diff --git a/contrib/array/array_iterator.c b/contrib/array/array_iterator.c
index cadda58a8f47973b84c836450a6c2664cbf71ebf..aa8697fb037f1dbbda196e543f710ae2a9c52912 100644
--- a/contrib/array/array_iterator.c
+++ b/contrib/array/array_iterator.c
@@ -144,7 +144,7 @@ array_texteq(ArrayType *array, char *value)
 {
 	return array_iterator((Oid) 25,		/* text */
 						  (Oid) 67,		/* texteq */
-						  0,			/* logical or */
+						  0,	/* logical or */
 						  array, (Datum) value);
 }
 
@@ -153,7 +153,7 @@ array_all_texteq(ArrayType *array, char *value)
 {
 	return array_iterator((Oid) 25,		/* text */
 						  (Oid) 67,		/* texteq */
-						  1,			/* logical and */
+						  1,	/* logical and */
 						  array, (Datum) value);
 }
 
@@ -162,7 +162,7 @@ array_textregexeq(ArrayType *array, char *value)
 {
 	return array_iterator((Oid) 25,		/* text */
 						  (Oid) 1254,	/* textregexeq */
-						  0,			/* logical or */
+						  0,	/* logical or */
 						  array, (Datum) value);
 }
 
@@ -171,7 +171,7 @@ array_all_textregexeq(ArrayType *array, char *value)
 {
 	return array_iterator((Oid) 25,		/* text */
 						  (Oid) 1254,	/* textregexeq */
-						  1,			/* logical and */
+						  1,	/* logical and */
 						  array, (Datum) value);
 }
 
@@ -185,7 +185,7 @@ array_varchareq(ArrayType *array, char *value)
 {
 	return array_iterator((Oid) 1043,	/* varchar */
 						  (Oid) 1070,	/* varchareq */
-						  0,			/* logical or */
+						  0,	/* logical or */
 						  array, (Datum) value);
 }
 
@@ -194,7 +194,7 @@ array_all_varchareq(ArrayType *array, char *value)
 {
 	return array_iterator((Oid) 1043,	/* varchar */
 						  (Oid) 1070,	/* varchareq */
-						  1,			/* logical and */
+						  1,	/* logical and */
 						  array, (Datum) value);
 }
 
@@ -203,7 +203,7 @@ array_varcharregexeq(ArrayType *array, char *value)
 {
 	return array_iterator((Oid) 1043,	/* varchar */
 						  (Oid) 1254,	/* textregexeq */
-						  0,			/* logical or */
+						  0,	/* logical or */
 						  array, (Datum) value);
 }
 
@@ -212,7 +212,7 @@ array_all_varcharregexeq(ArrayType *array, char *value)
 {
 	return array_iterator((Oid) 1043,	/* varchar */
 						  (Oid) 1254,	/* textregexeq */
-						  1,			/* logical and */
+						  1,	/* logical and */
 						  array, (Datum) value);
 }
 
@@ -226,7 +226,7 @@ array_bpchareq(ArrayType *array, char *value)
 {
 	return array_iterator((Oid) 1042,	/* bpchar */
 						  (Oid) 1048,	/* bpchareq */
-						  0,			/* logical or */
+						  0,	/* logical or */
 						  array, (Datum) value);
 }
 
@@ -235,7 +235,7 @@ array_all_bpchareq(ArrayType *array, char *value)
 {
 	return array_iterator((Oid) 1042,	/* bpchar */
 						  (Oid) 1048,	/* bpchareq */
-						  1,			/* logical and */
+						  1,	/* logical and */
 						  array, (Datum) value);
 }
 
@@ -244,7 +244,7 @@ array_bpcharregexeq(ArrayType *array, char *value)
 {
 	return array_iterator((Oid) 1042,	/* bpchar */
 						  (Oid) 1254,	/* textregexeq */
-						  0,			/* logical or */
+						  0,	/* logical or */
 						  array, (Datum) value);
 }
 
@@ -253,7 +253,7 @@ array_all_bpcharregexeq(ArrayType *array, char *value)
 {
 	return array_iterator((Oid) 1042,	/* bpchar */
 						  (Oid) 1254,	/* textregexeq */
-						  1,			/* logical and */
+						  1,	/* logical and */
 						  array, (Datum) value);
 }
 
@@ -266,7 +266,7 @@ array_int4eq(ArrayType *array, int4 value)
 {
 	return array_iterator((Oid) 23,		/* int4 */
 						  (Oid) 65,		/* int4eq */
-						  0,			/* logical or */
+						  0,	/* logical or */
 						  array, (Datum) value);
 }
 
@@ -275,7 +275,7 @@ array_all_int4eq(ArrayType *array, int4 value)
 {
 	return array_iterator((Oid) 23,		/* int4 */
 						  (Oid) 65,		/* int4eq */
-						  1,			/* logical and */
+						  1,	/* logical and */
 						  array, (Datum) value);
 }
 
@@ -284,7 +284,7 @@ array_int4ne(ArrayType *array, int4 value)
 {
 	return array_iterator((Oid) 23,		/* int4 */
 						  (Oid) 144,	/* int4ne */
-						  0,			/* logical or */
+						  0,	/* logical or */
 						  array, (Datum) value);
 }
 
@@ -293,7 +293,7 @@ array_all_int4ne(ArrayType *array, int4 value)
 {
 	return array_iterator((Oid) 23,		/* int4 */
 						  (Oid) 144,	/* int4ne */
-						  1,			/* logical and */
+						  1,	/* logical and */
 						  array, (Datum) value);
 }
 
@@ -302,7 +302,7 @@ array_int4gt(ArrayType *array, int4 value)
 {
 	return array_iterator((Oid) 23,		/* int4 */
 						  (Oid) 147,	/* int4gt */
-						  0,			/* logical or */
+						  0,	/* logical or */
 						  array, (Datum) value);
 }
 
@@ -311,7 +311,7 @@ array_all_int4gt(ArrayType *array, int4 value)
 {
 	return array_iterator((Oid) 23,		/* int4 */
 						  (Oid) 147,	/* int4gt */
-						  1,			/* logical and */
+						  1,	/* logical and */
 						  array, (Datum) value);
 }
 
@@ -320,7 +320,7 @@ array_int4ge(ArrayType *array, int4 value)
 {
 	return array_iterator((Oid) 23,		/* int4 */
 						  (Oid) 150,	/* int4ge */
-						  0,			/* logical or */
+						  0,	/* logical or */
 						  array, (Datum) value);
 }
 
@@ -329,7 +329,7 @@ array_all_int4ge(ArrayType *array, int4 value)
 {
 	return array_iterator((Oid) 23,		/* int4 */
 						  (Oid) 150,	/* int4ge */
-						  1,			/* logical and */
+						  1,	/* logical and */
 						  array, (Datum) value);
 }
 
@@ -338,7 +338,7 @@ array_int4lt(ArrayType *array, int4 value)
 {
 	return array_iterator((Oid) 23,		/* int4 */
 						  (Oid) 66,		/* int4lt */
-						  0,			/* logical or */
+						  0,	/* logical or */
 						  array, (Datum) value);
 }
 
@@ -347,7 +347,7 @@ array_all_int4lt(ArrayType *array, int4 value)
 {
 	return array_iterator((Oid) 23,		/* int4 */
 						  (Oid) 66,		/* int4lt */
-						  1,			/* logical and */
+						  1,	/* logical and */
 						  array, (Datum) value);
 }
 
@@ -356,7 +356,7 @@ array_int4le(ArrayType *array, int4 value)
 {
 	return array_iterator((Oid) 23,		/* int4 */
 						  (Oid) 149,	/* int4le */
-						  0,			/* logical or */
+						  0,	/* logical or */
 						  array, (Datum) value);
 }
 
@@ -365,7 +365,7 @@ array_all_int4le(ArrayType *array, int4 value)
 {
 	return array_iterator((Oid) 23,		/* int4 */
 						  (Oid) 149,	/* int4le */
-						  1,			/* logical and */
+						  1,	/* logical and */
 						  array, (Datum) value);
 }
 
@@ -376,7 +376,7 @@ array_oideq(ArrayType *array, Oid value)
 {
 	return array_iterator((Oid) 26,		/* oid */
 						  (Oid) 184,	/* oideq */
-						  0,			/* logical or */
+						  0,	/* logical or */
 						  array, (Datum) value);
 }
 
@@ -385,7 +385,7 @@ array_all_oidne(ArrayType *array, Oid value)
 {
 	return array_iterator((Oid) 26,		/* int4 */
 						  (Oid) 185,	/* oidne */
-						  1,			/* logical and */
+						  1,	/* logical and */
 						  array, (Datum) value);
 }
 
@@ -393,8 +393,8 @@ array_all_oidne(ArrayType *array, Oid value)
 
 /*
  * Local Variables:
- *  tab-width: 4
- *  c-indent-level: 4
- *  c-basic-offset: 4
+ *	tab-width: 4
+ *	c-indent-level: 4
+ *	c-basic-offset: 4
  * End:
  */
diff --git a/contrib/array/array_iterator.h b/contrib/array/array_iterator.h
index 9a386abd2c7959dea151a0e2cfcb8408f56cbc5f..68da385c9a4b48895d5875420dbcae9b21cc5bad 100644
--- a/contrib/array/array_iterator.h
+++ b/contrib/array/array_iterator.h
@@ -2,7 +2,7 @@
 #define ARRAY_ITERATOR_H
 
 static int32 array_iterator(Oid elemtype, Oid proc, int and,
-							ArrayType *array, Datum value);
+			   ArrayType *array, Datum value);
 
 int32		array_texteq(ArrayType *array, char *value);
 int32		array_all_texteq(ArrayType *array, char *value);
@@ -32,14 +32,15 @@ int32		array_all_int4lt(ArrayType *array, int4 value);
 int32		array_int4le(ArrayType *array, int4 value);
 int32		array_all_int4le(ArrayType *array, int4 value);
 
-int32       array_oideq(ArrayType *array, Oid value);
-int32       array_all_oidne(ArrayType *array, Oid value);
+int32		array_oideq(ArrayType *array, Oid value);
+int32		array_all_oidne(ArrayType *array, Oid value);
+
 #endif
 
 /*
  * Local Variables:
- *  tab-width: 4
- *  c-indent-level: 4
- *  c-basic-offset: 4
+ *	tab-width: 4
+ *	c-indent-level: 4
+ *	c-basic-offset: 4
  * End:
  */
diff --git a/contrib/bit/varbit.c b/contrib/bit/varbit.c
index 2a677ec6040121657f1e35a4dc24c51891674e21..20caaf9f7cb170dd84d46bd3a88cfd95bfb91b72 100644
--- a/contrib/bit/varbit.c
+++ b/contrib/bit/varbit.c
@@ -4,7 +4,7 @@
  *	  Functions for the built-in type bit() and varying bit().
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/contrib/bit/Attic/varbit.c,v 1.2 2000/04/03 20:56:40 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/contrib/bit/Attic/varbit.c,v 1.3 2000/04/12 17:14:21 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -14,19 +14,19 @@
 /*#include "utils/builtins.h" */
 
 
-/* 
+/*
    Prefixes:
-     zp    -- zero-padded fixed length bit string
-     var   -- varying bit string
+	 zp    -- zero-padded fixed length bit string
+	 var   -- varying bit string
 
    attypmod -- contains the length of the bit string in bits, or for
-               varying bits the maximum length. 
+			   varying bits the maximum length.
 
    The data structure contains the following elements:
-      header  -- length of the whole data structure (incl header)
-                 in bytes. (as with all varying length datatypes)
-      data section -- private data section for the bits data structures
-         bitlength -- lenght of the bit string in bits
+	  header  -- length of the whole data structure (incl header)
+				 in bytes. (as with all varying length datatypes)
+	  data section -- private data section for the bits data structures
+		 bitlength -- lenght of the bit string in bits
 	 bitdata   -- least significant byte first string
 */
 
@@ -34,214 +34,241 @@
  * zpbitin -
 
  *	  converts a string to the internal representation of a bitstring.
- *        The length is determined by the number of bits required plus
- *        VARHDRSZ bytes or from atttypmod. 
- *	  (XXX dummy is here because we pass typelem as the second argument 
- *        for array_in. copied this, no idea what it means??)
+ *		  The length is determined by the number of bits required plus
+ *		  VARHDRSZ bytes or from atttypmod.
+ *	  (XXX dummy is here because we pass typelem as the second argument
+ *		  for array_in. copied this, no idea what it means??)
  */
 bits8 *
-zpbitin(char *s, int dummy,  int32 atttypmod)
+zpbitin(char *s, int dummy, int32 atttypmod)
 {
-  bits8 *result;	/* the bits string that was read in   */ 
-  char  *sp;		/* pointer into the character string  */
-  bits8 *r;
-  int len,		/* Length of the whole data structure */
-    bitlen,		/* Number of bits in the bit string   */
-    slen;		/* Length of the input string         */
-  int bit_not_hex = 0;  /* 0 = hex string  1=bit string       */
-  int bc, ipad;
-  bits8 x = 0;
-
-
-  if (s == NULL)
-    return (bits8 *) NULL;
-
-  /* Check that the first character is a b or an x */
-  if (s[0]=='b' || s[0]=='B') 
-      bit_not_hex = 1;
-  else if (s[0]=='x' || s[0]=='X') 
-      bit_not_hex = 0;
-  else 
-    elog(ERROR, "zpbitin: %s is not a valid bitstring",s);
-
-  slen = strlen(s) - 1;
-  /* Determine bitlength from input string */
-  bitlen = slen;
-  if (!bit_not_hex)
-    bitlen *= 4;
-  
-  /* Sometimes atttypmod is not supplied. If it is supplied we need to make
-     sure that the bitstring fits. Note that the number of infered bits can
-     be larger than the number of actual bits needed, but only if we are 
-     reading a hex string and not by more than 3 bits, as a hex string gives 
-     and accurate length upto 4 bits */
-  if (atttypmod == -1)
-    atttypmod = bitlen;
-  else
-    if ((bitlen>atttypmod && bit_not_hex) || 
-	(bitlen>atttypmod+3 && !bit_not_hex))
-	  elog(ERROR, "zpbitin: bit string of size %d cannot be written into bits(%d)",
-	       bitlen,atttypmod);
-
-
-  len = VARBITDATALEN(atttypmod);
-
-  if (len > MaxAttrSize)
-    elog(ERROR, "zpbitin: length of bit() must be less than %ld",
-	 (MaxAttrSize-VARHDRSZ-VARBITHDRSZ)*BITSPERBYTE);
-
-  result = (bits8 *) palloc(len);
-  /* set to 0 so that *r is always initialised and strin is zero-padded */
-  memset(result, 0, len);
-  VARSIZE(result) = len;
-  VARBITLEN(result) = atttypmod;
-
-  /* We need to read the bitstring from the end, as we store it least 
-     significant byte first. s points to the byte before the beginning
-     of the bitstring */
-  sp = s+1;
-  r = VARBITS(result);
-  if (bit_not_hex) 
-    {
-      /* Parse the bit representation of the string */
-      /* We know it fits, as bitlen was compared to atttypmod */
-      x = BITHIGH;
-      for (bc = 0; sp != s+slen+1; sp++, bc++)
+	bits8	   *result;			/* the bits string that was read in   */
+	char	   *sp;				/* pointer into the character string  */
+	bits8	   *r;
+	int			len,			/* Length of the whole data structure */
+				bitlen,			/* Number of bits in the bit string   */
+				slen;			/* Length of the input string		  */
+	int			bit_not_hex = 0;/* 0 = hex string  1=bit string		  */
+	int			bc,
+				ipad;
+	bits8		x = 0;
+
+
+	if (s == NULL)
+		return (bits8 *) NULL;
+
+	/* Check that the first character is a b or an x */
+	if (s[0] == 'b' || s[0] == 'B')
+		bit_not_hex = 1;
+	else if (s[0] == 'x' || s[0] == 'X')
+		bit_not_hex = 0;
+	else
+		elog(ERROR, "zpbitin: %s is not a valid bitstring", s);
+
+	slen = strlen(s) - 1;
+	/* Determine bitlength from input string */
+	bitlen = slen;
+	if (!bit_not_hex)
+		bitlen *= 4;
+
+	/*
+	 * Sometimes atttypmod is not supplied. If it is supplied we need to
+	 * make sure that the bitstring fits. Note that the number of infered
+	 * bits can be larger than the number of actual bits needed, but only
+	 * if we are reading a hex string and not by more than 3 bits, as a
+	 * hex string gives and accurate length upto 4 bits
+	 */
+	if (atttypmod == -1)
+		atttypmod = bitlen;
+	else if ((bitlen > atttypmod && bit_not_hex) ||
+			 (bitlen > atttypmod + 3 && !bit_not_hex))
+		elog(ERROR, "zpbitin: bit string of size %d cannot be written into bits(%d)",
+			 bitlen, atttypmod);
+
+
+	len = VARBITDATALEN(atttypmod);
+
+	if (len > MaxAttrSize)
+		elog(ERROR, "zpbitin: length of bit() must be less than %ld",
+			 (MaxAttrSize - VARHDRSZ - VARBITHDRSZ) * BITSPERBYTE);
+
+	result = (bits8 *) palloc(len);
+	/* set to 0 so that *r is always initialised and strin is zero-padded */
+	memset(result, 0, len);
+	VARSIZE(result) = len;
+	VARBITLEN(result) = atttypmod;
+
+	/*
+	 * We need to read the bitstring from the end, as we store it least
+	 * significant byte first. s points to the byte before the beginning
+	 * of the bitstring
+	 */
+	sp = s + 1;
+	r = VARBITS(result);
+	if (bit_not_hex)
+	{
+		/* Parse the bit representation of the string */
+		/* We know it fits, as bitlen was compared to atttypmod */
+		x = BITHIGH;
+		for (bc = 0; sp != s + slen + 1; sp++, bc++)
+		{
+			if (*sp == '1')
+				*r |= x;
+			if (bc == 7)
+			{
+				bc = 0;
+				x = BITHIGH;
+				r++;
+			}
+			else
+				x >>= 1;
+		}
+	}
+	else
 	{
-	  if (*sp=='1')
-	    *r |= x;
-	  if (bc==7) {
-	    bc = 0;
-	    x = BITHIGH;
-	    r++;
-	  } else 
-	    x >>= 1;
+		/* Parse the hex representation of the string */
+		for (bc = 0; sp != s + slen + 1; sp++)
+		{
+			if (*sp >= '0' && *sp <= '9')
+				x = (bits8) (*sp - '0');
+			else if (*sp >= 'A' && *sp <= 'F')
+				x = (bits8) (*sp - 'A') + 10;
+			else if (*sp >= 'a' && *sp <= 'f')
+				x = (bits8) (*sp - 'a') + 10;
+			else
+				elog(ERROR, "Cannot parse %c as a hex digit", *sp);
+			if (bc)
+			{
+				bc = 0;
+				*r++ |= x;
+			}
+			else
+			{
+				bc++;
+				*r = x << 4;
+			}
+		}
 	}
-     }
-  else 
-    {
-      /* Parse the hex representation of the string */
-      for (bc = 0; sp != s+slen+1; sp++)
+
+	if (bitlen > atttypmod)
 	{
-	  if (*sp>='0' && *sp<='9') 
-	    x = (bits8) (*sp - '0');
-	  else if (*sp>='A' && *sp<='F') 
-	    x = (bits8) (*sp - 'A') + 10;
-	  else if (*sp>='a' && *sp<='f') 
-	    x = (bits8) (*sp - 'a') + 10;
-	  else 
-	    elog(ERROR,"Cannot parse %c as a hex digit",*sp);
-	  if (bc) {
-	    bc = 0;
-	    *r++ |= x;
-	  } else {
-	    bc++;
-	    *r = x<<4;
-	  }
+		/* Check that this fitted */
+		r = (bits8 *) (result + len - 1);
+		ipad = VARBITPAD(result);
+
+		/*
+		 * The bottom ipad bits of the byte pointed to by r need to be
+		 * zero
+		 */
+
+		/*
+		 * printf("Byte %X  shift %X %d\n",*r,(*r << (8-ipad)) & BITMASK,
+		 * (*r << (8-ipad)) & BITMASK > 0);
+		 */
+		if (((*r << (BITSPERBYTE - ipad)) & BITMASK) > 0)
+			elog(ERROR, "zpbitin: bit string too large for bit(%d) data type",
+				 atttypmod);
 	}
-    }
-
-  if (bitlen > atttypmod) {
-    /* Check that this fitted */
-    r = (bits8 *) (result + len - 1);
-    ipad = VARBITPAD(result);
-    /* The bottom ipad bits of the byte pointed to by r need to be zero */
-    /*    printf("Byte %X  shift %X %d\n",*r,(*r << (8-ipad)) & BITMASK,
-	   (*r << (8-ipad)) & BITMASK > 0);
-    */
-    if (((*r << (BITSPERBYTE-ipad)) & BITMASK) > 0)
-      elog(ERROR, "zpbitin: bit string too large for bit(%d) data type",
-	   atttypmod);
-  }
-
-  return result;
+
+	return result;
 }
 
 /* zpbitout -
- *    for the time being we print everything as hex strings, as this is likely 
- *    to be more compact than bit strings, and consequently much more efficient
- *    for long strings
+ *	  for the time being we print everything as hex strings, as this is likely
+ *	  to be more compact than bit strings, and consequently much more efficient
+ *	  for long strings
  */
 char *
 zpbitout(bits8 *s)
 {
-  char	   *result, *r;
-  bits8    *sp;
-  int	   i, len, bitlen;
-  
-  if (s == NULL)
-    {
-      result = (char *) palloc(2);
-      result[0] = '-';
-      result[1] = '\0';
-    }
-  else
-    {
-      bitlen = VARBITLEN(s);
-      len = bitlen/4 + (bitlen%4>0 ? 1 : 0);
-      result = (char *) palloc(len + 4);
-      sp = VARBITS(s);
-      r = result;
-      *r++ = 'X';
-      *r++ = '\'';
-      /* we cheat by knowing that we store full bytes zero padded */
-      for (i=0; i<len; i+=2, sp++) {
-	*r++ = HEXDIG((*sp)>>4);
-	*r++ = HEXDIG((*sp) & 0xF);
-      }
-      /* Go back one step if we printed a hex number that was not part
-	 of the bitstring anymore */
-      if (i==len+1)
-	r--;
-      *r++ = '\'';
-      *r = '\0';
-    }
-  return result;
+	char	   *result,
+			   *r;
+	bits8	   *sp;
+	int			i,
+				len,
+				bitlen;
+
+	if (s == NULL)
+	{
+		result = (char *) palloc(2);
+		result[0] = '-';
+		result[1] = '\0';
+	}
+	else
+	{
+		bitlen = VARBITLEN(s);
+		len = bitlen / 4 + (bitlen % 4 > 0 ? 1 : 0);
+		result = (char *) palloc(len + 4);
+		sp = VARBITS(s);
+		r = result;
+		*r++ = 'X';
+		*r++ = '\'';
+		/* we cheat by knowing that we store full bytes zero padded */
+		for (i = 0; i < len; i += 2, sp++)
+		{
+			*r++ = HEXDIG((*sp) >> 4);
+			*r++ = HEXDIG((*sp) & 0xF);
+		}
+
+		/*
+		 * Go back one step if we printed a hex number that was not part
+		 * of the bitstring anymore
+		 */
+		if (i == len + 1)
+			r--;
+		*r++ = '\'';
+		*r = '\0';
+	}
+	return result;
 }
 
 /* zpbitsout -
- *    Prints the string a bits
+ *	  Prints the string a bits
  */
 char *
 zpbitsout(bits8 *s)
 {
-  char	   *result, *r;
-  bits8    *sp;
-  bits8    x;
-  int	   i, k, len;
-  
-  if (s == NULL)
-    {
-      result = (char *) palloc(2);
-      result[0] = '-';
-      result[1] = '\0';
-    }
-  else
-    {
-      len = VARBITLEN(s);
-      result = (char *) palloc(len + 4);
-      sp = VARBITS(s);
-      r = result;
-      *r++ = 'B';
-      *r++ = '\'';
-      for (i=0; i<len-BITSPERBYTE; i+=BITSPERBYTE, sp++) {
-	x = *sp;
-	for (k=0; k<BITSPERBYTE; k++) 
-	  {
-	    *r++ = (x & BITHIGH) ? '1' : '0';
-	    x <<= 1;
-	  }
-      }
-      x = *sp;
-      for (k=i; k<len; k++)
+	char	   *result,
+			   *r;
+	bits8	   *sp;
+	bits8		x;
+	int			i,
+				k,
+				len;
+
+	if (s == NULL)
 	{
-	  *r++ = (x & BITHIGH) ? '1' : '0';
-	  x <<= 1;
+		result = (char *) palloc(2);
+		result[0] = '-';
+		result[1] = '\0';
 	}
-      *r++ = '\'';
-      *r = '\0';
-    }
-  return result;
+	else
+	{
+		len = VARBITLEN(s);
+		result = (char *) palloc(len + 4);
+		sp = VARBITS(s);
+		r = result;
+		*r++ = 'B';
+		*r++ = '\'';
+		for (i = 0; i < len - BITSPERBYTE; i += BITSPERBYTE, sp++)
+		{
+			x = *sp;
+			for (k = 0; k < BITSPERBYTE; k++)
+			{
+				*r++ = (x & BITHIGH) ? '1' : '0';
+				x <<= 1;
+			}
+		}
+		x = *sp;
+		for (k = i; k < len; k++)
+		{
+			*r++ = (x & BITHIGH) ? '1' : '0';
+			x <<= 1;
+		}
+		*r++ = '\'';
+		*r = '\0';
+	}
+	return result;
 }
 
 
@@ -250,118 +277,133 @@ zpbitsout(bits8 *s)
  *	  converts a string to the internal representation of a bitstring.
 */
 bits8 *
-varbitin(char *s, int dummy,  int32 atttypmod)
+varbitin(char *s, int dummy, int32 atttypmod)
 {
-  bits8 *result;	/* The resulting bit string           */
-  char *sp;		/* pointer into the character string  */
-  bits8 *r;
-  int len,		/* Length of the whole data structure */
-    bitlen,		/* Number of bits in the bit string   */
-    slen;		/* Length of the input string         */
-  int bit_not_hex = 0;
-  int bc, ipad;
-  bits8 x = 0;
-
-
-  if (s == NULL)
-    return (bits8 *) NULL;
-
-  /* Check that the first character is a b or an x */
-  if (s[0]=='b' || s[0]=='B') 
-      bit_not_hex = 1;
-  else if (s[0]=='x' || s[0]=='X') 
-      bit_not_hex = 0;
-  else 
-    elog(ERROR, "zpbitin: %s is not a valid bitstring",s);
-
-  slen = strlen(s) - 1;
-  /* Determine bitlength from input string */
-  bitlen = slen;
-  if (!bit_not_hex)
-    bitlen *= 4;
-  
-  /* Sometimes atttypmod is not supplied. If it is supplied we need to make
-     sure that the bitstring fits. Note that the number of infered bits can
-     be larger than the number of actual bits needed, but only if we are 
-     reading a hex string and not by more than 3 bits, as a hex string gives 
-     and accurate length upto 4 bits */
-  if (atttypmod > -1)
-    if ((bitlen>atttypmod && bit_not_hex) || 
-	(bitlen>atttypmod+3 && !bit_not_hex))
-	  elog(ERROR, "varbitin: bit string of size %d cannot be written into varying bits(%d)",
-	       bitlen,atttypmod);
-
-
-  len = VARBITDATALEN(bitlen);
-
-  if (len > MaxAttrSize)
-    elog(ERROR, "varbitin: length of bit() must be less than %ld",
-	 (MaxAttrSize-VARHDRSZ-VARBITHDRSZ)*BITSPERBYTE);
-
-  result = (bits8 *) palloc(len);
-  /* set to 0 so that *r is always initialised and strin is zero-padded */
-  memset(result, 0, len);
-  VARSIZE(result) = len;
-  VARBITLEN(result) = bitlen;
-
-  /* We need to read the bitstring from the end, as we store it least 
-     significant byte first. s points to the byte before the beginning
-     of the bitstring */
-  sp = s + 1;
-  r = VARBITS(result);
-  if (bit_not_hex) 
-    {
-      /* Parse the bit representation of the string */
-      x = BITHIGH;
-      for (bc = 0; sp != s+slen+1; sp++, bc++)
+	bits8	   *result;			/* The resulting bit string			  */
+	char	   *sp;				/* pointer into the character string  */
+	bits8	   *r;
+	int			len,			/* Length of the whole data structure */
+				bitlen,			/* Number of bits in the bit string   */
+				slen;			/* Length of the input string		  */
+	int			bit_not_hex = 0;
+	int			bc,
+				ipad;
+	bits8		x = 0;
+
+
+	if (s == NULL)
+		return (bits8 *) NULL;
+
+	/* Check that the first character is a b or an x */
+	if (s[0] == 'b' || s[0] == 'B')
+		bit_not_hex = 1;
+	else if (s[0] == 'x' || s[0] == 'X')
+		bit_not_hex = 0;
+	else
+		elog(ERROR, "zpbitin: %s is not a valid bitstring", s);
+
+	slen = strlen(s) - 1;
+	/* Determine bitlength from input string */
+	bitlen = slen;
+	if (!bit_not_hex)
+		bitlen *= 4;
+
+	/*
+	 * Sometimes atttypmod is not supplied. If it is supplied we need to
+	 * make sure that the bitstring fits. Note that the number of infered
+	 * bits can be larger than the number of actual bits needed, but only
+	 * if we are reading a hex string and not by more than 3 bits, as a
+	 * hex string gives and accurate length upto 4 bits
+	 */
+	if (atttypmod > -1)
+		if ((bitlen > atttypmod && bit_not_hex) ||
+			(bitlen > atttypmod + 3 && !bit_not_hex))
+			elog(ERROR, "varbitin: bit string of size %d cannot be written into varying bits(%d)",
+				 bitlen, atttypmod);
+
+
+	len = VARBITDATALEN(bitlen);
+
+	if (len > MaxAttrSize)
+		elog(ERROR, "varbitin: length of bit() must be less than %ld",
+			 (MaxAttrSize - VARHDRSZ - VARBITHDRSZ) * BITSPERBYTE);
+
+	result = (bits8 *) palloc(len);
+	/* set to 0 so that *r is always initialised and strin is zero-padded */
+	memset(result, 0, len);
+	VARSIZE(result) = len;
+	VARBITLEN(result) = bitlen;
+
+	/*
+	 * We need to read the bitstring from the end, as we store it least
+	 * significant byte first. s points to the byte before the beginning
+	 * of the bitstring
+	 */
+	sp = s + 1;
+	r = VARBITS(result);
+	if (bit_not_hex)
+	{
+		/* Parse the bit representation of the string */
+		x = BITHIGH;
+		for (bc = 0; sp != s + slen + 1; sp++, bc++)
+		{
+			if (*sp == '1')
+				*r |= x;
+			if (bc == 7)
+			{
+				bc = 0;
+				x = BITHIGH;
+				r++;
+			}
+			else
+				x >>= 1;
+		}
+	}
+	else
 	{
-	  if (*sp=='1')
-	    *r |= x;
-	  if (bc==7) {
-	    bc = 0;
-	    x = BITHIGH;
-	    r++;
-	  } else 
-	    x >>= 1;
+		for (bc = 0; sp != s + slen + 1; sp++)
+		{
+			if (*sp >= '0' && *sp <= '9')
+				x = (bits8) (*sp - '0');
+			else if (*sp >= 'A' && *sp <= 'F')
+				x = (bits8) (*sp - 'A') + 10;
+			else if (*sp >= 'a' && *sp <= 'f')
+				x = (bits8) (*sp - 'a') + 10;
+			else
+				elog(ERROR, "Cannot parse %c as a hex digit", *sp);
+			if (bc)
+			{
+				bc = 0;
+				*r++ |= x;
+			}
+			else
+			{
+				bc++;
+				*r = x << 4;
+			}
+		}
 	}
-     }
-  else 
-    {
-      for (bc = 0; sp != s+slen+1; sp++)
+
+	if (bitlen > atttypmod)
 	{
-	  if (*sp>='0' && *sp<='9') 
-	    x = (bits8) (*sp - '0');
-	  else if (*sp>='A' && *sp<='F') 
-	    x = (bits8) (*sp - 'A') + 10;
-	  else if (*sp>='a' && *sp<='f') 
-	    x = (bits8) (*sp - 'a') + 10;
-	  else 
-	    elog(ERROR,"Cannot parse %c as a hex digit",*sp);
-	  if (bc) {
-	    bc = 0;
-	    *r++ |= x;
-	  } else {
-	    bc++;
-	    *r = x<<4;
-	  }
+		/* Check that this fitted */
+		r = (bits8 *) (result + len - 1);
+		ipad = VARBITPAD(result);
+
+		/*
+		 * The bottom ipad bits of the byte pointed to by r need to be
+		 * zero
+		 */
+		if (((*r << (BITSPERBYTE - ipad)) & BITMASK) > 0)
+			elog(ERROR, "varbitin: bit string too large for varying bit(%d) data type",
+				 atttypmod);
 	}
-    }
-
-  if (bitlen > atttypmod) {
-    /* Check that this fitted */
-    r = (bits8 *) (result + len - 1);
-    ipad = VARBITPAD(result);
-    /* The bottom ipad bits of the byte pointed to by r need to be zero */
-    if (((*r << (BITSPERBYTE-ipad)) & BITMASK) > 0)
-      elog(ERROR, "varbitin: bit string too large for varying bit(%d) data type",
-	   atttypmod);
-  }
-
-  return result;
+
+	return result;
 }
 
 /*
-  the zpbitout routines are fine for varying bits as well 
+  the zpbitout routines are fine for varying bits as well
 */
 
 
@@ -369,228 +411,244 @@ varbitin(char *s, int dummy,  int32 atttypmod)
  * Comparison operators
  *
  * We only need one set of comparison operators for bitstrings, as the lengths
- * are stored in the same way for zero-padded and varying bit strings. 
+ * are stored in the same way for zero-padded and varying bit strings.
  *
- * Note that the standard is not unambiguous about the comparison between 
+ * Note that the standard is not unambiguous about the comparison between
  * zero-padded bit strings and varying bitstrings. If the same value is written
- * into a zero padded bitstring as into a varying bitstring, but the zero 
- * padded bitstring has greater length, it will be bigger. 
+ * into a zero padded bitstring as into a varying bitstring, but the zero
+ * padded bitstring has greater length, it will be bigger.
  *
  * Zeros from the beginning of a bitstring cannot simply be ignored, as they
  * may be part of a bit string and may be significant.
  */
 
 bool
-biteq (bits8 *arg1, bits8 *arg2)
+biteq(bits8 *arg1, bits8 *arg2)
 {
-  int bitlen1,
-    bitlen2;
-
-  if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
-    return (bool) 0;
-  bitlen1 = VARBITLEN(arg1);
-  bitlen2 = VARBITLEN(arg2);
-  if (bitlen1 != bitlen2)
-    return (bool) 0;
-  
-  /* bit strings are always stored in a full number of bytes */
-  return memcmp((void *)VARBITS(arg1),(void *)VARBITS(arg2),
-		VARBITBYTES(arg1)) == 0;
+	int			bitlen1,
+				bitlen2;
+
+	if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
+		return (bool) 0;
+	bitlen1 = VARBITLEN(arg1);
+	bitlen2 = VARBITLEN(arg2);
+	if (bitlen1 != bitlen2)
+		return (bool) 0;
+
+	/* bit strings are always stored in a full number of bytes */
+	return memcmp((void *) VARBITS(arg1), (void *) VARBITS(arg2),
+				  VARBITBYTES(arg1)) == 0;
 }
 
 bool
-bitne (bits8 *arg1, bits8 *arg2)
+bitne(bits8 *arg1, bits8 *arg2)
 {
-  int bitlen1,
-    bitlen2;
-
-  if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
-    return (bool) 0;
-  bitlen1 = VARBITLEN(arg1);
-  bitlen2 = VARBITLEN(arg2);
-  if (bitlen1 != bitlen2)
-    return (bool) 1;
-  
-  /* bit strings are always stored in a full number of bytes */
-  return memcmp((void *)VARBITS(arg1),(void *)VARBITS(arg2),
-		VARBITBYTES(arg1)) != 0;
+	int			bitlen1,
+				bitlen2;
+
+	if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
+		return (bool) 0;
+	bitlen1 = VARBITLEN(arg1);
+	bitlen2 = VARBITLEN(arg2);
+	if (bitlen1 != bitlen2)
+		return (bool) 1;
+
+	/* bit strings are always stored in a full number of bytes */
+	return memcmp((void *) VARBITS(arg1), (void *) VARBITS(arg2),
+				  VARBITBYTES(arg1)) != 0;
 }
 
 /* bitcmp
- * 
+ *
  * Compares two bitstrings and returns -1, 0, 1 depending on whether the first
  * string is smaller, equal, or bigger than the second. All bits are considered
  * and additional zero bits may make one string smaller/larger than the other,
  * even if their zero-padded values would be the same.
- *   Anything is equal to undefined.
+ *	 Anything is equal to undefined.
  */
-int 
-bitcmp (bits8 *arg1, bits8 *arg2)
+int
+bitcmp(bits8 *arg1, bits8 *arg2)
 {
-  int bitlen1, bytelen1,
-    bitlen2, bytelen2;
-  int cmp;
-
-  if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
-    return (bool) 0;
-  bytelen1 = VARBITBYTES(arg1);  
-  bytelen2 = VARBITBYTES(arg2);
-  
-  cmp = memcmp(VARBITS(arg1),VARBITS(arg2),Min(bytelen1,bytelen2));
-  if (cmp==0) {
-    bitlen1 = VARBITLEN(arg1);
-    bitlen2 = VARBITLEN(arg2);
-    if (bitlen1 != bitlen2) 
-      return bitlen1 < bitlen2 ? -1 : 1;
-  }
-  return cmp;
+	int			bitlen1,
+				bytelen1,
+				bitlen2,
+				bytelen2;
+	int			cmp;
+
+	if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
+		return (bool) 0;
+	bytelen1 = VARBITBYTES(arg1);
+	bytelen2 = VARBITBYTES(arg2);
+
+	cmp = memcmp(VARBITS(arg1), VARBITS(arg2), Min(bytelen1, bytelen2));
+	if (cmp == 0)
+	{
+		bitlen1 = VARBITLEN(arg1);
+		bitlen2 = VARBITLEN(arg2);
+		if (bitlen1 != bitlen2)
+			return bitlen1 < bitlen2 ? -1 : 1;
+	}
+	return cmp;
 }
 
 bool
-bitlt (bits8 *arg1, bits8 *arg2)
+bitlt(bits8 *arg1, bits8 *arg2)
 {
-  return (bool) (bitcmp(arg1,arg2) == -1);
+	return (bool) (bitcmp(arg1, arg2) == -1);
 }
 
 bool
-bitle (bits8 *arg1, bits8 *arg2)
+bitle(bits8 *arg1, bits8 *arg2)
 {
-  return (bool) (bitcmp(arg1,arg2) <= 0);
+	return (bool) (bitcmp(arg1, arg2) <= 0);
 }
 
 bool
-bitge (bits8 *arg1, bits8 *arg2)
+bitge(bits8 *arg1, bits8 *arg2)
 {
-  return (bool) (bitcmp(arg1,arg2) >= 0);
+	return (bool) (bitcmp(arg1, arg2) >= 0);
 }
 
 bool
-bitgt (bits8 *arg1, bits8 *arg2)
+bitgt(bits8 *arg1, bits8 *arg2)
 {
-  return (bool) (bitcmp(arg1,arg2) == 1);
+	return (bool) (bitcmp(arg1, arg2) == 1);
 }
 
 /* bitcat
  * Concatenation of bit strings
  */
 bits8 *
-bitcat (bits8 *arg1, bits8 *arg2)
+bitcat(bits8 *arg1, bits8 *arg2)
 {
-  int bitlen1, bitlen2, bytelen, bit1pad, bit2shift;
-  bits8 *result;
-  bits8 *pr, *pa;
-
-  if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
-    return NULL;
-
-  bitlen1 = VARBITLEN(arg1);
-  bitlen2 = VARBITLEN(arg2);
-
-  bytelen = VARBITDATALEN(bitlen1+bitlen2);
-  
-  result = (bits8 *) palloc(bytelen*sizeof(bits8));
-  VARSIZE(result) = bytelen;
-  VARBITLEN(result) = bitlen1+bitlen2;
-  printf("%d %d %d \n",VARBITBYTES(arg1),VARBITLEN(arg1),VARBITPAD(arg1));
-  /* Copy the first bitstring in */
-  memcpy(VARBITS(result),VARBITS(arg1),VARBITBYTES(arg1));
-  /* Copy the second bit string */
-  bit1pad = VARBITPAD(arg1);
-  if (bit1pad==0) 
-    {
-      memcpy(VARBITS(result)+VARBITBYTES(arg1),VARBITS(arg2),
-	     VARBITBYTES(arg2));
-    }
-  else if (bitlen2>0)
-    {
-      /* We need to shift all the results to fit */
-      bit2shift = BITSPERBYTE - bit1pad;
-      pa = VARBITS(arg2);
-      pr = VARBITS(result)+VARBITBYTES(arg1)-1;
-      for ( ; pa < VARBITEND(arg2); pa++) {
-	*pr |= ((*pa >> bit2shift) & BITMASK);
-	pr++;
-	if (pr < VARBITEND(result))
-	  *pr = (*pa << bit1pad) & BITMASK;
-      }
-    }
-
-  return result;
+	int			bitlen1,
+				bitlen2,
+				bytelen,
+				bit1pad,
+				bit2shift;
+	bits8	   *result;
+	bits8	   *pr,
+			   *pa;
+
+	if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
+		return NULL;
+
+	bitlen1 = VARBITLEN(arg1);
+	bitlen2 = VARBITLEN(arg2);
+
+	bytelen = VARBITDATALEN(bitlen1 + bitlen2);
+
+	result = (bits8 *) palloc(bytelen * sizeof(bits8));
+	VARSIZE(result) = bytelen;
+	VARBITLEN(result) = bitlen1 + bitlen2;
+	printf("%d %d %d \n", VARBITBYTES(arg1), VARBITLEN(arg1), VARBITPAD(arg1));
+	/* Copy the first bitstring in */
+	memcpy(VARBITS(result), VARBITS(arg1), VARBITBYTES(arg1));
+	/* Copy the second bit string */
+	bit1pad = VARBITPAD(arg1);
+	if (bit1pad == 0)
+	{
+		memcpy(VARBITS(result) + VARBITBYTES(arg1), VARBITS(arg2),
+			   VARBITBYTES(arg2));
+	}
+	else if (bitlen2 > 0)
+	{
+		/* We need to shift all the results to fit */
+		bit2shift = BITSPERBYTE - bit1pad;
+		pa = VARBITS(arg2);
+		pr = VARBITS(result) + VARBITBYTES(arg1) - 1;
+		for (; pa < VARBITEND(arg2); pa++)
+		{
+			*pr |= ((*pa >> bit2shift) & BITMASK);
+			pr++;
+			if (pr < VARBITEND(result))
+				*pr = (*pa << bit1pad) & BITMASK;
+		}
+	}
+
+	return result;
 }
 
 /* bitsubstr
- * retrieve a substring from the bit string. 
+ * retrieve a substring from the bit string.
  * Note, s is 1-based.
  * SQL draft 6.10 9)
  */
-bits8 * 
-bitsubstr (bits8 *arg, int32 s, int32 l)
+bits8 *
+bitsubstr(bits8 *arg, int32 s, int32 l)
 {
-  int bitlen,
-    rbitlen,
-    len,
-    ipad = 0,
-    ishift,
-    i;
-  int e, s1, e1;
-  bits8 * result;
-  bits8 mask, *r, *ps;
-
-  if (!PointerIsValid(arg))
-    return NULL;
-
-  bitlen = VARBITLEN(arg);
-  e = s+l;
-  s1 = Max(s,1);
-  e1 = Min(e,bitlen+1);
-  if (s1>bitlen || e1<1) 
-    {
-      /* Need to return a null string */
-      len = VARBITDATALEN(0);
-      result = (bits8 *) palloc(len);
-      VARBITLEN(result) = 0;
-      VARSIZE(result) = len;
-    } 
-  else 
-    {
-      /* OK, we've got a true substring starting at position s1-1 and 
-	 ending at position e1-1 */
-      rbitlen = e1-s1;
-      len = VARBITDATALEN(rbitlen);
-      result = (bits8 *) palloc(len);
-      VARBITLEN(result) = rbitlen;
-      VARSIZE(result) = len;
-      len -= VARHDRSZ + VARBITHDRSZ;
-      /* Are we copying from a byte boundary? */
-      if ((s1-1)%BITSPERBYTE==0) 
+	int			bitlen,
+				rbitlen,
+				len,
+				ipad = 0,
+				ishift,
+				i;
+	int			e,
+				s1,
+				e1;
+	bits8	   *result;
+	bits8		mask,
+			   *r,
+			   *ps;
+
+	if (!PointerIsValid(arg))
+		return NULL;
+
+	bitlen = VARBITLEN(arg);
+	e = s + l;
+	s1 = Max(s, 1);
+	e1 = Min(e, bitlen + 1);
+	if (s1 > bitlen || e1 < 1)
 	{
-	  /* Yep, we are copying bytes */
-	  memcpy(VARBITS(result),VARBITS(arg)+(s1-1)/BITSPERBYTE,len);
-	} 
-      else 
-	{
-	  /* Figure out how much we need to shift the sequence by */
-	  ishift = (s1-1)%BITSPERBYTE;
-	  r = VARBITS(result);
-	  ps = VARBITS(arg) + (s1-1)/BITSPERBYTE;
-	  for (i=0; i<len; i++) 
-	    {
-	      *r = (*ps <<ishift) & BITMASK;
-	      if ((++ps) < VARBITEND(arg))
-		*r |= *ps >>(BITSPERBYTE-ishift);
-	      r++;
-	    }
+		/* Need to return a null string */
+		len = VARBITDATALEN(0);
+		result = (bits8 *) palloc(len);
+		VARBITLEN(result) = 0;
+		VARSIZE(result) = len;
 	}
-      /* Do we need to pad at the end? */
-      ipad = VARBITPAD(result);
-      if (ipad > 0) 
+	else
 	{
-	  mask = BITMASK << ipad;
-	  *(VARBITS(result) + len - 1) &= mask;
+
+		/*
+		 * OK, we've got a true substring starting at position s1-1 and
+		 * ending at position e1-1
+		 */
+		rbitlen = e1 - s1;
+		len = VARBITDATALEN(rbitlen);
+		result = (bits8 *) palloc(len);
+		VARBITLEN(result) = rbitlen;
+		VARSIZE(result) = len;
+		len -= VARHDRSZ + VARBITHDRSZ;
+		/* Are we copying from a byte boundary? */
+		if ((s1 - 1) % BITSPERBYTE == 0)
+		{
+			/* Yep, we are copying bytes */
+			memcpy(VARBITS(result), VARBITS(arg) + (s1 - 1) / BITSPERBYTE, len);
+		}
+		else
+		{
+			/* Figure out how much we need to shift the sequence by */
+			ishift = (s1 - 1) % BITSPERBYTE;
+			r = VARBITS(result);
+			ps = VARBITS(arg) + (s1 - 1) / BITSPERBYTE;
+			for (i = 0; i < len; i++)
+			{
+				*r = (*ps << ishift) & BITMASK;
+				if ((++ps) < VARBITEND(arg))
+					*r |= *ps >> (BITSPERBYTE - ishift);
+				r++;
+			}
+		}
+		/* Do we need to pad at the end? */
+		ipad = VARBITPAD(result);
+		if (ipad > 0)
+		{
+			mask = BITMASK << ipad;
+			*(VARBITS(result) + len - 1) &= mask;
+		}
 	}
-    }
 
-  return result;
+	return result;
 }
 
 /* bitand
@@ -598,32 +656,32 @@ bitsubstr (bits8 *arg, int32 s, int32 l)
  * truncated to the shorter bit string
  */
 bits8 *
-bitand (bits8 * arg1, bits8 * arg2)
+bitand(bits8 *arg1, bits8 *arg2)
 {
-  int len,
-    i;
-  bits8 *result;
-  bits8 *p1, 
-    *p2, 
-    *r;
-
-  if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
-    return (bool) 0;
-
-  len = Min(VARSIZE(arg1),VARSIZE(arg2));
-  result = (bits8 *) palloc(len);
-  VARSIZE(result) = len;
-  VARBITLEN(result) = Min(VARBITLEN(arg1),VARBITLEN(arg2));
-
-  p1 = (bits8 *) VARBITS(arg1);
-  p2 = (bits8 *) VARBITS(arg2);
-  r = (bits8 *) VARBITS(result);
-  for (i=0; i<Min(VARBITBYTES(arg1),VARBITBYTES(arg2)); i++)
-    *r++ = *p1++ & *p2++;
-  
-  /* Padding is not needed as & of 0 pad is 0 */
-  
-  return result;
+	int			len,
+				i;
+	bits8	   *result;
+	bits8	   *p1,
+			   *p2,
+			   *r;
+
+	if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
+		return (bool) 0;
+
+	len = Min(VARSIZE(arg1), VARSIZE(arg2));
+	result = (bits8 *) palloc(len);
+	VARSIZE(result) = len;
+	VARBITLEN(result) = Min(VARBITLEN(arg1), VARBITLEN(arg2));
+
+	p1 = (bits8 *) VARBITS(arg1);
+	p2 = (bits8 *) VARBITS(arg2);
+	r = (bits8 *) VARBITS(result);
+	for (i = 0; i < Min(VARBITBYTES(arg1), VARBITBYTES(arg2)); i++)
+		*r++ = *p1++ & *p2++;
+
+	/* Padding is not needed as & of 0 pad is 0 */
+
+	return result;
 }
 
 /* bitor
@@ -631,35 +689,35 @@ bitand (bits8 * arg1, bits8 * arg2)
  * truncated to the shorter bit string.
  */
 bits8 *
-bitor (bits8 * arg1, bits8 * arg2)
+bitor(bits8 *arg1, bits8 *arg2)
 {
-  int len,
-    i;
-  bits8 *result;
-  bits8 *p1, 
-    *p2, 
-    *r;
-  bits8 mask;
-
-  if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
-    return (bool) 0;
-
-  len = Min(VARSIZE(arg1),VARSIZE(arg2));
-  result = (bits8 *) palloc(len);
-  VARSIZE(result) = len;
-  VARBITLEN(result) = Min(VARBITLEN(arg1),VARBITLEN(arg2));
-
-  p1 = (bits8 *) VARBITS(arg1);
-  p2 = (bits8 *) VARBITS(arg2);
-  r = (bits8 *) VARBITS(result);
-  for (i=0; i<Min(VARBITBYTES(arg1),VARBITBYTES(arg2)); i++)
-    *r++ = *p1++ | *p2++;
-
-  /* Pad the result */
-  mask = BITMASK << VARBITPAD(result);
-  *r &= mask;
-  
-  return result;
+	int			len,
+				i;
+	bits8	   *result;
+	bits8	   *p1,
+			   *p2,
+			   *r;
+	bits8		mask;
+
+	if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
+		return (bool) 0;
+
+	len = Min(VARSIZE(arg1), VARSIZE(arg2));
+	result = (bits8 *) palloc(len);
+	VARSIZE(result) = len;
+	VARBITLEN(result) = Min(VARBITLEN(arg1), VARBITLEN(arg2));
+
+	p1 = (bits8 *) VARBITS(arg1);
+	p2 = (bits8 *) VARBITS(arg2);
+	r = (bits8 *) VARBITS(result);
+	for (i = 0; i < Min(VARBITBYTES(arg1), VARBITBYTES(arg2)); i++)
+		*r++ = *p1++ | *p2++;
+
+	/* Pad the result */
+	mask = BITMASK << VARBITPAD(result);
+	*r &= mask;
+
+	return result;
 }
 
 /* bitxor
@@ -667,160 +725,167 @@ bitor (bits8 * arg1, bits8 * arg2)
  * truncated to the shorter bit string.
  */
 bits8 *
-bitxor (bits8 * arg1, bits8 * arg2)
+bitxor(bits8 *arg1, bits8 *arg2)
 {
-  int len,
-    i;
-  bits8 *result;
-  bits8 *p1, 
-    *p2, 
-    *r;
-  bits8 mask;
-
-  if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
-    return (bool) 0;
-
-  len = Min(VARSIZE(arg1),VARSIZE(arg2));
-  result = (bits8 *) palloc(len);
-  VARSIZE(result) = len;
-  VARBITLEN(result) = Min(VARBITLEN(arg1),VARBITLEN(arg2));
-
-  p1 = (bits8 *) VARBITS(arg1);
-  p2 = (bits8 *) VARBITS(arg2);
-  r = (bits8 *) VARBITS(result);
-  for (i=0; i<Min(VARBITBYTES(arg1),VARBITBYTES(arg2)); i++)
-    {
-      *r++ = *p1++ ^ *p2++;
-    }
-
-  /* Pad the result */
-  mask = BITMASK << VARBITPAD(result);
-  *r &= mask;
-  
-  return result;
+	int			len,
+				i;
+	bits8	   *result;
+	bits8	   *p1,
+			   *p2,
+			   *r;
+	bits8		mask;
+
+	if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
+		return (bool) 0;
+
+	len = Min(VARSIZE(arg1), VARSIZE(arg2));
+	result = (bits8 *) palloc(len);
+	VARSIZE(result) = len;
+	VARBITLEN(result) = Min(VARBITLEN(arg1), VARBITLEN(arg2));
+
+	p1 = (bits8 *) VARBITS(arg1);
+	p2 = (bits8 *) VARBITS(arg2);
+	r = (bits8 *) VARBITS(result);
+	for (i = 0; i < Min(VARBITBYTES(arg1), VARBITBYTES(arg2)); i++)
+		*r++ = *p1++ ^ *p2++;
+
+	/* Pad the result */
+	mask = BITMASK << VARBITPAD(result);
+	*r &= mask;
+
+	return result;
 }
 
 /* bitnot
  * perform a logical NOT on a bit strings.
  */
 bits8 *
-bitnot (bits8 * arg)
+bitnot(bits8 *arg)
 {
-  bits8 *result;
-  bits8 *p, 
-    *r;
-  bits8 mask;
-
-  if (!PointerIsValid(arg))
-    return (bool) 0;
-
-  result = (bits8 *) palloc(VARSIZE(arg));
-  VARSIZE(result) = VARSIZE(arg);
-  VARBITLEN(result) = VARBITLEN(arg);
-
-  p = (bits8 *) VARBITS(arg);
-  r = (bits8 *) VARBITS(result);
-  for ( ; p < VARBITEND(arg); p++, r++)
-    *r = ~*p;
-
-  /* Pad the result */
-  mask = BITMASK << VARBITPAD(result);
-  *r &= mask;
-  
-  return result;
+	bits8	   *result;
+	bits8	   *p,
+			   *r;
+	bits8		mask;
+
+	if (!PointerIsValid(arg))
+		return (bool) 0;
+
+	result = (bits8 *) palloc(VARSIZE(arg));
+	VARSIZE(result) = VARSIZE(arg);
+	VARBITLEN(result) = VARBITLEN(arg);
+
+	p = (bits8 *) VARBITS(arg);
+	r = (bits8 *) VARBITS(result);
+	for (; p < VARBITEND(arg); p++, r++)
+		*r = ~*p;
+
+	/* Pad the result */
+	mask = BITMASK << VARBITPAD(result);
+	*r &= mask;
+
+	return result;
 }
 
 /* bitshiftleft
  * do a left shift (i.e. to the beginning of the string) of the bit string
  */
 bits8 *
-bitshiftleft (bits8 * arg, int shft)
+bitshiftleft(bits8 *arg, int shft)
 {
-  int byte_shift, ishift, len;
-  bits8 *result;
-  bits8 *p, 
-    *r;
-
-  if (!PointerIsValid(arg))
-    return (bool) 0;
-
-  /* Negative shift is a shift to the right */
-  if (shft < 0) 
-    return bitshiftright(arg, -shft);
-
-  result = (bits8 *) palloc(VARSIZE(arg));
-  VARSIZE(result) = VARSIZE(arg);
-  VARBITLEN(result) = VARBITLEN(arg);
-  r = (bits8 *) VARBITS(result);
-
-  byte_shift = shft/BITSPERBYTE;
-  ishift = shft % BITSPERBYTE;
-  p = ((bits8 *) VARBITS(arg)) + byte_shift;
-  
-  if (ishift == 0) {
-    /* Special case: we can do a memcpy */
-    len = VARBITBYTES(arg) - byte_shift;
-    memcpy(r, p, len);
-    memset(r+len, 0, byte_shift);
-  } else {
-    for ( ; p < VARBITEND(arg); r++) {
-      *r = *p <<ishift;
-      if ((++p) < VARBITEND(arg))
-	*r |= *p >>(BITSPERBYTE-ishift);
-    }
-    for ( ; r < VARBITEND(result) ; r++ ) 
-      *r = (bits8) 0;
-  }
-
-  return result;
+	int			byte_shift,
+				ishift,
+				len;
+	bits8	   *result;
+	bits8	   *p,
+			   *r;
+
+	if (!PointerIsValid(arg))
+		return (bool) 0;
+
+	/* Negative shift is a shift to the right */
+	if (shft < 0)
+		return bitshiftright(arg, -shft);
+
+	result = (bits8 *) palloc(VARSIZE(arg));
+	VARSIZE(result) = VARSIZE(arg);
+	VARBITLEN(result) = VARBITLEN(arg);
+	r = (bits8 *) VARBITS(result);
+
+	byte_shift = shft / BITSPERBYTE;
+	ishift = shft % BITSPERBYTE;
+	p = ((bits8 *) VARBITS(arg)) + byte_shift;
+
+	if (ishift == 0)
+	{
+		/* Special case: we can do a memcpy */
+		len = VARBITBYTES(arg) - byte_shift;
+		memcpy(r, p, len);
+		memset(r + len, 0, byte_shift);
+	}
+	else
+	{
+		for (; p < VARBITEND(arg); r++)
+		{
+			*r = *p << ishift;
+			if ((++p) < VARBITEND(arg))
+				*r |= *p >> (BITSPERBYTE - ishift);
+		}
+		for (; r < VARBITEND(result); r++)
+			*r = (bits8) 0;
+	}
+
+	return result;
 }
 
 /* bitshiftright
  * do a right shift (i.e. to the beginning of the string) of the bit string
  */
 bits8 *
-bitshiftright (bits8 * arg, int shft)
+bitshiftright(bits8 *arg, int shft)
 {
-  int byte_shift, ishift, len;
-  bits8 *result;
-  bits8 *p, 
-    *r;
-
-  if (!PointerIsValid(arg))
-    return (bits8 *) 0;
-
-  /* Negative shift is a shift to the left */
-  if (shft < 0) 
-    return bitshiftleft(arg, -shft);
-
-  result = (bits8 *) palloc(VARSIZE(arg));
-  VARSIZE(result) = VARSIZE(arg);
-  VARBITLEN(result) = VARBITLEN(arg);
-  r = (bits8 *) VARBITS(result);
-
-  byte_shift = shft/BITSPERBYTE;
-  ishift = shft % BITSPERBYTE;
-  p = (bits8 *) VARBITS(arg);
-
-  /* Set the first part of the result to 0 */
-  memset(r, 0, byte_shift);
-  
-  if (ishift == 0) 
-    {
-      /* Special case: we can do a memcpy */
-      len = VARBITBYTES(arg) - byte_shift;
-      memcpy(r+byte_shift, p, len);
-    } 
-  else 
-    {
-      r += byte_shift;
-      *r = 0;    /* Initialise first byte */
-      for ( ; r < VARBITEND(result); p++) {
-	*r |= *p >> ishift;
-	if ((++r) < VARBITEND(result))
-	  *r = (*p <<(BITSPERBYTE-ishift)) & BITMASK;
-      }
-    }
-
-  return result;
+	int			byte_shift,
+				ishift,
+				len;
+	bits8	   *result;
+	bits8	   *p,
+			   *r;
+
+	if (!PointerIsValid(arg))
+		return (bits8 *) 0;
+
+	/* Negative shift is a shift to the left */
+	if (shft < 0)
+		return bitshiftleft(arg, -shft);
+
+	result = (bits8 *) palloc(VARSIZE(arg));
+	VARSIZE(result) = VARSIZE(arg);
+	VARBITLEN(result) = VARBITLEN(arg);
+	r = (bits8 *) VARBITS(result);
+
+	byte_shift = shft / BITSPERBYTE;
+	ishift = shft % BITSPERBYTE;
+	p = (bits8 *) VARBITS(arg);
+
+	/* Set the first part of the result to 0 */
+	memset(r, 0, byte_shift);
+
+	if (ishift == 0)
+	{
+		/* Special case: we can do a memcpy */
+		len = VARBITBYTES(arg) - byte_shift;
+		memcpy(r + byte_shift, p, len);
+	}
+	else
+	{
+		r += byte_shift;
+		*r = 0;					/* Initialise first byte */
+		for (; r < VARBITEND(result); p++)
+		{
+			*r |= *p >> ishift;
+			if ((++r) < VARBITEND(result))
+				*r = (*p << (BITSPERBYTE - ishift)) & BITMASK;
+		}
+	}
+
+	return result;
 }
diff --git a/contrib/bit/varbit.h b/contrib/bit/varbit.h
index 0b7e3308c482c20608d84cd17fbf170d7ab2a86c..ca7202b4c802dc64b414b54e142b9e79c2348b9a 100644
--- a/contrib/bit/varbit.h
+++ b/contrib/bit/varbit.h
@@ -2,7 +2,7 @@
 #include <ctype.h>
 #include <errno.h>
 
-#include <float.h>                              /* faked on sunos4 */
+#include <float.h>				/* faked on sunos4 */
 
 #include <math.h>
 
@@ -10,7 +10,7 @@
 #ifdef HAVE_LIMITS_H
 #include <limits.h>
 #ifndef MAXINT
-#define MAXINT            INT_MAX
+#define MAXINT			  INT_MAX
 #endif
 #else
 #ifdef HAVE_VALUES_H
@@ -22,7 +22,7 @@
 #include "utils/builtins.h"
 
 
-#define HEXDIG(z)    (z)<10 ? ((z)+'0') : ((z)-10+'A')
+#define HEXDIG(z)	 (z)<10 ? ((z)+'0') : ((z)-10+'A')
 
 /* Modeled on struct varlena from postgres.h, bu data type is bits8 */
 struct varbita
@@ -49,25 +49,25 @@ struct varbita
 #define VARBITEND(PTR)		((bits8 *) (PTR + VARSIZE(PTR)))
 /* Mask that will cover exactly one byte, i.e. BITSPERBYTE bits */
 #define BITMASK			0xFF
-#define BITHIGH                 0x80
+#define BITHIGH					0x80
 
 
-bits8 * zpbitin(char *s, int dummy,  int32 atttypmod);
-char * zpbitout(bits8 *s);
-char * zpbitsout(bits8 *s);
-bits8 * varbitin(char *s, int dummy,  int32 atttypmod);
-bool biteq (bits8 *arg1, bits8 *arg2);
-bool bitne (bits8 *arg1, bits8 *arg2);
-bool bitge (bits8 *arg1, bits8 *arg2);
-bool bitgt (bits8 *arg1, bits8 *arg2);
-bool bitle (bits8 *arg1, bits8 *arg2);
-bool bitlt (bits8 *arg1, bits8 *arg2);
-int bitcmp (bits8 *arg1, bits8 *arg2);
-bits8 * bitand (bits8 * arg1, bits8 * arg2);
-bits8 * bitor (bits8 * arg1, bits8 * arg2);
-bits8 * bitxor (bits8 * arg1, bits8 * arg2);
-bits8 * bitnot (bits8 * arg);
-bits8 * bitshiftright (bits8 * arg, int shft);
-bits8 * bitshiftleft (bits8 * arg, int shft);
-bits8 * bitcat (bits8 *arg1, bits8 *arg2);
-bits8 * bitsubstr (bits8 *arg, int32 s, int32 l);
+bits8	   *zpbitin(char *s, int dummy, int32 atttypmod);
+char	   *zpbitout(bits8 *s);
+char	   *zpbitsout(bits8 *s);
+bits8	   *varbitin(char *s, int dummy, int32 atttypmod);
+bool		biteq(bits8 *arg1, bits8 *arg2);
+bool		bitne(bits8 *arg1, bits8 *arg2);
+bool		bitge(bits8 *arg1, bits8 *arg2);
+bool		bitgt(bits8 *arg1, bits8 *arg2);
+bool		bitle(bits8 *arg1, bits8 *arg2);
+bool		bitlt(bits8 *arg1, bits8 *arg2);
+int			bitcmp(bits8 *arg1, bits8 *arg2);
+bits8	   *bitand(bits8 *arg1, bits8 *arg2);
+bits8	   *bitor(bits8 *arg1, bits8 *arg2);
+bits8	   *bitxor(bits8 *arg1, bits8 *arg2);
+bits8	   *bitnot(bits8 *arg);
+bits8	   *bitshiftright(bits8 *arg, int shft);
+bits8	   *bitshiftleft(bits8 *arg, int shft);
+bits8	   *bitcat(bits8 *arg1, bits8 *arg2);
+bits8	   *bitsubstr(bits8 *arg, int32 s, int32 l);
diff --git a/contrib/bit/varbit_glue.c b/contrib/bit/varbit_glue.c
index 29b7debd03cd45c9a813b92bb7dee1588174aef0..bd79a849a5095d4ba8a638a0a06893810b9e7d77 100644
--- a/contrib/bit/varbit_glue.c
+++ b/contrib/bit/varbit_glue.c
@@ -2,21 +2,23 @@
 
 #include "varbit.h"
 
-bits8 * varbit_in (char * s);
-char * varbit_out (bits8 *s);
+bits8	   *varbit_in(char *s);
+char	   *varbit_out(bits8 *s);
 
 bits8 *
-varbit_in (char * s) {
-  return varbitin (s, 0, -1);
+varbit_in(char *s)
+{
+	return varbitin(s, 0, -1);
 }
 
-/*char * 
+/*char *
 varbit_out (bits8 *s) {
   return zpbitout(s);
 }
 */
 
-char * 
-varbit_out (bits8 *s) {
-  return zpbitsout(s);
+char *
+varbit_out(bits8 *s)
+{
+	return zpbitsout(s);
 }
diff --git a/contrib/bit/vartest.c b/contrib/bit/vartest.c
index f07f5c5b8333654b89099b7fe961137efe53905d..7725f6bbd306f027ad8cfd1e8ac35dd00e13a6a1 100644
--- a/contrib/bit/vartest.c
+++ b/contrib/bit/vartest.c
@@ -2,173 +2,183 @@
 #include "varbit.h"
 #include <stdio.h>
 
-void print_details (unsigned char *s);
+void		print_details(unsigned char *s);
+
+const int	numb = 8;
 
-const int numb = 8;
 /*
 const char *b[] = { "B0010", "B11011011", "B0001", "X3F12", "X27", "B",
-                    "X11", "B100111"};
+					"X11", "B100111"};
 int atttypmod[] = {-1, -1, -1,-1,-1,-1,-1,-1 };
 */
-const char *b[] = { "B0010", "B11011011", "B10001", "X3D12", "X27", "B",
-                    "X11", "B100111"};
-int atttypmod[] = { 7, 9, 6, 18, 11, 6, -1, -1 };
+const char *b[] = {"B0010", "B11011011", "B10001", "X3D12", "X27", "B",
+"X11", "B100111"};
+int			atttypmod[] = {7, 9, 6, 18, 11, 6, -1, -1};
 
 
-void print_details (unsigned char *s) 
+void
+print_details(unsigned char *s)
 {
-  int i;
-  printf ("Length in bytes    : %d\n",VARSIZE(s));
-  printf ("Length of bitstring: %d\n",VARBITLEN(s));
-  for (i=8; i<VARSIZE(s); i++) 
-    printf ("%X%X ",s[i]>>4,s[i]&0xF);
-  printf("\n");
+	int			i;
+
+	printf("Length in bytes    : %d\n", VARSIZE(s));
+	printf("Length of bitstring: %d\n", VARBITLEN(s));
+	for (i = 8; i < VARSIZE(s); i++)
+		printf("%X%X ", s[i] >> 4, s[i] & 0xF);
+	printf("\n");
 }
 
 int
-main () 
+main()
 {
-  int i, j;
-  char *s[numb];
-
-  for (i=0; i<numb; i++) {
-    printf ("Input: %s\n",b[i]);
-    s[i] = zpbitin(b[i], 0, atttypmod[i]);
-    //print_details(s[i]);
-    printf ("%s = %s\n",zpbitout(s[i]),zpbitsout(s[i]));
-  }
-
-  printf ("\nCOMPARISONS:\n");
-  for (i=0; i<numb; i++)
-    for (j=i+1; j<numb; j++)
-      printf("%s <=> %s = %d\n",zpbitsout(s[i]),zpbitsout(s[j]),
-	     bitcmp(s[i],s[j]));
-
-  printf ("\nCONCATENATION:\n");
-  for (i=0; i<numb; i++)
-    for (j=i+1; j<numb; j++)
-      printf("%s || %s = %s\n",zpbitsout(s[i]),zpbitsout(s[j]),
-	     zpbitsout(bitcat(s[i],s[j])));
-
-  printf("\nSUBSTR:\n");
-  printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),1,8,
-	 zpbitsout(bitsubstr(s[3],1,8)));
-  printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),9,8,
-	 zpbitsout(bitsubstr(s[3],9,8)));
-  printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),1,9,
-	 zpbitsout(bitsubstr(s[3],1,9)));
-  printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),3,5,
-	 zpbitsout(bitsubstr(s[3],3,5)));
-  printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),3,9,
-	 zpbitsout(bitsubstr(s[3],3,9)));
-  printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),3,17,
-	 zpbitsout(bitsubstr(s[3],3,17)));
-  printf ("\nLOGICAL AND:\n");
-  for (i=0; i<numb; i++)
-    for (j=i+1; j<numb; j++)
-      printf("%s & %s = %s\n",zpbitsout(s[i]),zpbitsout(s[j]),
-	     zpbitsout(bitand(s[i],s[j])));
-
-  printf ("\nLOGICAL OR:\n");
-  for (i=0; i<numb; i++)
-    for (j=i+1; j<numb; j++)
-      printf("%s | %s = %s\n",zpbitsout(s[i]),zpbitsout(s[j]),
-	     zpbitsout(bitor(s[i],s[j])));
-
-  printf ("\nLOGICAL XOR:\n");
-  for (i=0; i<numb; i++)
-    for (j=i+1; j<numb; j++)
-      printf("%s ^ %s = %s\n",zpbitsout(s[i]),zpbitsout(s[j]),
-	     zpbitsout(bitxor(s[i],s[j])));
-  
-  printf ("\nLOGICAL NOT:\n");
-  for (i=0; i<numb; i++)
-    printf("~%s = %s\n",zpbitsout(s[i]),zpbitsout(bitnot(s[i])));
-
-
-  printf ("\nSHIFT LEFT:\n");
-  for (i=0; i<numb; i++) {
-    printf("%s\n",zpbitsout(s[i]));
-    for (j=0; j<=VARBITLEN(s[i]); j++)
-      printf("\t%3d\t%s\n",j,zpbitsout(bitshiftleft(s[i],j)));
-  }
-
-  printf ("\nSHIFT RIGHT:\n");
-  for (i=0; i<numb; i++) {
-    printf("%s\n",zpbitsout(s[i]));
-    for (j=0; j<=VARBITLEN(s[i]); j++)
-      printf("\t%3d\t%s\n",j,zpbitsout(bitshiftright(s[i],j)));
-  }
-
-  printf ("\n\n ********** VARYING **********\n");
-  for (i=0; i<numb; i++) {
-    printf ("Input: %s\n",b[i]);
-    s[i] = varbitin(b[i], 0, atttypmod[i]);
-    /*print_details(s);*/
-    printf ("%s\n",zpbitout(s[i]));
-    printf ("%s\n",zpbitsout(s[i]));
-  }
-
-  printf ("\nCOMPARISONS:\n");
-  for (i=0; i<numb; i++)
-    for (j=i+1; j<numb; j++)
-      printf("%s <=> %s = %d\n",zpbitsout(s[i]),zpbitsout(s[j]),
-	     bitcmp(s[i],s[j]));
-
-  printf ("\nCONCATENATION:\n");
-  for (i=0; i<numb; i++)
-    for (j=i+1; j<numb; j++)
-      printf("%s || %s = %s\n",zpbitsout(s[i]),zpbitsout(s[j]),
-	     zpbitsout(bitcat(s[i],s[j])));
-
-  printf("\nSUBSTR:\n");
-  printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),1,8,
-	 zpbitsout(bitsubstr(s[3],1,8)));
-  printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),9,8,
-	 zpbitsout(bitsubstr(s[3],9,8)));
-  printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),1,9,
-	 zpbitsout(bitsubstr(s[3],1,9)));
-  printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),3,5,
-	 zpbitsout(bitsubstr(s[3],3,5)));
-  printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),3,9,
-	 zpbitsout(bitsubstr(s[3],3,9)));
-  printf("%s (%d,%d) => %s (%s)\n",zpbitsout(s[3]),3,17,
-	 zpbitsout(bitsubstr(s[3],3,17)),zpbitsout(bitsubstr(s[3],3,17)));
-  printf ("\nLOGICAL AND:\n");
-  for (i=0; i<numb; i++)
-    for (j=i+1; j<numb; j++)
-      printf("%s & %s = %s\n",zpbitsout(s[i]),zpbitsout(s[j]),
-	     zpbitsout(bitand(s[i],s[j])));
-
-  printf ("\nLOGICAL OR:\n");
-  for (i=0; i<numb; i++)
-    for (j=i+1; j<numb; j++)
-      printf("%s | %s = %s\n",zpbitsout(s[i]),zpbitsout(s[j]),
-	     zpbitsout(bitor(s[i],s[j])));
-
-  printf ("\nLOGICAL XOR:\n");
-  for (i=0; i<numb; i++)
-    for (j=i+1; j<numb; j++)
-      printf("%s ^ %s = %s\n",zpbitsout(s[i]),zpbitsout(s[j]),
-	     zpbitsout(bitxor(s[i],s[j])));
-  
-  printf ("\nLOGICAL NOT:\n");
-  for (i=0; i<numb; i++)
-    printf("~%s = %s\n",zpbitsout(s[i]),zpbitsout(bitnot(s[i])));
-
-
-  printf ("\nSHIFT LEFT:\n");
-  for (i=0; i<numb; i++) {
-    printf("%s\n",zpbitsout(s[i]));
-    for (j=0; j<=VARBITLEN(s[i]); j++)
-      printf("\t%3d\t%s\n",j,zpbitsout(bitshiftleft(s[i],j)));
-  }
-
-  printf ("\nSHIFT RIGHT:\n");
-  for (i=0; i<numb; i++) {
-    printf("%s\n",zpbitsout(s[i]));
-    for (j=0; j<=VARBITLEN(s[i]); j++)
-      printf("\t%3d\t%s\n",j,zpbitsout(bitshiftright(s[i],j)));
-  }
+	int			i,
+				j;
+	char	   *s[numb];
+
+	for (i = 0; i < numb; i++)
+	{
+		printf("Input: %s\n", b[i]);
+		s[i] = zpbitin(b[i], 0, atttypmod[i]);
+		//print_details(s[i]);
+		printf("%s = %s\n", zpbitout(s[i]), zpbitsout(s[i]));
+	}
+
+	printf("\nCOMPARISONS:\n");
+	for (i = 0; i < numb; i++)
+		for (j = i + 1; j < numb; j++)
+			printf("%s <=> %s = %d\n", zpbitsout(s[i]), zpbitsout(s[j]),
+				   bitcmp(s[i], s[j]));
+
+	printf("\nCONCATENATION:\n");
+	for (i = 0; i < numb; i++)
+		for (j = i + 1; j < numb; j++)
+			printf("%s || %s = %s\n", zpbitsout(s[i]), zpbitsout(s[j]),
+				   zpbitsout(bitcat(s[i], s[j])));
+
+	printf("\nSUBSTR:\n");
+	printf("%s (%d,%d) => %s\n", zpbitsout(s[3]), 1, 8,
+		   zpbitsout(bitsubstr(s[3], 1, 8)));
+	printf("%s (%d,%d) => %s\n", zpbitsout(s[3]), 9, 8,
+		   zpbitsout(bitsubstr(s[3], 9, 8)));
+	printf("%s (%d,%d) => %s\n", zpbitsout(s[3]), 1, 9,
+		   zpbitsout(bitsubstr(s[3], 1, 9)));
+	printf("%s (%d,%d) => %s\n", zpbitsout(s[3]), 3, 5,
+		   zpbitsout(bitsubstr(s[3], 3, 5)));
+	printf("%s (%d,%d) => %s\n", zpbitsout(s[3]), 3, 9,
+		   zpbitsout(bitsubstr(s[3], 3, 9)));
+	printf("%s (%d,%d) => %s\n", zpbitsout(s[3]), 3, 17,
+		   zpbitsout(bitsubstr(s[3], 3, 17)));
+	printf("\nLOGICAL AND:\n");
+	for (i = 0; i < numb; i++)
+		for (j = i + 1; j < numb; j++)
+			printf("%s & %s = %s\n", zpbitsout(s[i]), zpbitsout(s[j]),
+				   zpbitsout(bitand(s[i], s[j])));
+
+	printf("\nLOGICAL OR:\n");
+	for (i = 0; i < numb; i++)
+		for (j = i + 1; j < numb; j++)
+			printf("%s | %s = %s\n", zpbitsout(s[i]), zpbitsout(s[j]),
+				   zpbitsout(bitor(s[i], s[j])));
+
+	printf("\nLOGICAL XOR:\n");
+	for (i = 0; i < numb; i++)
+		for (j = i + 1; j < numb; j++)
+			printf("%s ^ %s = %s\n", zpbitsout(s[i]), zpbitsout(s[j]),
+				   zpbitsout(bitxor(s[i], s[j])));
+
+	printf("\nLOGICAL NOT:\n");
+	for (i = 0; i < numb; i++)
+		printf("~%s = %s\n", zpbitsout(s[i]), zpbitsout(bitnot(s[i])));
+
+
+	printf("\nSHIFT LEFT:\n");
+	for (i = 0; i < numb; i++)
+	{
+		printf("%s\n", zpbitsout(s[i]));
+		for (j = 0; j <= VARBITLEN(s[i]); j++)
+			printf("\t%3d\t%s\n", j, zpbitsout(bitshiftleft(s[i], j)));
+	}
+
+	printf("\nSHIFT RIGHT:\n");
+	for (i = 0; i < numb; i++)
+	{
+		printf("%s\n", zpbitsout(s[i]));
+		for (j = 0; j <= VARBITLEN(s[i]); j++)
+			printf("\t%3d\t%s\n", j, zpbitsout(bitshiftright(s[i], j)));
+	}
+
+	printf("\n\n ********** VARYING **********\n");
+	for (i = 0; i < numb; i++)
+	{
+		printf("Input: %s\n", b[i]);
+		s[i] = varbitin(b[i], 0, atttypmod[i]);
+		/* print_details(s); */
+		printf("%s\n", zpbitout(s[i]));
+		printf("%s\n", zpbitsout(s[i]));
+	}
+
+	printf("\nCOMPARISONS:\n");
+	for (i = 0; i < numb; i++)
+		for (j = i + 1; j < numb; j++)
+			printf("%s <=> %s = %d\n", zpbitsout(s[i]), zpbitsout(s[j]),
+				   bitcmp(s[i], s[j]));
+
+	printf("\nCONCATENATION:\n");
+	for (i = 0; i < numb; i++)
+		for (j = i + 1; j < numb; j++)
+			printf("%s || %s = %s\n", zpbitsout(s[i]), zpbitsout(s[j]),
+				   zpbitsout(bitcat(s[i], s[j])));
+
+	printf("\nSUBSTR:\n");
+	printf("%s (%d,%d) => %s\n", zpbitsout(s[3]), 1, 8,
+		   zpbitsout(bitsubstr(s[3], 1, 8)));
+	printf("%s (%d,%d) => %s\n", zpbitsout(s[3]), 9, 8,
+		   zpbitsout(bitsubstr(s[3], 9, 8)));
+	printf("%s (%d,%d) => %s\n", zpbitsout(s[3]), 1, 9,
+		   zpbitsout(bitsubstr(s[3], 1, 9)));
+	printf("%s (%d,%d) => %s\n", zpbitsout(s[3]), 3, 5,
+		   zpbitsout(bitsubstr(s[3], 3, 5)));
+	printf("%s (%d,%d) => %s\n", zpbitsout(s[3]), 3, 9,
+		   zpbitsout(bitsubstr(s[3], 3, 9)));
+	printf("%s (%d,%d) => %s (%s)\n", zpbitsout(s[3]), 3, 17,
+	zpbitsout(bitsubstr(s[3], 3, 17)), zpbitsout(bitsubstr(s[3], 3, 17)));
+	printf("\nLOGICAL AND:\n");
+	for (i = 0; i < numb; i++)
+		for (j = i + 1; j < numb; j++)
+			printf("%s & %s = %s\n", zpbitsout(s[i]), zpbitsout(s[j]),
+				   zpbitsout(bitand(s[i], s[j])));
+
+	printf("\nLOGICAL OR:\n");
+	for (i = 0; i < numb; i++)
+		for (j = i + 1; j < numb; j++)
+			printf("%s | %s = %s\n", zpbitsout(s[i]), zpbitsout(s[j]),
+				   zpbitsout(bitor(s[i], s[j])));
+
+	printf("\nLOGICAL XOR:\n");
+	for (i = 0; i < numb; i++)
+		for (j = i + 1; j < numb; j++)
+			printf("%s ^ %s = %s\n", zpbitsout(s[i]), zpbitsout(s[j]),
+				   zpbitsout(bitxor(s[i], s[j])));
+
+	printf("\nLOGICAL NOT:\n");
+	for (i = 0; i < numb; i++)
+		printf("~%s = %s\n", zpbitsout(s[i]), zpbitsout(bitnot(s[i])));
+
+
+	printf("\nSHIFT LEFT:\n");
+	for (i = 0; i < numb; i++)
+	{
+		printf("%s\n", zpbitsout(s[i]));
+		for (j = 0; j <= VARBITLEN(s[i]); j++)
+			printf("\t%3d\t%s\n", j, zpbitsout(bitshiftleft(s[i], j)));
+	}
+
+	printf("\nSHIFT RIGHT:\n");
+	for (i = 0; i < numb; i++)
+	{
+		printf("%s\n", zpbitsout(s[i]));
+		for (j = 0; j <= VARBITLEN(s[i]); j++)
+			printf("\t%3d\t%s\n", j, zpbitsout(bitshiftright(s[i], j)));
+	}
 
 }
diff --git a/contrib/datetime/datetime_functions.c b/contrib/datetime/datetime_functions.c
index c5b8bc25e9d2789611846cb849850b2e1b81270b..47991a8646d9a5c94e642585482ba9871f00bf6c 100644
--- a/contrib/datetime/datetime_functions.c
+++ b/contrib/datetime/datetime_functions.c
@@ -36,7 +36,7 @@
  * Decode time string 00:00:00 through 24:00:00.
  */
 static int
-decode_24h_time(char *str, struct tm *tm, double *fsec)
+decode_24h_time(char *str, struct tm * tm, double *fsec)
 {
 	char	   *cp;
 
@@ -51,9 +51,7 @@ decode_24h_time(char *str, struct tm *tm, double *fsec)
 		*fsec = 0;
 	}
 	else if (*cp != ':')
-	{
 		return -1;
-	}
 	else
 	{
 		str = cp + 1;
@@ -72,10 +70,10 @@ decode_24h_time(char *str, struct tm *tm, double *fsec)
 	}
 
 	/* do a sanity check */
-	if (   (tm->tm_hour < 0) || (tm->tm_hour > 24)
-		|| (tm->tm_min  < 0) || (tm->tm_min  > 59)
-		|| (tm->tm_sec  < 0) || (tm->tm_sec  > 59)
-		|| (*fsec       < 0) )
+	if ((tm->tm_hour < 0) || (tm->tm_hour > 24)
+		|| (tm->tm_min < 0) || (tm->tm_min > 59)
+		|| (tm->tm_sec < 0) || (tm->tm_sec > 59)
+		|| (*fsec < 0))
 		return -1;
 
 	return 0;
@@ -265,7 +263,7 @@ currentdate()
 int4
 date2mjd(DateADT val)
 {
-	int result;
+	int			result;
 
 	result = val + JDATE_2000 - 2400000.5;
 
@@ -276,8 +274,8 @@ date2mjd(DateADT val)
 
 /*
  * Local Variables:
- *  tab-width: 4
- *  c-indent-level: 4
- *  c-basic-offset: 4
+ *	tab-width: 4
+ *	c-indent-level: 4
+ *	c-basic-offset: 4
  * End:
  */
diff --git a/contrib/datetime/datetime_functions.h b/contrib/datetime/datetime_functions.h
index ff2309d16f0543f4e080c282547ce427b492d8e1..c345f2852b8a16d1ac5d4bfb846e750d138e254b 100644
--- a/contrib/datetime/datetime_functions.h
+++ b/contrib/datetime/datetime_functions.h
@@ -20,8 +20,8 @@ DateADT		currentdate(void);
 
 /*
  * Local Variables:
- *  tab-width: 4
- *  c-indent-level: 4
- *  c-basic-offset: 4
+ *	tab-width: 4
+ *	c-indent-level: 4
+ *	c-basic-offset: 4
  * End:
  */
diff --git a/contrib/miscutil/misc_utils.c b/contrib/miscutil/misc_utils.c
index 6745b5b8bb9a9e049c19e181b875f64e45fae7ab..302118689dc1b9a713c2192eb64823261ff9850f 100644
--- a/contrib/miscutil/misc_utils.c
+++ b/contrib/miscutil/misc_utils.c
@@ -38,6 +38,7 @@ extern int	assertTest(int val);
 
 #ifdef ASSERT_CHECKING_TEST
 extern int	assertEnable(int val);
+
 #endif
 
 int
@@ -84,7 +85,8 @@ active_listeners(text *relname)
 	ScanKeyData key;
 	Datum		d;
 	bool		isnull;
-	int			len, pid;
+	int			len,
+				pid;
 	int			count = 0;
 	int			ourpid = getpid();
 	char		listen_name[NAMEDATALEN];
@@ -92,8 +94,9 @@ active_listeners(text *relname)
 	lRel = heap_openr(ListenerRelationName, AccessShareLock);
 	tdesc = RelationGetDescr(lRel);
 
-	if (relname && (VARSIZE(relname) > VARHDRSZ)) {
-		len = MIN(VARSIZE(relname)-VARHDRSZ, NAMEDATALEN-1);
+	if (relname && (VARSIZE(relname) > VARHDRSZ))
+	{
+		len = MIN(VARSIZE(relname) - VARHDRSZ, NAMEDATALEN - 1);
 		strncpy(listen_name, VARDATA(relname), len);
 		listen_name[len] = '\0';
 		ScanKeyEntryInitialize(&key, 0,
@@ -101,15 +104,16 @@ active_listeners(text *relname)
 							   F_NAMEEQ,
 							   PointerGetDatum(listen_name));
 		sRel = heap_beginscan(lRel, 0, SnapshotNow, 1, &key);
-	} else {
-		sRel = heap_beginscan(lRel, 0, SnapshotNow, 0, (ScanKey)NULL);
 	}
+	else
+		sRel = heap_beginscan(lRel, 0, SnapshotNow, 0, (ScanKey) NULL);
 
 	while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0)))
 	{
 		d = heap_getattr(lTuple, Anum_pg_listener_pid, tdesc, &isnull);
 		pid = DatumGetInt32(d);
-		if ((pid == ourpid) || (kill(pid, SIGTSTP) == 0)) {
+		if ((pid == ourpid) || (kill(pid, SIGTSTP) == 0))
+		{
 			/* elog(NOTICE, "%d ok", pid); */
 			count++;
 		}
@@ -134,6 +138,7 @@ assert_test(int val)
 {
 	return assertTest(val);
 }
+
 #endif
 #endif
 
@@ -141,8 +146,8 @@ assert_test(int val)
 
 /*
  * Local Variables:
- *  tab-width: 4
- *  c-indent-level: 4
- *  c-basic-offset: 4
+ *	tab-width: 4
+ *	c-indent-level: 4
+ *	c-basic-offset: 4
  * End:
  */
diff --git a/contrib/miscutil/misc_utils.h b/contrib/miscutil/misc_utils.h
index 139df3bc775cadc75e3a75cac7e2a812c601cd58..080f1147a887753f5fb2ab51667b213b086ccf53 100644
--- a/contrib/miscutil/misc_utils.h
+++ b/contrib/miscutil/misc_utils.h
@@ -10,8 +10,10 @@ int			active_listeners(text *relname);
 
 #ifdef USE_ASSERT_CHECKING
 int			assert_enable(int val);
+
 #ifdef ASSERT_CHECKING_TEST
 int			assert_test(int val);
+
 #endif
 #endif
 
@@ -19,8 +21,8 @@ int			assert_test(int val);
 
 /*
  * Local Variables:
- *  tab-width: 4
- *  c-indent-level: 4
- *  c-basic-offset: 4
+ *	tab-width: 4
+ *	c-indent-level: 4
+ *	c-basic-offset: 4
  * End:
  */
diff --git a/contrib/os2client/config.h b/contrib/os2client/config.h
index afdcb4484c8d557359556ef1e9dfdbf64e4edfb4..7a98eb60a9c399472aad6ef52124144ef76899a1 100644
--- a/contrib/os2client/config.h
+++ b/contrib/os2client/config.h
@@ -11,7 +11,7 @@
  * DEF_PGPORT is the TCP port number on which the Postmaster listens by
  * default.  This can be overriden by command options, environment variables,
  * and the postconfig hook. (set by build script)
-	*/
+	  */
 
 #define DEF_PGPORT "5432"
 
diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c
index ab5f0907167f727e87a6637dfe0120c12c56bad1..c2b027c9eccbd7f0b788ec173aaa7a85b8a7cc5e 100644
--- a/contrib/pgbench/pgbench.c
+++ b/contrib/pgbench/pgbench.c
@@ -1,5 +1,5 @@
 /*
- * $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.2 2000/04/08 18:32:24 tgl Exp $
+ * $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.3 2000/04/12 17:14:27 momjian Exp $
  *
  * pgbench: a simple TPC-B like benchmark program for PostgreSQL
  * written by Tatsuo Ishii
@@ -50,16 +50,17 @@
 /********************************************************************
  * some configurable parameters */
 
-#define MAXCLIENTS 1024	/* max number of clients allowed */
+#define MAXCLIENTS 1024			/* max number of clients allowed */
 
-int nclients = 1;	/* default number of simulated clients */
-int nxacts = 10;	/* default number of transactions per clients */
+int			nclients = 1;		/* default number of simulated clients */
+int			nxacts = 10;		/* default number of transactions per
+								 * clients */
 
 /*
  * scaling factor. for example, tps = 10 will make 1000000 tuples of
  * accounts table.
  */
-int tps = 1;
+int			tps = 1;
 
 /*
  * end of configurable parameters
@@ -67,671 +68,753 @@ int tps = 1;
 
 #define nbranches	1
 #define ntellers	10
-#define	naccounts	100000
-
-int remains;		/* number of remained clients */
-
-typedef struct {
-  PGconn	*con;	/* connection handle to DB */
-  int	state;	/* state No. */
-  int	cnt;	/* xacts count */
-  int	ecnt;	/* error count */
-  int	listen;	/* none 0 indicates that an async query has been sent */
-  int	aid;	/* account id for this transaction */
-  int	bid;	/* branch id for this transaction */
-  int	tid;	/* teller id for this transaction */
-  int	delta;
-  int	abalance;
-} CState;
-
-static void usage() {
-  fprintf(stderr,"usage: pgbench [-h hostname][-p port][-c nclients][-t ntransactions][-s scaling_factor][-n][-v][-S][-d][dbname]\n");
-  fprintf(stderr,"(initialize mode): pgbench -i [-h hostname][-p port][-s scaling_factor][-d][dbname]\n");
+#define naccounts	100000
+
+int			remains;			/* number of remained clients */
+
+typedef struct
+{
+	PGconn	   *con;			/* connection handle to DB */
+	int			state;			/* state No. */
+	int			cnt;			/* xacts count */
+	int			ecnt;			/* error count */
+	int			listen;			/* none 0 indicates that an async query
+								 * has been sent */
+	int			aid;			/* account id for this transaction */
+	int			bid;			/* branch id for this transaction */
+	int			tid;			/* teller id for this transaction */
+	int			delta;
+	int			abalance;
+}			CState;
+
+static void
+usage()
+{
+	fprintf(stderr, "usage: pgbench [-h hostname][-p port][-c nclients][-t ntransactions][-s scaling_factor][-n][-v][-S][-d][dbname]\n");
+	fprintf(stderr, "(initialize mode): pgbench -i [-h hostname][-p port][-s scaling_factor][-d][dbname]\n");
 }
 
 /* random number generator */
-static int getrand(int min, int max) {
-  return(min+(int)(max*1.0*rand()/(RAND_MAX+1.0)));
+static int
+getrand(int min, int max)
+{
+	return (min + (int) (max * 1.0 * rand() / (RAND_MAX + 1.0)));
 }
 
 /* throw away response from backend */
-static void discard_response(CState *state) {
-  PGresult *res;
-  do {
-    res = PQgetResult(state->con);
-    if (res)
-      PQclear(res);
-  } while(res);
+static void
+discard_response(CState * state)
+{
+	PGresult   *res;
+
+	do
+	{
+		res = PQgetResult(state->con);
+		if (res)
+			PQclear(res);
+	} while (res);
 }
 
-static int check(CState *state, PGresult *res, int n, int good)
+static int
+check(CState * state, PGresult *res, int n, int good)
 {
-  CState *st = &state[n];
-
-  if (res && PQresultStatus(res) != good) {
-    fprintf(stderr,"Client %d aborted in state %d: %s",n,st->state,PQerrorMessage(st->con));
-    remains--;	/* I've aborted */
-    PQfinish(st->con);
-    st->con = NULL;
-    return(-1);
-  }
-  return(0);
+	CState	   *st = &state[n];
+
+	if (res && PQresultStatus(res) != good)
+	{
+		fprintf(stderr, "Client %d aborted in state %d: %s", n, st->state, PQerrorMessage(st->con));
+		remains--;				/* I've aborted */
+		PQfinish(st->con);
+		st->con = NULL;
+		return (-1);
+	}
+	return (0);
 }
 
 /* process a transaction */
-static void doOne(CState *state, int n, int debug) {
-  char sql[256];
-  PGresult   *res;
-  CState *st = &state[n];
-
-  if (st->listen) {	/* are we receiver? */
-    if (debug) {
-      fprintf(stderr,"client %d receiving\n",n);
-    }
-    while (PQisBusy(st->con) == TRUE) {
-      if (!PQconsumeInput(st->con)) {	/* there's something wrong */
-	fprintf(stderr, "Client %d aborted in state %d. Probably the backend died while processing.\n",n, st->state);
-	remains--;	/* I've aborted */
-	PQfinish(st->con);
-	st->con = NULL;
-	return;
-      }
-    }
-
-    switch (st->state) {
-    case 0:	/* response to "begin" */
-      res = PQgetResult(st->con);
-      if (check(state, res, n, PGRES_COMMAND_OK)) {
-	return;
-      }
-      PQclear(res);
-      discard_response(st);
-      break;
-    case 1:	/* response to "update accounts..." */
-      res = PQgetResult(st->con);
-      if (check(state, res, n, PGRES_COMMAND_OK)) {
-	return;
-      }
-      PQclear(res);
-      discard_response(st);
-      break;
-    case 2:	/* response to "select abalance ..." */
-      res = PQgetResult(st->con);
-      if (check(state, res, n, PGRES_TUPLES_OK)) {
-	return;
-      }
-      PQclear(res);
-      discard_response(st);
-      break;
-    case 3:	/* response to "update tellers ..." */
-      res = PQgetResult(st->con);
-      if (check(state, res, n, PGRES_COMMAND_OK)) {
-	return;
-      }
-      PQclear(res);
-      discard_response(st);
-      break;
-    case 4:	/* response to "update branches ..." */
-      res = PQgetResult(st->con);
-      if (check(state, res, n, PGRES_COMMAND_OK)) {
-	return;
-      }
-      PQclear(res);
-      discard_response(st);
-      break;
-    case 5:	/* response to "insert into history ..." */
-      res = PQgetResult(st->con);
-      if (check(state, res, n, PGRES_COMMAND_OK)) {
-	return;
-      }
-      PQclear(res);
-      discard_response(st);
-      break;
-    case 6:	/* response to "end" */
-      res = PQgetResult(st->con);
-      if (check(state, res, n, PGRES_COMMAND_OK)) {
-	return;
-      }
-      PQclear(res);
-      discard_response(st);
-
-      if (++st->cnt >= nxacts) {
-	remains--;	/* I've done */
-	PQfinish(st->con);
-	st->con = NULL;
-	return;
-      }
-      break;
-    }
-
-    /* increment state counter */
-    st->state++;
-    if (st->state > 6) {
-      st->state = 0;
-    }
-  }
-
-  switch (st->state) {
-  case 0:	/* about to start */
-    strcpy(sql,"begin");
-    st->aid = getrand(1,naccounts*tps);
-    st->bid = getrand(1,nbranches*tps);
-    st->tid = getrand(1,ntellers*tps);
-    st->delta = getrand(1,1000);
-    break;
-  case 1:
-    sprintf(sql,"update accounts set abalance = abalance + %d where aid = %d\n",st->delta,st->aid);
-      break;
-  case 2:
-    sprintf(sql,"select abalance from accounts where aid = %d",st->aid);
-    break;
-  case 3:
-    sprintf(sql,"update tellers set tbalance = tbalance + %d where tid = %d\n",
-	    st->delta,st->tid);
-    break;
-  case 4:
-    sprintf(sql,"update branches set bbalance = bbalance + %d where bid = %d",st->delta,st->bid);
-    break;
-  case 5:
-    sprintf(sql,"insert into history(tid,bid,aid,delta,time) values(%d,%d,%d,%d,'now')",
-	    st->tid,st->bid,st->aid,st->delta);
-    break;
-  case 6:
-    strcpy(sql,"end");
-    break;
-  }
-
-  if (debug) {
-    fprintf(stderr,"client %d sending %s\n",n,sql);
-  }
-  if (PQsendQuery(st->con, sql) == 0) {
-    if (debug) {
-      fprintf(stderr, "PQsendQuery(%s)failed\n",sql);
-    }
-    st->ecnt++;
-  } else {
-    st->listen++;	/* flags that should be listned */
-  }
+static void
+doOne(CState * state, int n, int debug)
+{
+	char		sql[256];
+	PGresult   *res;
+	CState	   *st = &state[n];
+
+	if (st->listen)
+	{							/* are we receiver? */
+		if (debug)
+			fprintf(stderr, "client %d receiving\n", n);
+		while (PQisBusy(st->con) == TRUE)
+		{
+			if (!PQconsumeInput(st->con))
+			{					/* there's something wrong */
+				fprintf(stderr, "Client %d aborted in state %d. Probably the backend died while processing.\n", n, st->state);
+				remains--;		/* I've aborted */
+				PQfinish(st->con);
+				st->con = NULL;
+				return;
+			}
+		}
+
+		switch (st->state)
+		{
+			case 0:				/* response to "begin" */
+				res = PQgetResult(st->con);
+				if (check(state, res, n, PGRES_COMMAND_OK))
+					return;
+				PQclear(res);
+				discard_response(st);
+				break;
+			case 1:				/* response to "update accounts..." */
+				res = PQgetResult(st->con);
+				if (check(state, res, n, PGRES_COMMAND_OK))
+					return;
+				PQclear(res);
+				discard_response(st);
+				break;
+			case 2:				/* response to "select abalance ..." */
+				res = PQgetResult(st->con);
+				if (check(state, res, n, PGRES_TUPLES_OK))
+					return;
+				PQclear(res);
+				discard_response(st);
+				break;
+			case 3:				/* response to "update tellers ..." */
+				res = PQgetResult(st->con);
+				if (check(state, res, n, PGRES_COMMAND_OK))
+					return;
+				PQclear(res);
+				discard_response(st);
+				break;
+			case 4:				/* response to "update branches ..." */
+				res = PQgetResult(st->con);
+				if (check(state, res, n, PGRES_COMMAND_OK))
+					return;
+				PQclear(res);
+				discard_response(st);
+				break;
+			case 5:				/* response to "insert into history ..." */
+				res = PQgetResult(st->con);
+				if (check(state, res, n, PGRES_COMMAND_OK))
+					return;
+				PQclear(res);
+				discard_response(st);
+				break;
+			case 6:				/* response to "end" */
+				res = PQgetResult(st->con);
+				if (check(state, res, n, PGRES_COMMAND_OK))
+					return;
+				PQclear(res);
+				discard_response(st);
+
+				if (++st->cnt >= nxacts)
+				{
+					remains--;	/* I've done */
+					PQfinish(st->con);
+					st->con = NULL;
+					return;
+				}
+				break;
+		}
+
+		/* increment state counter */
+		st->state++;
+		if (st->state > 6)
+			st->state = 0;
+	}
+
+	switch (st->state)
+	{
+		case 0:			/* about to start */
+			strcpy(sql, "begin");
+			st->aid = getrand(1, naccounts * tps);
+			st->bid = getrand(1, nbranches * tps);
+			st->tid = getrand(1, ntellers * tps);
+			st->delta = getrand(1, 1000);
+			break;
+		case 1:
+			sprintf(sql, "update accounts set abalance = abalance + %d where aid = %d\n", st->delta, st->aid);
+			break;
+		case 2:
+			sprintf(sql, "select abalance from accounts where aid = %d", st->aid);
+			break;
+		case 3:
+			sprintf(sql, "update tellers set tbalance = tbalance + %d where tid = %d\n",
+					st->delta, st->tid);
+			break;
+		case 4:
+			sprintf(sql, "update branches set bbalance = bbalance + %d where bid = %d", st->delta, st->bid);
+			break;
+		case 5:
+			sprintf(sql, "insert into history(tid,bid,aid,delta,time) values(%d,%d,%d,%d,'now')",
+					st->tid, st->bid, st->aid, st->delta);
+			break;
+		case 6:
+			strcpy(sql, "end");
+			break;
+	}
+
+	if (debug)
+		fprintf(stderr, "client %d sending %s\n", n, sql);
+	if (PQsendQuery(st->con, sql) == 0)
+	{
+		if (debug)
+			fprintf(stderr, "PQsendQuery(%s)failed\n", sql);
+		st->ecnt++;
+	}
+	else
+	{
+		st->listen++;			/* flags that should be listned */
+	}
 }
 
 /* process a select only transaction */
-static void doSelectOnly(CState *state, int n, int debug) {
-  char sql[256];
-  PGresult   *res;
-  CState *st = &state[n];
-
-  if (st->listen) {	/* are we receiver? */
-    if (debug) {
-      fprintf(stderr,"client %d receiving\n",n);
-    }
-    while (PQisBusy(st->con) == TRUE) {
-      if (!PQconsumeInput(st->con)) {	/* there's something wrong */
-	fprintf(stderr, "Client %d aborted in state %d. Probably the backend died while processing.\n",n, st->state);
-	remains--;	/* I've aborted */
-	PQfinish(st->con);
-	st->con = NULL;
-	return;
-      }
-    }
-
-    switch (st->state) {
-    case 0:	/* response to "select abalance ..." */
-      res = PQgetResult(st->con);
-      if (check(state, res, n, PGRES_TUPLES_OK)) {
-	return;
-      }
-      PQclear(res);
-      discard_response(st);
-
-      if (++st->cnt >= nxacts) {
-	remains--;	/* I've done */
-	PQfinish(st->con);
-	st->con = NULL;
-	return;
-      }
-      break;
-    }
-
-    /* increment state counter */
-    st->state++;
-    if (st->state > 0) {
-      st->state = 0;
-    }
-  }
-
-  switch (st->state) {
-  case 0:
-    st->aid = getrand(1,naccounts*tps);
-    sprintf(sql,"select abalance from accounts where aid = %d",st->aid);
-    break;
-  }
-
-  if (debug) {
-    fprintf(stderr,"client %d sending %s\n",n,sql);
-  }
-
-  if (PQsendQuery(st->con, sql) == 0) {
-    if (debug) {
-      fprintf(stderr, "PQsendQuery(%s)failed\n",sql);
-    }
-    st->ecnt++;
-  } else {
-    st->listen++;	/* flags that should be listned */
-  }
+static void
+doSelectOnly(CState * state, int n, int debug)
+{
+	char		sql[256];
+	PGresult   *res;
+	CState	   *st = &state[n];
+
+	if (st->listen)
+	{							/* are we receiver? */
+		if (debug)
+			fprintf(stderr, "client %d receiving\n", n);
+		while (PQisBusy(st->con) == TRUE)
+		{
+			if (!PQconsumeInput(st->con))
+			{					/* there's something wrong */
+				fprintf(stderr, "Client %d aborted in state %d. Probably the backend died while processing.\n", n, st->state);
+				remains--;		/* I've aborted */
+				PQfinish(st->con);
+				st->con = NULL;
+				return;
+			}
+		}
+
+		switch (st->state)
+		{
+			case 0:				/* response to "select abalance ..." */
+				res = PQgetResult(st->con);
+				if (check(state, res, n, PGRES_TUPLES_OK))
+					return;
+				PQclear(res);
+				discard_response(st);
+
+				if (++st->cnt >= nxacts)
+				{
+					remains--;	/* I've done */
+					PQfinish(st->con);
+					st->con = NULL;
+					return;
+				}
+				break;
+		}
+
+		/* increment state counter */
+		st->state++;
+		if (st->state > 0)
+			st->state = 0;
+	}
+
+	switch (st->state)
+	{
+		case 0:
+			st->aid = getrand(1, naccounts * tps);
+			sprintf(sql, "select abalance from accounts where aid = %d", st->aid);
+			break;
+	}
+
+	if (debug)
+		fprintf(stderr, "client %d sending %s\n", n, sql);
+
+	if (PQsendQuery(st->con, sql) == 0)
+	{
+		if (debug)
+			fprintf(stderr, "PQsendQuery(%s)failed\n", sql);
+		st->ecnt++;
+	}
+	else
+	{
+		st->listen++;			/* flags that should be listned */
+	}
 }
 
 /* discard connections */
-static void disconnect_all(CState *state) {
-  int i;
-  for (i=0;i<nclients;i++) {
-    if (state[i].con) {
-      PQfinish(state[i].con);
-    }
-  }
+static void
+disconnect_all(CState * state)
+{
+	int			i;
+
+	for (i = 0; i < nclients; i++)
+	{
+		if (state[i].con)
+			PQfinish(state[i].con);
+	}
 }
 
 /* create tables and setup data */
-static void init(char *pghost, char *pgport,char *dbName) {
-  PGconn *con;
-  PGresult *res;
-  static char *DDLs[] = {
-    "drop table branches",
-    "create table branches(bid int, primary key(bid),bbalance int,filler char(88))",
-    "drop table tellers",
-    "create table tellers(tid int, primary key(tid),bid int,tbalance int,filler char(84))",
-    "drop table accounts",
-    "create table accounts(aid int,primary key(aid),bid int,abalance int,filler char(84))",
-    "drop table history",
-    "create table history(tid int,bid int,aid int,delta int,time timestamp,filler char(22))"};
-  char sql[256];
-
-  int i;
-
-  con = PQsetdb(pghost, pgport, NULL, NULL, dbName);
-  if (PQstatus(con) == CONNECTION_BAD) {
-    fprintf(stderr, "Connection to database '%s' on %s failed.\n", dbName,pghost);
-    fprintf(stderr, "%s", PQerrorMessage(con));
-    exit(1);
-  }
-
-  for (i=0;i<(sizeof(DDLs)/sizeof(char *));i++) {
-    res = PQexec(con,DDLs[i]);
-    if (strncmp(DDLs[i],"drop",4) && PQresultStatus(res) != PGRES_COMMAND_OK) {
-      fprintf(stderr, "%s", PQerrorMessage(con));
-      exit(1);
-    }
-    PQclear(res);
-  }
-
-  res = PQexec(con,"begin");
-  if (PQresultStatus(res) != PGRES_COMMAND_OK) {
-    fprintf(stderr, "%s", PQerrorMessage(con));
-    exit(1);
-  }
-
-  for(i = 0; i < nbranches * tps; i++) {
-    sprintf(sql,"insert into branches(bid,bbalance) values(%d,0)",i+1);
-    res = PQexec(con,sql);
-    if (PQresultStatus(res) != PGRES_COMMAND_OK) {
-      fprintf(stderr, "%s", PQerrorMessage(con));
-      exit(1);
-    }
-    PQclear(res);
-  }
-
-  for(i = 0; i < ntellers * tps; i++) {
-    sprintf(sql,"insert into tellers(tid,bid,tbalance) values (%d,%d,0)"
-	    ,i+1,i/ntellers+1);
-    res = PQexec(con,sql);
-    if (PQresultStatus(res) != PGRES_COMMAND_OK) {
-      fprintf(stderr, "%s", PQerrorMessage(con));
-      exit(1);
-    }
-    PQclear(res);
-  }
-
-  res = PQexec(con,"copy accounts from stdin");
-  if (PQresultStatus(res) != PGRES_COPY_IN) {
-    fprintf(stderr, "%s", PQerrorMessage(con));
-    exit(1);
-  }
-  PQclear(res);
-
-  fprintf(stderr,"creating tables...\n");
-  for(i = 0; i < naccounts*tps; i++) {
-    int j = i + 1;
-    sprintf(sql,"%d\t%d\t%d\t\n",i+1,(i+1)/naccounts,0);
-    if (PQputline(con,sql)) {
-      fprintf(stderr,"PQputline failed\n");
-      exit(1);
-    }
-    if (j % 10000 == 0) {
-      fprintf(stderr,"%d tuples done.\n",j);
-    }
-  }
-  if (PQputline(con,"\\.\n")) {
-    fprintf(stderr,"very last PQputline failed\n");
-    exit(1);
-  }
-
-  if (PQendcopy(con)) {
-    fprintf(stderr,"PQendcopy failed\n");
-    exit(1);
-  }
-
-  res = PQexec(con,"end");
-  if (PQresultStatus(res) != PGRES_COMMAND_OK) {
-    fprintf(stderr, "%s", PQerrorMessage(con));
-    exit(1);
-  }
-
-  /* vacuum */
-  fprintf(stderr,"vacuum...");
-  res = PQexec(con,"vacuum analyze");
-  if (PQresultStatus(res) != PGRES_COMMAND_OK) {
-    fprintf(stderr, "%s", PQerrorMessage(con));
-    exit(1);
-  }
-  fprintf(stderr,"done.\n");
-
-  PQfinish(con);
-}
+static void
+init(char *pghost, char *pgport, char *dbName)
+{
+	PGconn	   *con;
+	PGresult   *res;
+	static char *DDLs[] = {
+		"drop table branches",
+		"create table branches(bid int, primary key(bid),bbalance int,filler char(88))",
+		"drop table tellers",
+		"create table tellers(tid int, primary key(tid),bid int,tbalance int,filler char(84))",
+		"drop table accounts",
+		"create table accounts(aid int,primary key(aid),bid int,abalance int,filler char(84))",
+		"drop table history",
+	"create table history(tid int,bid int,aid int,delta int,time timestamp,filler char(22))"};
+	char		sql[256];
+
+	int			i;
+
+	con = PQsetdb(pghost, pgport, NULL, NULL, dbName);
+	if (PQstatus(con) == CONNECTION_BAD)
+	{
+		fprintf(stderr, "Connection to database '%s' on %s failed.\n", dbName, pghost);
+		fprintf(stderr, "%s", PQerrorMessage(con));
+		exit(1);
+	}
 
-/* print out results */
-static void printResults(
-			 int ttype, CState *state, 
-			 struct timeval *tv1,struct timeval *tv2,
-			 struct timeval *tv3) {
-  double t1,t2;
-  int i;
-  int normal_xacts = 0;
-
-  for (i=0;i<nclients;i++) {
-    normal_xacts += state[i].cnt;
-  }
-
-  t1 = (tv3->tv_sec - tv1->tv_sec)*1000000.0+(tv3->tv_usec - tv1->tv_usec);
-  t1 = normal_xacts*1000000.0/t1;
-
-  t2 = (tv3->tv_sec - tv2->tv_sec)*1000000.0+(tv3->tv_usec - tv2->tv_usec);
-  t2 = normal_xacts*1000000.0/t2;
-
-  printf("transaction type: %s\n",ttype==0?"TPC-B (sort of)":"SELECT only");
-  printf("scaling factor: %d\n",tps);
-  printf("number of clients: %d\n",nclients);
-  printf("number of transactions per client: %d\n",nxacts);
-  printf("number of transactions actually processed: %d/%d\n",normal_xacts,nxacts*nclients);
-  printf("tps = %f(including connections establishing)\n",t1);
-  printf("tps = %f(excluding connections establishing)\n",t2);
-}
+	for (i = 0; i < (sizeof(DDLs) / sizeof(char *)); i++)
+	{
+		res = PQexec(con, DDLs[i]);
+		if (strncmp(DDLs[i], "drop", 4) && PQresultStatus(res) != PGRES_COMMAND_OK)
+		{
+			fprintf(stderr, "%s", PQerrorMessage(con));
+			exit(1);
+		}
+		PQclear(res);
+	}
 
-int main(int argc, char **argv) {
-  extern char *optarg;
-  extern int optind, opterr, optopt;
-  int c;
-  char *pghost = "";
-  char *pgport = "";
-  char *dbName;
-  int is_init_mode = 0;	/* initialize mode? */
-  int is_no_vacuum = 0;	/* no vacuum at all before testing? */
-  int is_full_vacuum = 0;	/* do full vacuum before testing? */
-  int debug = 0;	/* debug flag */
-  int ttype = 0;	/* transaction type. 0: TPC-B, 1: SELECT only */
+	res = PQexec(con, "begin");
+	if (PQresultStatus(res) != PGRES_COMMAND_OK)
+	{
+		fprintf(stderr, "%s", PQerrorMessage(con));
+		exit(1);
+	}
 
-  static CState	   state[MAXCLIENTS];	/* clients status */
+	for (i = 0; i < nbranches * tps; i++)
+	{
+		sprintf(sql, "insert into branches(bid,bbalance) values(%d,0)", i + 1);
+		res = PQexec(con, sql);
+		if (PQresultStatus(res) != PGRES_COMMAND_OK)
+		{
+			fprintf(stderr, "%s", PQerrorMessage(con));
+			exit(1);
+		}
+		PQclear(res);
+	}
 
-  struct timeval tv1;	/* start up time */
-  struct timeval tv2;	/* after establishing all connections to the backend */
-  struct timeval tv3;	/* end time */
+	for (i = 0; i < ntellers * tps; i++)
+	{
+		sprintf(sql, "insert into tellers(tid,bid,tbalance) values (%d,%d,0)"
+				,i + 1, i / ntellers + 1);
+		res = PQexec(con, sql);
+		if (PQresultStatus(res) != PGRES_COMMAND_OK)
+		{
+			fprintf(stderr, "%s", PQerrorMessage(con));
+			exit(1);
+		}
+		PQclear(res);
+	}
 
-  int	i;
+	res = PQexec(con, "copy accounts from stdin");
+	if (PQresultStatus(res) != PGRES_COPY_IN)
+	{
+		fprintf(stderr, "%s", PQerrorMessage(con));
+		exit(1);
+	}
+	PQclear(res);
+
+	fprintf(stderr, "creating tables...\n");
+	for (i = 0; i < naccounts * tps; i++)
+	{
+		int			j = i + 1;
+
+		sprintf(sql, "%d\t%d\t%d\t\n", i + 1, (i + 1) / naccounts, 0);
+		if (PQputline(con, sql))
+		{
+			fprintf(stderr, "PQputline failed\n");
+			exit(1);
+		}
+		if (j % 10000 == 0)
+			fprintf(stderr, "%d tuples done.\n", j);
+	}
+	if (PQputline(con, "\\.\n"))
+	{
+		fprintf(stderr, "very last PQputline failed\n");
+		exit(1);
+	}
+
+	if (PQendcopy(con))
+	{
+		fprintf(stderr, "PQendcopy failed\n");
+		exit(1);
+	}
+
+	res = PQexec(con, "end");
+	if (PQresultStatus(res) != PGRES_COMMAND_OK)
+	{
+		fprintf(stderr, "%s", PQerrorMessage(con));
+		exit(1);
+	}
+
+	/* vacuum */
+	fprintf(stderr, "vacuum...");
+	res = PQexec(con, "vacuum analyze");
+	if (PQresultStatus(res) != PGRES_COMMAND_OK)
+	{
+		fprintf(stderr, "%s", PQerrorMessage(con));
+		exit(1);
+	}
+	fprintf(stderr, "done.\n");
+
+	PQfinish(con);
+}
 
-  fd_set	input_mask;
-  int nsocks;	/* return from select(2) */
-  int maxsock;	/* max socket number to be waited */
+/* print out results */
+static void
+printResults(
+			 int ttype, CState * state,
+			 struct timeval * tv1, struct timeval * tv2,
+			 struct timeval * tv3)
+{
+	double		t1,
+				t2;
+	int			i;
+	int			normal_xacts = 0;
+
+	for (i = 0; i < nclients; i++)
+		normal_xacts += state[i].cnt;
+
+	t1 = (tv3->tv_sec - tv1->tv_sec) * 1000000.0 + (tv3->tv_usec - tv1->tv_usec);
+	t1 = normal_xacts * 1000000.0 / t1;
+
+	t2 = (tv3->tv_sec - tv2->tv_sec) * 1000000.0 + (tv3->tv_usec - tv2->tv_usec);
+	t2 = normal_xacts * 1000000.0 / t2;
+
+	printf("transaction type: %s\n", ttype == 0 ? "TPC-B (sort of)" : "SELECT only");
+	printf("scaling factor: %d\n", tps);
+	printf("number of clients: %d\n", nclients);
+	printf("number of transactions per client: %d\n", nxacts);
+	printf("number of transactions actually processed: %d/%d\n", normal_xacts, nxacts * nclients);
+	printf("tps = %f(including connections establishing)\n", t1);
+	printf("tps = %f(excluding connections establishing)\n", t2);
+}
+
+int
+main(int argc, char **argv)
+{
+	extern char *optarg;
+	extern int	optind,
+				opterr,
+				optopt;
+	int			c;
+	char	   *pghost = "";
+	char	   *pgport = "";
+	char	   *dbName;
+	int			is_init_mode = 0;		/* initialize mode? */
+	int			is_no_vacuum = 0;		/* no vacuum at all before
+										 * testing? */
+	int			is_full_vacuum = 0;		/* do full vacuum before testing? */
+	int			debug = 0;		/* debug flag */
+	int			ttype = 0;		/* transaction type. 0: TPC-B, 1: SELECT
+								 * only */
+
+	static CState state[MAXCLIENTS];	/* clients status */
+
+	struct timeval tv1;			/* start up time */
+	struct timeval tv2;			/* after establishing all connections to
+								 * the backend */
+	struct timeval tv3;			/* end time */
+
+	int			i;
+
+	fd_set		input_mask;
+	int			nsocks;			/* return from select(2) */
+	int			maxsock;		/* max socket number to be waited */
 
 #ifndef __CYGWIN32__
-  struct rlimit rlim;
+	struct rlimit rlim;
+
 #endif
 
-  PGconn *con;
-  PGresult *res;
-
-  while ((c = getopt(argc, argv, "ih:nvp:dc:t:s:S")) != EOF) {
-    switch (c) {
-    case 'i':
-      is_init_mode++;
-      break;
-    case 'h':
-      pghost = optarg;
-      break;
-    case 'n':
-      is_no_vacuum++;
-      break;
-    case 'v':
-      is_full_vacuum++;
-      break;
-    case 'p':
-      pgport = optarg;
-      break;
-    case 'd':
-      debug++;
-      break;
-    case 'S':
-      ttype = 1;
-      break;
-    case 'c':
-      nclients = atoi(optarg);
-      if (nclients <= 0 || nclients > MAXCLIENTS) {
-	fprintf(stderr,"wrong number of clients: %d\n",nclients);
-	exit(1);
-      }
+	PGconn	   *con;
+	PGresult   *res;
+
+	while ((c = getopt(argc, argv, "ih:nvp:dc:t:s:S")) != EOF)
+	{
+		switch (c)
+		{
+			case 'i':
+				is_init_mode++;
+				break;
+			case 'h':
+				pghost = optarg;
+				break;
+			case 'n':
+				is_no_vacuum++;
+				break;
+			case 'v':
+				is_full_vacuum++;
+				break;
+			case 'p':
+				pgport = optarg;
+				break;
+			case 'd':
+				debug++;
+				break;
+			case 'S':
+				ttype = 1;
+				break;
+			case 'c':
+				nclients = atoi(optarg);
+				if (nclients <= 0 || nclients > MAXCLIENTS)
+				{
+					fprintf(stderr, "wrong number of clients: %d\n", nclients);
+					exit(1);
+				}
 #ifndef __CYGWIN32__
-#ifdef RLIMIT_NOFILE		/* most platform uses RLIMIT_NOFILE */
-      if (getrlimit(RLIMIT_NOFILE,&rlim) == -1) {
-#else	/* but BSD doesn't ... */
-      if (getrlimit(RLIMIT_OFILE,&rlim) == -1) {
-#endif /* HAVE_RLIMIT_NOFILE */
-	fprintf(stderr,"getrlimit failed. reason: %s\n",strerror(errno));
-	exit(1);
-      }
-      if (rlim.rlim_cur <= (nclients+2)) {
-	fprintf(stderr,"You need at least %d open files resource but you are only allowed to use %ld.\n",nclients+2,rlim.rlim_cur);
-	fprintf(stderr,"Use limit/ulimt to increase the limit before using pgbench.\n");
-	exit(1);
-      }
-#endif /* #ifndef __CYGWIN32__ */
-      break;
-    case 's':
-      tps = atoi(optarg);
-      if (tps <= 0) {
-	fprintf(stderr,"wrong scaling factor: %d\n",tps);
-	exit(1);
-      }
-      break;
-    case 't':
-      nxacts = atoi(optarg);
-      if (nxacts <= 0) {
-	fprintf(stderr,"wrong number of transactions: %d\n",nxacts);
-	exit(1);
-      }
-      break;
-    default:
-      usage();
-      exit(1);
-      break;
-    }
-  }
-
-  if (argc > optind) {
-    dbName = argv[optind];
-  } else {
-    dbName = getenv("USER");
-    if (dbName == NULL) {
-      dbName = "";
-    }
-  }
-
-  if (is_init_mode) {
-    init(pghost, pgport, dbName);
-    exit(0);
-  }
-
-  remains = nclients;
-
-  if (debug) {
-    printf("pghost: %s pgport: %s nclients: %d nxacts: %d dbName: %s\n",
-	   pghost, pgport, nclients, nxacts, dbName);
-  }
-
-  /* opening connection... */
-  con = PQsetdb(pghost, pgport, NULL, NULL, dbName);
-  if (PQstatus(con) == CONNECTION_BAD) {
-    fprintf(stderr, "Connection to database '%s' failed.\n", dbName);
-    fprintf(stderr, "%s", PQerrorMessage(con));
-    exit(1);
-  }
-
-  /* get the scaling factor that should be same as count(*) from branches... */
-  res = PQexec(con,"select count(*) from branches");
-  if (PQresultStatus(res) != PGRES_TUPLES_OK) {
-    fprintf(stderr, "%s", PQerrorMessage(con));
-    exit(1);
-  }
-  tps = atoi(PQgetvalue(res, 0, 0));
-  if (tps < 0) {
-    fprintf(stderr,"count(*) from branches invalid (%d)\n",tps);
-    exit(1);
-  }
-  PQclear(res);
-
-  if (!is_no_vacuum) {
-    fprintf(stderr,"starting vacuum...");
-    res = PQexec(con,"vacuum branches");
-    if (PQresultStatus(res) != PGRES_COMMAND_OK) {
-      fprintf(stderr, "%s", PQerrorMessage(con));
-      exit(1);
-    }
-    PQclear(res);
-
-    res = PQexec(con,"vacuum tellers");
-    if (PQresultStatus(res) != PGRES_COMMAND_OK) {
-      fprintf(stderr, "%s", PQerrorMessage(con));
-      exit(1);
-    }
-    PQclear(res);
-
-    res = PQexec(con,"delete from history");
-    if (PQresultStatus(res) != PGRES_COMMAND_OK) {
-      fprintf(stderr, "%s", PQerrorMessage(con));
-      exit(1);
-    }
-    PQclear(res);
-    res = PQexec(con,"vacuum history");
-    if (PQresultStatus(res) != PGRES_COMMAND_OK) {
-      fprintf(stderr, "%s", PQerrorMessage(con));
-      exit(1);
-    }
-    PQclear(res);
-
-    fprintf(stderr,"end.\n");
-
-    if (is_full_vacuum) {
-      fprintf(stderr,"starting full vacuum...");
-      res = PQexec(con,"vacuum analyze accounts");
-      if (PQresultStatus(res) != PGRES_COMMAND_OK) {
-	fprintf(stderr, "%s", PQerrorMessage(con));
-	exit(1);
-      }
-      PQclear(res);
-      fprintf(stderr,"end.\n");
-    }
-  }
-  PQfinish(con);
-
-  /* set random seed */
-  gettimeofday(&tv1, 0);
-  srand((uint)tv1.tv_usec);
-
-  /* get start up time */
-  gettimeofday(&tv1, 0);
-
-  /* make connections to the database */
-  for (i=0;i<nclients;i++) {
-    state[i].con = PQsetdb(pghost, pgport, NULL, NULL, dbName);
-    if (PQstatus(state[i].con) == CONNECTION_BAD) {
-      fprintf(stderr, "Connection to database '%s' failed.\n", dbName);
-      fprintf(stderr, "%s", PQerrorMessage(state[i].con));
-      exit(1);
-    }
-  }
-
-  /* time after connections set up */
-  gettimeofday(&tv2, 0);
-
-  /* send start up quries in async manner */
-  for (i=0;i<nclients;i++) {
-    if (ttype == 0) {
-      doOne(state, i, debug);
-    } else if (ttype == 1) {
-      doSelectOnly(state, i, debug);
-    }
-  }
-
-  for (;;) {
-    if (remains <= 0) {	/* all done ? */
-      disconnect_all(state);
-      /* get end time */
-      gettimeofday(&tv3, 0);
-      printResults(ttype, state, &tv1,&tv2,&tv3);
-      exit(0);
-    }
-
-    FD_ZERO(&input_mask);
-
-    maxsock = 0;
-    for (i=0;i<nclients;i++) {
-      if (state[i].con) {
-	int sock = PQsocket(state[i].con);
-	if (sock < 0) {
-	  fprintf(stderr,"Client %d: PQsock failed\n",i);
-	  disconnect_all(state);
-	  exit(1);
-	}
-	FD_SET(sock, &input_mask);
-	if (maxsock < sock) {
-	  maxsock = sock;
-	}
-      }
-    }
-
-    if ((nsocks = select(maxsock +1, &input_mask, (fd_set *)NULL,
-			 (fd_set *)NULL, (struct timeval *)NULL)) < 0) {
-      if (errno == EINTR) {
-	continue;
-      }
-      /* must be something wrong */
-      disconnect_all(state);
-      fprintf(stderr,"select failed: %s\n",strerror(errno));
-      exit(1);
-    } else if (nsocks == 0) { /* timeout */
-      fprintf(stderr,"select timeout\n");
-      for (i=0;i<nclients;i++) {
-	fprintf(stderr,"client %d:state %d cnt %d ecnt %d listen %d\n",
-		i,state[i].state,state[i].cnt,state[i].ecnt,state[i].listen);
-      }
-      exit(0);
-    }
-
-    /* ok, backend returns reply */
-    for (i=0;i<nclients;i++) {
-      if (state[i].con && FD_ISSET(PQsocket(state[i].con), &input_mask)) {
-	if (ttype == 0) {
-	  doOne(state, i, debug);
-	} else if (ttype == 1) {
-	  doSelectOnly(state, i, debug);
-	}
-      }
-    }
-  }
+#ifdef RLIMIT_NOFILE			/* most platform uses RLIMIT_NOFILE */
+				if (getrlimit(RLIMIT_NOFILE, &rlim) == -1)
+				{
+#else							/* but BSD doesn't ... */
+				if (getrlimit(RLIMIT_OFILE, &rlim) == -1)
+				{
+#endif	 /* HAVE_RLIMIT_NOFILE */
+					fprintf(stderr, "getrlimit failed. reason: %s\n", strerror(errno));
+					exit(1);
+				}
+				if (rlim.rlim_cur <= (nclients + 2))
+				{
+					fprintf(stderr, "You need at least %d open files resource but you are only allowed to use %ld.\n", nclients + 2, rlim.rlim_cur);
+					fprintf(stderr, "Use limit/ulimt to increase the limit before using pgbench.\n");
+					exit(1);
+				}
+#endif	 /* #ifndef __CYGWIN32__ */
+				break;
+			case 's':
+				tps = atoi(optarg);
+				if (tps <= 0)
+				{
+					fprintf(stderr, "wrong scaling factor: %d\n", tps);
+					exit(1);
+				}
+				break;
+			case 't':
+				nxacts = atoi(optarg);
+				if (nxacts <= 0)
+				{
+					fprintf(stderr, "wrong number of transactions: %d\n", nxacts);
+					exit(1);
+				}
+				break;
+			default:
+				usage();
+				exit(1);
+				break;
+		}
+	}
+
+	if (argc > optind)
+		dbName = argv[optind];
+	else
+	{
+		dbName = getenv("USER");
+		if (dbName == NULL)
+			dbName = "";
+	}
+
+	if (is_init_mode)
+	{
+		init(pghost, pgport, dbName);
+		exit(0);
+	}
+
+	remains = nclients;
+
+	if (debug)
+	{
+		printf("pghost: %s pgport: %s nclients: %d nxacts: %d dbName: %s\n",
+			   pghost, pgport, nclients, nxacts, dbName);
+	}
+
+	/* opening connection... */
+	con = PQsetdb(pghost, pgport, NULL, NULL, dbName);
+	if (PQstatus(con) == CONNECTION_BAD)
+	{
+		fprintf(stderr, "Connection to database '%s' failed.\n", dbName);
+		fprintf(stderr, "%s", PQerrorMessage(con));
+		exit(1);
+	}
+
+	/*
+	 * get the scaling factor that should be same as count(*) from
+	 * branches...
+	 */
+	res = PQexec(con, "select count(*) from branches");
+	if (PQresultStatus(res) != PGRES_TUPLES_OK)
+	{
+		fprintf(stderr, "%s", PQerrorMessage(con));
+		exit(1);
+	}
+	tps = atoi(PQgetvalue(res, 0, 0));
+	if (tps < 0)
+	{
+		fprintf(stderr, "count(*) from branches invalid (%d)\n", tps);
+		exit(1);
+	}
+	PQclear(res);
+
+	if (!is_no_vacuum)
+	{
+		fprintf(stderr, "starting vacuum...");
+		res = PQexec(con, "vacuum branches");
+		if (PQresultStatus(res) != PGRES_COMMAND_OK)
+		{
+			fprintf(stderr, "%s", PQerrorMessage(con));
+			exit(1);
+		}
+		PQclear(res);
+
+		res = PQexec(con, "vacuum tellers");
+		if (PQresultStatus(res) != PGRES_COMMAND_OK)
+		{
+			fprintf(stderr, "%s", PQerrorMessage(con));
+			exit(1);
+		}
+		PQclear(res);
+
+		res = PQexec(con, "delete from history");
+		if (PQresultStatus(res) != PGRES_COMMAND_OK)
+		{
+			fprintf(stderr, "%s", PQerrorMessage(con));
+			exit(1);
+		}
+		PQclear(res);
+		res = PQexec(con, "vacuum history");
+		if (PQresultStatus(res) != PGRES_COMMAND_OK)
+		{
+			fprintf(stderr, "%s", PQerrorMessage(con));
+			exit(1);
+		}
+		PQclear(res);
+
+		fprintf(stderr, "end.\n");
+
+		if (is_full_vacuum)
+		{
+			fprintf(stderr, "starting full vacuum...");
+			res = PQexec(con, "vacuum analyze accounts");
+			if (PQresultStatus(res) != PGRES_COMMAND_OK)
+			{
+				fprintf(stderr, "%s", PQerrorMessage(con));
+				exit(1);
+			}
+			PQclear(res);
+			fprintf(stderr, "end.\n");
+		}
+	}
+	PQfinish(con);
+
+	/* set random seed */
+	gettimeofday(&tv1, 0);
+	srand((uint) tv1.tv_usec);
+
+	/* get start up time */
+	gettimeofday(&tv1, 0);
+
+	/* make connections to the database */
+	for (i = 0; i < nclients; i++)
+	{
+		state[i].con = PQsetdb(pghost, pgport, NULL, NULL, dbName);
+		if (PQstatus(state[i].con) == CONNECTION_BAD)
+		{
+			fprintf(stderr, "Connection to database '%s' failed.\n", dbName);
+			fprintf(stderr, "%s", PQerrorMessage(state[i].con));
+			exit(1);
+		}
+	}
+
+	/* time after connections set up */
+	gettimeofday(&tv2, 0);
+
+	/* send start up quries in async manner */
+	for (i = 0; i < nclients; i++)
+	{
+		if (ttype == 0)
+			doOne(state, i, debug);
+		else if (ttype == 1)
+			doSelectOnly(state, i, debug);
+	}
+
+	for (;;)
+	{
+		if (remains <= 0)
+		{						/* all done ? */
+			disconnect_all(state);
+			/* get end time */
+			gettimeofday(&tv3, 0);
+			printResults(ttype, state, &tv1, &tv2, &tv3);
+			exit(0);
+		}
+
+		FD_ZERO(&input_mask);
+
+		maxsock = 0;
+		for (i = 0; i < nclients; i++)
+		{
+			if (state[i].con)
+			{
+				int			sock = PQsocket(state[i].con);
+
+				if (sock < 0)
+				{
+					fprintf(stderr, "Client %d: PQsock failed\n", i);
+					disconnect_all(state);
+					exit(1);
+				}
+				FD_SET(sock, &input_mask);
+				if (maxsock < sock)
+					maxsock = sock;
+			}
+		}
+
+		if ((nsocks = select(maxsock + 1, &input_mask, (fd_set *) NULL,
+						  (fd_set *) NULL, (struct timeval *) NULL)) < 0)
+		{
+			if (errno == EINTR)
+				continue;
+			/* must be something wrong */
+			disconnect_all(state);
+			fprintf(stderr, "select failed: %s\n", strerror(errno));
+			exit(1);
+		}
+		else if (nsocks == 0)
+		{						/* timeout */
+			fprintf(stderr, "select timeout\n");
+			for (i = 0; i < nclients; i++)
+			{
+				fprintf(stderr, "client %d:state %d cnt %d ecnt %d listen %d\n",
+						i, state[i].state, state[i].cnt, state[i].ecnt, state[i].listen);
+			}
+			exit(0);
+		}
+
+		/* ok, backend returns reply */
+		for (i = 0; i < nclients; i++)
+		{
+			if (state[i].con && FD_ISSET(PQsocket(state[i].con), &input_mask))
+			{
+				if (ttype == 0)
+					doOne(state, i, debug);
+				else if (ttype == 1)
+					doSelectOnly(state, i, debug);
+			}
+		}
+	}
 }
diff --git a/contrib/string/string_io.c b/contrib/string/string_io.c
index 9407e6a21b3d37425140ad96b43f1e08affedca8..cb8323d9c9b75650429cc753536fcf65682419bf 100644
--- a/contrib/string/string_io.c
+++ b/contrib/string/string_io.c
@@ -23,7 +23,7 @@
 #define ISO8859
 
 #define MIN(x, y)	((x) < (y) ? (x) : (y))
-#define VALUE(char)	((char) - '0')
+#define VALUE(char) ((char) - '0')
 #define DIGIT(val)	((val) + '0')
 #define ISOCTAL(c)	(((c) >= '0') && ((c) <= '7'))
 #ifndef ISO8859
@@ -89,9 +89,8 @@ string_output(unsigned char *data, int size)
 				break;
 			case '{':
 				/* Escape beginning of string, to distinguish from arrays */
-				if (p == data) {
+				if (p == data)
 					len++;
-				}
 				break;
 			default:
 				if (NOTPRINTABLE(*p))
@@ -137,9 +136,8 @@ string_output(unsigned char *data, int size)
 				break;
 			case '{':
 				/* Escape beginning of string, to distinguish from arrays */
-				if (p == data) {
+				if (p == data)
 					*r++ = '\\';
-				}
 				*r++ = c;
 				break;
 			default:
@@ -361,14 +359,15 @@ c_charin(unsigned char *str)
 {
 	return (string_input(str, 1, 0, NULL));
 }
+
 #endif
 
 /* end of file */
 
 /*
  * Local Variables:
- *  tab-width: 4
- *  c-indent-level: 4
- *  c-basic-offset: 4
+ *	tab-width: 4
+ *	c-indent-level: 4
+ *	c-basic-offset: 4
  * End:
  */
diff --git a/contrib/string/string_io.h b/contrib/string/string_io.h
index e79d7fd28febc7392d56c8102c166561c2182883..556c33660ce7b18c1c5d9585bce44cfff4531d9f 100644
--- a/contrib/string/string_io.h
+++ b/contrib/string/string_io.h
@@ -1,24 +1,25 @@
 #ifndef STRING_IO_H
 #define STRING_IO_H
 
-unsigned char*	string_output(unsigned char *data, int size);
-unsigned char*	string_input(unsigned char *str, int size, int hdrsize,
-							  int *rtn_size);
-unsigned char*	c_charout(int32 c);
-unsigned char*	c_textout(struct varlena * vlena);
-unsigned char*	c_varcharout(unsigned char *s);
+unsigned char *string_output(unsigned char *data, int size);
+unsigned char *string_input(unsigned char *str, int size, int hdrsize,
+			 int *rtn_size);
+unsigned char *c_charout(int32 c);
+unsigned char *c_textout(struct varlena * vlena);
+unsigned char *c_varcharout(unsigned char *s);
 
 #if 0
-struct varlena*	c_textin(unsigned char *str);
-int32*			c_charin(unsigned char *str)
+struct varlena *c_textin(unsigned char *str);
+int32 *
+c_charin(unsigned char *str)
 #endif
 
 #endif
 
 /*
  * Local Variables:
- *  tab-width: 4
- *  c-indent-level: 4
- *  c-basic-offset: 4
+ *	tab-width: 4
+ *	c-indent-level: 4
+ *	c-basic-offset: 4
  * End:
  */
diff --git a/contrib/userlock/user_locks.c b/contrib/userlock/user_locks.c
index 1a596d515401696034e38dff0fedd0256500b059..1e37a54cf01ec2470e75e78fdde185ee6c2d1418 100644
--- a/contrib/userlock/user_locks.c
+++ b/contrib/userlock/user_locks.c
@@ -96,8 +96,8 @@ user_unlock_all()
 
 /*
  * Local Variables:
- *  tab-width: 4
- *  c-indent-level: 4
- *  c-basic-offset: 4
+ *	tab-width: 4
+ *	c-indent-level: 4
+ *	c-basic-offset: 4
  * End:
  */
diff --git a/contrib/userlock/user_locks.h b/contrib/userlock/user_locks.h
index 3f0449e7e4507a1ffae70bec4d28adcbb69329fb..82ecb3b9ea00c22b98b9c9bbe244ae2e7ed84230 100644
--- a/contrib/userlock/user_locks.h
+++ b/contrib/userlock/user_locks.h
@@ -13,8 +13,8 @@ int			user_unlock_all(void);
 
 /*
  * Local Variables:
- *  tab-width: 4
- *  c-indent-level: 4
- *  c-basic-offset: 4
+ *	tab-width: 4
+ *	c-indent-level: 4
+ *	c-basic-offset: 4
  * End:
  */
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c
index 4eec6ed6d077438bd3d637a17536b2f948d7620a..d30e4c7fe64e350bbee4ffed062a74e7d679e1ab 100644
--- a/src/backend/access/common/heaptuple.c
+++ b/src/backend/access/common/heaptuple.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.61 2000/01/26 05:55:53 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.62 2000/04/12 17:14:36 momjian Exp $
  *
  * NOTES
  *	  The old interface functions have been converted to macros
@@ -137,9 +137,9 @@ DataFill(char *data,
 								   *((int32 *) value[i]));
 				break;
 			default:
-                Assert(att[i]->attlen >= 0);
-                memmove(data, DatumGetPointer(value[i]),
-                        (size_t)(att[i]->attlen));
+				Assert(att[i]->attlen >= 0);
+				memmove(data, DatumGetPointer(value[i]),
+						(size_t) (att[i]->attlen));
 				break;
 		}
 		data = (char *) att_addlength((long) data, att[i]->attlen, value[i]);
@@ -326,7 +326,7 @@ nocachegetattr(HeapTuple tuple,
 	Form_pg_attribute *att = tupleDesc->attrs;
 	int			slow = 0;		/* do we have to walk nulls? */
 
-    (void)isnull; /*not used*/
+	(void) isnull;				/* not used */
 #ifdef IN_MACRO
 /* This is handled in the macro */
 	Assert(attnum > 0);
@@ -681,7 +681,7 @@ heap_formtuple(TupleDesc tupleDescriptor,
 		len += bitmaplen;
 	}
 
-	hoff = len = MAXALIGN(len);		/* be conservative here */
+	hoff = len = MAXALIGN(len); /* be conservative here */
 
 	len += ComputeDataSize(tupleDescriptor, value, nulls);
 
@@ -806,11 +806,9 @@ void
 heap_freetuple(HeapTuple htup)
 {
 	if (htup->t_data != NULL)
-		if (htup->t_datamcxt != NULL && (char *)(htup->t_data) != 
-									((char *) htup + HEAPTUPLESIZE))
-		{
+		if (htup->t_datamcxt != NULL && (char *) (htup->t_data) !=
+			((char *) htup + HEAPTUPLESIZE))
 			elog(NOTICE, "TELL Jan Wieck: heap_freetuple() found separate t_data");
-		}
 
 	pfree(htup);
 }
@@ -835,7 +833,7 @@ heap_addheader(uint32 natts,	/* max domain index */
 
 	len = offsetof(HeapTupleHeaderData, t_bits);
 
-	hoff = len = MAXALIGN(len);		/* be conservative */
+	hoff = len = MAXALIGN(len); /* be conservative */
 	len += structlen;
 	tuple = (HeapTuple) palloc(HEAPTUPLESIZE + len);
 	tuple->t_datamcxt = CurrentMemoryContext;
@@ -850,8 +848,8 @@ heap_addheader(uint32 natts,	/* max domain index */
 	td->t_infomask = 0;
 	td->t_infomask |= HEAP_XMAX_INVALID;
 
-    if (structlen > 0)
-        memmove((char *) td + hoff, structure, (size_t)structlen);
+	if (structlen > 0)
+		memmove((char *) td + hoff, structure, (size_t) structlen);
 
 	return tuple;
 }
diff --git a/src/backend/access/common/indextuple.c b/src/backend/access/common/indextuple.c
index 438318747d24cd75b895fde89728fac6b9180019..e11ddbc1dc9b495cd5a81438268d48f2692088aa 100644
--- a/src/backend/access/common/indextuple.c
+++ b/src/backend/access/common/indextuple.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.42 2000/01/26 05:55:53 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.43 2000/04/12 17:14:37 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -60,7 +60,7 @@ index_formtuple(TupleDesc tupleDescriptor,
 
 	hoff = IndexInfoFindDataOffset(infomask);
 	size = hoff + ComputeDataSize(tupleDescriptor, value, null);
-	size = MAXALIGN(size);	/* be conservative */
+	size = MAXALIGN(size);		/* be conservative */
 
 	tp = (char *) palloc(size);
 	tuple = (IndexTuple) tp;
@@ -134,7 +134,7 @@ nocache_index_getattr(IndexTuple tup,
 	int			data_off;		/* tuple data offset */
 	Form_pg_attribute *att = tupleDesc->attrs;
 
-    (void)isnull;
+	(void) isnull;
 	/* ----------------
 	 *	sanity checks
 	 * ----------------
diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c
index b2af4ff932ecac4ba53f1dd9e78e9b8b04e5bd1e..1e8d2ae00343a5964c4a5d01b164413c0dc3c4f8 100644
--- a/src/backend/access/common/tupdesc.c
+++ b/src/backend/access/common/tupdesc.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.61 2000/01/31 04:35:48 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.62 2000/04/12 17:14:37 momjian Exp $
  *
  * NOTES
  *	  some of the executor utility code such as "ExecTypeFromTL" should be
@@ -229,17 +229,19 @@ FreeTupleDesc(TupleDesc tupdesc)
 bool
 equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
 {
-	int		i;
+	int			i;
 
 	if (tupdesc1->natts != tupdesc2->natts)
 		return false;
 	for (i = 0; i < tupdesc1->natts; i++)
 	{
-		Form_pg_attribute	attr1 = tupdesc1->attrs[i];
-		Form_pg_attribute	attr2 = tupdesc2->attrs[i];
+		Form_pg_attribute attr1 = tupdesc1->attrs[i];
+		Form_pg_attribute attr2 = tupdesc2->attrs[i];
 
-		/* We do not need to check every single field here, and in fact
-		 * some fields such as attdisbursion probably shouldn't be compared.
+		/*
+		 * We do not need to check every single field here, and in fact
+		 * some fields such as attdisbursion probably shouldn't be
+		 * compared.
 		 */
 		if (strcmp(NameStr(attr1->attname), NameStr(attr2->attname)) != 0)
 			return false;
@@ -254,8 +256,8 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
 	}
 	if (tupdesc1->constr != NULL)
 	{
-		TupleConstr	   *constr1 = tupdesc1->constr;
-		TupleConstr	   *constr2 = tupdesc2->constr;
+		TupleConstr *constr1 = tupdesc1->constr;
+		TupleConstr *constr2 = tupdesc2->constr;
 
 		if (constr2 == NULL)
 			return false;
@@ -263,8 +265,8 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
 			return false;
 		for (i = 0; i < (int) constr1->num_defval; i++)
 		{
-			AttrDefault	   *defval1 = constr1->defval + i;
-			AttrDefault	   *defval2 = constr2->defval + i;
+			AttrDefault *defval1 = constr1->defval + i;
+			AttrDefault *defval2 = constr2->defval + i;
 
 			if (defval1->adnum != defval2->adnum)
 				return false;
@@ -275,8 +277,8 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
 			return false;
 		for (i = 0; i < (int) constr1->num_check; i++)
 		{
-			ConstrCheck	   *check1 = constr1->check + i;
-			ConstrCheck	   *check2 = constr2->check + i;
+			ConstrCheck *check1 = constr1->check + i;
+			ConstrCheck *check2 = constr2->check + i;
 
 			if (strcmp(check1->ccname, check2->ccname) != 0)
 				return false;
@@ -585,8 +587,9 @@ BuildDescForRelation(List *schema, char *relname)
 			constr->has_not_null = true;
 		desc->attrs[attnum - 1]->attnotnull = entry->is_not_null;
 
-		/* Note we copy only pre-cooked default expressions.
-		 * Digestion of raw ones is someone else's problem.
+		/*
+		 * Note we copy only pre-cooked default expressions. Digestion of
+		 * raw ones is someone else's problem.
 		 */
 		if (entry->cooked_default != NULL)
 		{
diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c
index 9e93f1d652da5d13340c6b53e717734a05468832..66a3702e438d3630486ffb97722a5fcac7583bb3 100644
--- a/src/backend/access/gist/gist.c
+++ b/src/backend/access/gist/gist.c
@@ -6,7 +6,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.52 2000/03/17 02:36:00 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.53 2000/04/12 17:14:39 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -52,8 +52,10 @@ void		gistdelete(Relation r, ItemPointer tid);
 static IndexTuple gist_tuple_replacekey(Relation r, GISTENTRY entry, IndexTuple t);
 static void gistcentryinit(GISTSTATE *giststate, GISTENTRY *e, char *pr,
 			   Relation r, Page pg, OffsetNumber o, int b, bool l);
+
 #ifdef GISTDEBUG
 static char *int_range_out(INTRANGE *r);
+
 #endif
 
 /*
@@ -98,7 +100,7 @@ gistbuild(Relation heap,
 
 	/* no locking is needed */
 
-	CommandCounterIncrement();		/* so we can see the new pg_index tuple */
+	CommandCounterIncrement();	/* so we can see the new pg_index tuple */
 
 	initGISTstate(&giststate, index);
 
@@ -186,7 +188,7 @@ gistbuild(Relation heap,
 #ifndef OMIT_PARTIAL_INDEX
 			/* SetSlotContents(slot, htup); */
 			slot->val = htup;
-			if (! ExecQual((List *) pred, econtext, false))
+			if (!ExecQual((List *) pred, econtext, false))
 				continue;
 #endif	 /* OMIT_PARTIAL_INDEX */
 		}
@@ -272,18 +274,18 @@ gistbuild(Relation heap,
 	/*
 	 * Since we just counted the tuples in the heap, we update its stats
 	 * in pg_class to guarantee that the planner takes advantage of the
-	 * index we just created.  But, only update statistics during
-	 * normal index definitions, not for indices on system catalogs
-	 * created during bootstrap processing.  We must close the relations
-	 * before updating statistics to guarantee that the relcache entries
-	 * are flushed when we increment the command counter in UpdateStats().
-	 * But we do not release any locks on the relations; those will be
-	 * held until end of transaction.
+	 * index we just created.  But, only update statistics during normal
+	 * index definitions, not for indices on system catalogs created
+	 * during bootstrap processing.  We must close the relations before
+	 * updating statistics to guarantee that the relcache entries are
+	 * flushed when we increment the command counter in UpdateStats(). But
+	 * we do not release any locks on the relations; those will be held
+	 * until end of transaction.
 	 */
 	if (IsNormalProcessingMode())
 	{
-		Oid		hrelid = RelationGetRelid(heap);
-		Oid		irelid = RelationGetRelid(index);
+		Oid			hrelid = RelationGetRelid(heap);
+		Oid			irelid = RelationGetRelid(index);
 		bool		inplace = IsReindexProcessing();
 
 		heap_close(heap, NoLock);
diff --git a/src/backend/access/gist/gistscan.c b/src/backend/access/gist/gistscan.c
index a7d1faf43db1b9ffcf45fda183f9e0415aa54a62..2196e897e4a12ecccfc52edd3170af13a22c93f4 100644
--- a/src/backend/access/gist/gistscan.c
+++ b/src/backend/access/gist/gistscan.c
@@ -266,7 +266,7 @@ gistdropscan(IndexScanDesc s)
 		prev = l;
 
 	if (l == (GISTScanList) NULL)
-		elog(ERROR, "GiST scan list corrupted -- cannot find 0x%p", (void*)s);
+		elog(ERROR, "GiST scan list corrupted -- cannot find 0x%p", (void *) s);
 
 	if (prev == (GISTScanList) NULL)
 		GISTScans = l->gsl_next;
diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c
index d116aa1a4997131f44738527c1d180c45cfb6c50..1e5bc15bf2fadbe3339da23beb059622168bcf08 100644
--- a/src/backend/access/hash/hash.c
+++ b/src/backend/access/hash/hash.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.36 2000/03/01 05:39:22 inoue Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.37 2000/04/12 17:14:43 momjian Exp $
  *
  * NOTES
  *	  This file contains only the public interface routines.
@@ -149,7 +149,7 @@ hashbuild(Relation heap,
 #ifndef OMIT_PARTIAL_INDEX
 			/* SetSlotContents(slot, htup); */
 			slot->val = htup;
-			if (! ExecQual((List *) pred, econtext, false))
+			if (!ExecQual((List *) pred, econtext, false))
 				continue;
 #endif	 /* OMIT_PARTIAL_INDEX */
 		}
@@ -230,18 +230,18 @@ hashbuild(Relation heap,
 	/*
 	 * Since we just counted the tuples in the heap, we update its stats
 	 * in pg_class to guarantee that the planner takes advantage of the
-	 * index we just created.  But, only update statistics during
-	 * normal index definitions, not for indices on system catalogs
-	 * created during bootstrap processing.  We must close the relations
-	 * before updating statistics to guarantee that the relcache entries
-	 * are flushed when we increment the command counter in UpdateStats().
-	 * But we do not release any locks on the relations; those will be
-	 * held until end of transaction.
+	 * index we just created.  But, only update statistics during normal
+	 * index definitions, not for indices on system catalogs created
+	 * during bootstrap processing.  We must close the relations before
+	 * updating statistics to guarantee that the relcache entries are
+	 * flushed when we increment the command counter in UpdateStats(). But
+	 * we do not release any locks on the relations; those will be held
+	 * until end of transaction.
 	 */
 	if (IsNormalProcessingMode())
 	{
-		Oid		hrelid = RelationGetRelid(heap);
-		Oid		irelid = RelationGetRelid(index);
+		Oid			hrelid = RelationGetRelid(heap);
+		Oid			irelid = RelationGetRelid(index);
 		bool		inplace = IsReindexProcessing();
 
 		heap_close(heap, NoLock);
diff --git a/src/backend/access/hash/hashfunc.c b/src/backend/access/hash/hashfunc.c
index 78af6353f0ba15c417057a9004851fa8d8ee1083..80d9ac3741c01566689620526f10ce428ea9ded1 100644
--- a/src/backend/access/hash/hashfunc.c
+++ b/src/backend/access/hash/hashfunc.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.24 2000/02/21 03:36:46 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.25 2000/04/12 17:14:44 momjian Exp $
  *
  * NOTES
  *	  These functions are stored in pg_amproc.	For each operator class
@@ -146,14 +146,14 @@ hashoidvector(Oid *key)
 	int			i;
 	uint32		result = 0;
 
-	for (i = INDEX_MAX_KEYS; --i >= 0; )
+	for (i = INDEX_MAX_KEYS; --i >= 0;)
 		result = (result << 1) ^ (~(uint32) key[i]);
 	return result;
 }
 
 /*
  * Note: hashint2vector currently can't be used as a user hash table
- * hash function, because it has no pg_proc entry.  We only need it
+ * hash function, because it has no pg_proc entry.	We only need it
  * for catcache indexing.
  */
 uint32
@@ -162,7 +162,7 @@ hashint2vector(int16 *key)
 	int			i;
 	uint32		result = 0;
 
-	for (i = INDEX_MAX_KEYS; --i >= 0; )
+	for (i = INDEX_MAX_KEYS; --i >= 0;)
 		result = (result << 1) ^ (~(uint32) key[i]);
 	return result;
 }
diff --git a/src/backend/access/hash/hashscan.c b/src/backend/access/hash/hashscan.c
index d44ba69b9bd97d9ad39919d77c0224d67e08ad17..979baf8d70c72ebfab42479ee9a54ee4dbd1198e 100644
--- a/src/backend/access/hash/hashscan.c
+++ b/src/backend/access/hash/hashscan.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/hash/hashscan.c,v 1.22 2000/01/26 05:55:55 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/hash/hashscan.c,v 1.23 2000/04/12 17:14:44 momjian Exp $
  *
  * NOTES
  *	  Because we can be doing an index scan on a relation while we
@@ -75,7 +75,7 @@ _hash_dropscan(IndexScanDesc scan)
 		last = chk;
 
 	if (chk == (HashScanList) NULL)
-		elog(ERROR, "hash scan list trashed; can't find 0x%p", (void*)scan);
+		elog(ERROR, "hash scan list trashed; can't find 0x%p", (void *) scan);
 
 	if (last == (HashScanList) NULL)
 		HashScans = chk->hashsl_next;
diff --git a/src/backend/access/hash/hashsearch.c b/src/backend/access/hash/hashsearch.c
index d6ae498d19d285745c4780e46d7959eae7279804..21f45f471370e38d8dc5ca54a554d87d0674022b 100644
--- a/src/backend/access/hash/hashsearch.c
+++ b/src/backend/access/hash/hashsearch.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/hash/hashsearch.c,v 1.23 2000/03/17 02:36:02 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/hash/hashsearch.c,v 1.24 2000/04/12 17:14:44 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -351,7 +351,7 @@ _hash_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir, Buffer metabuf)
 							opaque = (HashPageOpaque) PageGetSpecialPointer(page);
 							Assert(opaque->hasho_bucket == bucket);
 							while (PageIsEmpty(page) &&
-								   BlockNumberIsValid(opaque->hasho_nextblkno))
+							 BlockNumberIsValid(opaque->hasho_nextblkno))
 								_hash_readnext(rel, &buf, &page, &opaque);
 							maxoff = PageGetMaxOffsetNumber(page);
 							offnum = FirstOffsetNumber;
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index d51705fa4726ff60cde33d7fd8f423aa8bffa8c2..29d6c9e0f9ec0208fb191a52eed1f75252f5edc9 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.66 2000/02/09 03:49:47 inoue Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.67 2000/04/12 17:14:45 momjian Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -23,7 +23,7 @@
  *		heap_fetch		- retrive tuple with tid
  *		heap_insert		- insert tuple into a relation
  *		heap_delete		- delete a tuple from a relation
- *		heap_update	- replace a tuple in a relation with another tuple
+ *		heap_update - replace a tuple in a relation with another tuple
  *		heap_markpos	- mark scan position
  *		heap_restrpos	- restore position to marked location
  *
@@ -120,9 +120,9 @@ initscan(HeapScanDesc scan,
 		 * ----------------
 		 */
 		scan->rs_ntup.t_datamcxt = scan->rs_ctup.t_datamcxt =
-		scan->rs_ptup.t_datamcxt = NULL;
+			scan->rs_ptup.t_datamcxt = NULL;
 		scan->rs_ntup.t_data = scan->rs_ctup.t_data =
-		scan->rs_ptup.t_data = NULL;
+			scan->rs_ptup.t_data = NULL;
 		scan->rs_nbuf = scan->rs_cbuf = scan->rs_pbuf = InvalidBuffer;
 	}
 	else if (atend)
@@ -188,8 +188,9 @@ unpinscan(HeapScanDesc scan)
 	if (BufferIsValid(scan->rs_nbuf))
 		ReleaseBuffer(scan->rs_nbuf);
 
-	/* we don't bother to clear rs_pbuf etc --- caller must
-	 * reinitialize them if scan descriptor is not being deleted.
+	/*
+	 * we don't bother to clear rs_pbuf etc --- caller must reinitialize
+	 * them if scan descriptor is not being deleted.
 	 */
 }
 
@@ -544,7 +545,7 @@ heap_open(Oid relationId, LOCKMODE lockmode)
 	if (lockmode == NoLock)
 		return r;				/* caller must check RelationIsValid! */
 
-	if (! RelationIsValid(r))
+	if (!RelationIsValid(r))
 		elog(ERROR, "Relation %u does not exist", relationId);
 
 	LockRelation(r, lockmode);
@@ -586,7 +587,7 @@ heap_openr(const char *relationName, LOCKMODE lockmode)
 	if (lockmode == NoLock)
 		return r;				/* caller must check RelationIsValid! */
 
-	if (! RelationIsValid(r))
+	if (!RelationIsValid(r))
 		elog(ERROR, "Relation '%s' does not exist", relationName);
 
 	LockRelation(r, lockmode);
@@ -646,7 +647,7 @@ heap_beginscan(Relation relation,
 	 *	sanity checks
 	 * ----------------
 	 */
-	if (! RelationIsValid(relation))
+	if (!RelationIsValid(relation))
 		elog(ERROR, "heap_beginscan: !RelationIsValid(relation)");
 
 	/* ----------------
@@ -659,7 +660,7 @@ heap_beginscan(Relation relation,
 	 *	Acquire AccessShareLock for the duration of the scan
 	 *
 	 *	Note: we could get an SI inval message here and consequently have
-	 *	to rebuild the relcache entry.  The refcount increment above
+	 *	to rebuild the relcache entry.	The refcount increment above
 	 *	ensures that we will rebuild it and not just flush it...
 	 * ----------------
 	 */
@@ -681,6 +682,7 @@ heap_beginscan(Relation relation,
 	scan->rs_nkeys = (short) nkeys;
 
 	if (nkeys)
+
 		/*
 		 * we do this here instead of in initscan() because heap_rescan
 		 * also calls initscan() and we don't want to allocate memory
@@ -847,9 +849,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
 
 		if (scan->rs_ptup.t_data == scan->rs_ctup.t_data &&
 			BufferIsInvalid(scan->rs_pbuf))
-		{
 			return NULL;
-		}
 
 		/*
 		 * Copy the "current" tuple/buffer to "next". Pin/unpin the
@@ -1095,8 +1095,10 @@ heap_fetch(Relation relation,
 	}
 	else
 	{
-		/* All checks passed, so return the tuple as valid.
-		 * Caller is now responsible for releasing the buffer.
+
+		/*
+		 * All checks passed, so return the tuple as valid. Caller is now
+		 * responsible for releasing the buffer.
 		 */
 		*userbuf = buffer;
 	}
@@ -1109,17 +1111,18 @@ heap_fetch(Relation relation,
  */
 ItemPointer
 heap_get_latest_tid(Relation relation,
-		   Snapshot snapshot,
-		   ItemPointer tid)
+					Snapshot snapshot,
+					ItemPointer tid)
 {
 	ItemId		lp = NULL;
 	Buffer		buffer;
 	PageHeader	dp;
-	OffsetNumber	offnum;
-	HeapTupleData	tp;
-	HeapTupleHeader	t_data;
-	ItemPointerData	ctid;
-	bool		invalidBlock,linkend;
+	OffsetNumber offnum;
+	HeapTupleData tp;
+	HeapTupleHeader t_data;
+	ItemPointerData ctid;
+	bool		invalidBlock,
+				linkend;
 
 	/* ----------------
 	 *	get the buffer from the relation descriptor
@@ -1149,11 +1152,11 @@ heap_get_latest_tid(Relation relation,
 			invalidBlock = false;
 	}
 	if (invalidBlock)
-	{	
+	{
 		LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
 		ReleaseBuffer(buffer);
 		return NULL;
-	} 
+	}
 
 	/* ----------------
 	 *	more sanity checks
@@ -1175,7 +1178,7 @@ heap_get_latest_tid(Relation relation,
 					   snapshot, 0, (ScanKey) NULL);
 
 	linkend = true;
-	if ((t_data->t_infomask & HEAP_XMAX_COMMITTED) && 
+	if ((t_data->t_infomask & HEAP_XMAX_COMMITTED) &&
 		!ItemPointerEquals(tid, &ctid))
 		linkend = false;
 
@@ -1186,7 +1189,7 @@ heap_get_latest_tid(Relation relation,
 	{
 		if (linkend)
 			return NULL;
-		return heap_get_latest_tid(relation, snapshot, &ctid); 
+		return heap_get_latest_tid(relation, snapshot, &ctid);
 	}
 
 	return tid;
@@ -1300,10 +1303,11 @@ l1:
 		LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
 		if (TransactionIdDidAbort(xwait))
 			goto l1;
-		/* 
-		 * xwait is committed but if xwait had just marked
-		 * the tuple for update then some other xaction could 
-		 * update this tuple before we got to this point.
+
+		/*
+		 * xwait is committed but if xwait had just marked the tuple for
+		 * update then some other xaction could update this tuple before
+		 * we got to this point.
 		 */
 		if (tp.t_data->t_xmax != xwait)
 			goto l1;
@@ -1345,11 +1349,11 @@ l1:
 }
 
 /*
- *	heap_update	- replace a tuple
+ *	heap_update - replace a tuple
  */
 int
 heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
-			 ItemPointer ctid)
+			ItemPointer ctid)
 {
 	ItemId		lp;
 	HeapTupleData oldtup;
@@ -1396,10 +1400,11 @@ l2:
 		LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
 		if (TransactionIdDidAbort(xwait))
 			goto l2;
-		/* 
-		 * xwait is committed but if xwait had just marked
-		 * the tuple for update then some other xaction could 
-		 * update this tuple before we got to this point.
+
+		/*
+		 * xwait is committed but if xwait had just marked the tuple for
+		 * update then some other xaction could update this tuple before
+		 * we got to this point.
 		 */
 		if (oldtup.t_data->t_xmax != xwait)
 			goto l2;
@@ -1521,10 +1526,11 @@ l3:
 		LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
 		if (TransactionIdDidAbort(xwait))
 			goto l3;
-		/* 
-		 * xwait is committed but if xwait had just marked
-		 * the tuple for update then some other xaction could 
-		 * update this tuple before we got to this point.
+
+		/*
+		 * xwait is committed but if xwait had just marked the tuple for
+		 * update then some other xaction could update this tuple before
+		 * we got to this point.
 		 */
 		if (tuple->t_data->t_xmax != xwait)
 			goto l3;
diff --git a/src/backend/access/heap/hio.c b/src/backend/access/heap/hio.c
index b269ca90170c0eb3f1610df05533cc8452e4666f..3fc2a69df1a3fe914c9ee30418bda41cbad593b0 100644
--- a/src/backend/access/heap/hio.c
+++ b/src/backend/access/heap/hio.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Id: hio.c,v 1.30 2000/03/17 02:36:02 tgl Exp $
+ *	  $Id: hio.c,v 1.31 2000/04/12 17:14:45 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -51,7 +51,7 @@ RelationPutHeapTuple(Relation relation,
 	IncrHeapAccessStat(global_RelationPutHeapTuple);
 
 	pageHeader = (Page) BufferGetPage(buffer);
-	len = MAXALIGN(tuple->t_len); /* be conservative */
+	len = MAXALIGN(tuple->t_len);		/* be conservative */
 	Assert(len <= PageGetFreeSpace(pageHeader));
 
 	offnum = PageAddItem((Page) pageHeader, (Item) tuple->t_data,
@@ -108,11 +108,11 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple)
 	ItemId		itemId;
 	Item		item;
 
-	len = MAXALIGN(tuple->t_len); /* be conservative */
+	len = MAXALIGN(tuple->t_len);		/* be conservative */
 
 	/*
-	 * If we're gonna fail for oversize tuple, do it right away...
-	 * this code should go away eventually.
+	 * If we're gonna fail for oversize tuple, do it right away... this
+	 * code should go away eventually.
 	 */
 	if (len > MaxTupleSize)
 		elog(ERROR, "Tuple is too big: size %u, max size %ld",
@@ -136,8 +136,8 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple)
 	lastblock = RelationGetNumberOfBlocks(relation);
 
 	/*
-	 * Get the last existing page --- may need to create the first one
-	 * if this is a virgin relation.
+	 * Get the last existing page --- may need to create the first one if
+	 * this is a virgin relation.
 	 */
 	if (lastblock == 0)
 	{
@@ -168,12 +168,14 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple)
 
 		if (len > PageGetFreeSpace(pageHeader))
 		{
+
 			/*
-			 * BUG: by elog'ing here, we leave the new buffer locked and not
-			 * marked dirty, which may result in an invalid page header
-			 * being left on disk.  But we should not get here given the
-			 * test at the top of the routine, and the whole deal should
-			 * go away when we implement tuple splitting anyway...
+			 * BUG: by elog'ing here, we leave the new buffer locked and
+			 * not marked dirty, which may result in an invalid page
+			 * header being left on disk.  But we should not get here
+			 * given the test at the top of the routine, and the whole
+			 * deal should go away when we implement tuple splitting
+			 * anyway...
 			 */
 			elog(ERROR, "Tuple is too big: size %u", len);
 		}
diff --git a/src/backend/access/heap/tuptoaster.c b/src/backend/access/heap/tuptoaster.c
index 9176521a5fce192811badda304a4fb70dd787e76..3aadfb2cde08c44b2665333c844616c6d82af574 100644
--- a/src/backend/access/heap/tuptoaster.c
+++ b/src/backend/access/heap/tuptoaster.c
@@ -2,13 +2,13 @@
  *
  * tuptoaster.c
  *	  Support routines for external and compressed storage of
- *    variable size attributes.
+ *	  variable size attributes.
  *
  * Copyright (c) 2000, PostgreSQL Global Development Group
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.2 2000/01/20 21:50:59 petere Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.3 2000/04/12 17:14:45 momjian Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -30,17 +30,17 @@
 #ifdef TUPLE_TOASTER_ACTIVE
 
 void
-heap_tuple_toast_attrs (Relation rel, HeapTuple newtup, HeapTuple oldtup)
+heap_tuple_toast_attrs(Relation rel, HeapTuple newtup, HeapTuple oldtup)
 {
 	return;
 }
 
 
-varattrib *
-heap_tuple_untoast_attr (varattrib *attr)
+varattrib  *
+heap_tuple_untoast_attr(varattrib * attr)
 {
 	elog(ERROR, "heap_tuple_untoast_attr() called");
 }
 
 
-#endif /* TUPLE_TOASTER_ACTIVE */
+#endif	 /* TUPLE_TOASTER_ACTIVE */
diff --git a/src/backend/access/index/genam.c b/src/backend/access/index/genam.c
index 1bd02f839ad42236df3bdd5e1966495c7cc470f8..3530320637b016172d5817857e5cd6dfe2f575d3 100644
--- a/src/backend/access/index/genam.c
+++ b/src/backend/access/index/genam.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.24 2000/03/14 23:52:01 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.25 2000/04/12 17:14:47 momjian Exp $
  *
  * NOTES
  *	  many of the old access method routines have been turned into
@@ -62,7 +62,7 @@
  *
  *		At the end of a scan, the AM's endscan routine undoes the locking,
  *		but does *not* call IndexScanEnd --- the higher-level index_endscan
- *		routine does that.  (We can't do it in the AM because index_endscan
+ *		routine does that.	(We can't do it in the AM because index_endscan
  *		still needs to touch the IndexScanDesc after calling the AM.)
  *
  *		Because of this, the AM does not have a choice whether to call
@@ -114,7 +114,10 @@ RelationGetIndexScan(Relation relation,
 	ItemPointerSetInvalid(&scan->currentMarkData);
 	ItemPointerSetInvalid(&scan->nextMarkData);
 
-	/* mark cached function lookup data invalid; it will be set on first use */
+	/*
+	 * mark cached function lookup data invalid; it will be set on first
+	 * use
+	 */
 	scan->fn_getnext.fn_oid = InvalidOid;
 
 	if (numberOfKeys > 0)
diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c
index 2335693119829d6fc289c165b1b57b41361f6f72..e0672667c7fbba99d2a58950f13719351e5810f9 100644
--- a/src/backend/access/index/indexam.c
+++ b/src/backend/access/index/indexam.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.41 2000/03/14 23:52:01 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.42 2000/04/12 17:14:47 momjian Exp $
  *
  * INTERFACE ROUTINES
  *		index_open		- open an index relation by relationId
@@ -115,10 +115,10 @@
  *		index_open - open an index relation by relationId
  *
  *		presently the relcache routines do all the work we need
- *		to open/close index relations.  However, callers of index_open
+ *		to open/close index relations.	However, callers of index_open
  *		expect it to succeed, so we need to check for a failure return.
  *
- *		Note: we acquire no lock on the index.  An AccessShareLock is
+ *		Note: we acquire no lock on the index.	An AccessShareLock is
  *		acquired by index_beginscan (and released by index_endscan).
  * ----------------
  */
@@ -129,7 +129,7 @@ index_open(Oid relationId)
 
 	r = RelationIdGetRelation(relationId);
 
-	if (! RelationIsValid(r))
+	if (!RelationIsValid(r))
 		elog(ERROR, "Index %u does not exist", relationId);
 
 	if (r->rd_rel->relkind != RELKIND_INDEX)
@@ -151,7 +151,7 @@ index_openr(char *relationName)
 
 	r = RelationNameGetRelation(relationName);
 
-	if (! RelationIsValid(r))
+	if (!RelationIsValid(r))
 		elog(ERROR, "Index '%s' does not exist", relationName);
 
 	if (r->rd_rel->relkind != RELKIND_INDEX)
@@ -238,7 +238,7 @@ index_beginscan(Relation relation,
 	 *	Acquire AccessShareLock for the duration of the scan
 	 *
 	 *	Note: we could get an SI inval message here and consequently have
-	 *	to rebuild the relcache entry.  The refcount increment above
+	 *	to rebuild the relcache entry.	The refcount increment above
 	 *	ensures that we will rebuild it and not just flush it...
 	 * ----------------
 	 */
diff --git a/src/backend/access/index/istrat.c b/src/backend/access/index/istrat.c
index fe956ead378aa133c6bc8650239103283b4712ce..b0864e505fac99084e40a3fd33304d7b97044854 100644
--- a/src/backend/access/index/istrat.c
+++ b/src/backend/access/index/istrat.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.41 2000/02/18 09:29:16 inoue Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.42 2000/04/12 17:14:47 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -477,7 +477,7 @@ OperatorRelationFillScanKeyEntry(Relation operatorRelation,
 {
 	HeapTuple	tuple;
 	HeapScanDesc scan = NULL;
-	bool	cachesearch = (!IsBootstrapProcessingMode()) && IsCacheInitialized();
+	bool		cachesearch = (!IsBootstrapProcessingMode()) && IsCacheInitialized();
 
 	if (cachesearch)
 	{
@@ -547,7 +547,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy,
 	AttrNumber	attributeNumber;
 	int			attributeIndex;
 	Oid			operatorClassObjectId[INDEX_MAX_KEYS];
-	bool	cachesearch = (!IsBootstrapProcessingMode()) && IsCacheInitialized();
+	bool		cachesearch = (!IsBootstrapProcessingMode()) && IsCacheInitialized();
 
 	if (cachesearch)
 	{
@@ -674,7 +674,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy,
 			aform = (Form_pg_amop) GETSTRUCT(tuple);
 			OperatorRelationFillScanKeyEntry(operatorRelation,
 											 aform->amopopr,
-					StrategyMapGetScanKeyEntry(map, aform->amopstrategy));
+				   StrategyMapGetScanKeyEntry(map, aform->amopstrategy));
 		}
 
 		heap_endscan(scan);
diff --git a/src/backend/access/nbtree/nbtcompare.c b/src/backend/access/nbtree/nbtcompare.c
index f66b9a0e8e24c79b97446d74d5f80b258374cea9..3e58c677a0082b7ab5c8567065c5ea8ade420f8f 100644
--- a/src/backend/access/nbtree/nbtcompare.c
+++ b/src/backend/access/nbtree/nbtcompare.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.33 2000/02/10 19:51:38 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.34 2000/04/12 17:14:49 momjian Exp $
  *
  *	NOTES
  *		These functions are stored in pg_amproc.  For each operator class
@@ -35,12 +35,12 @@ btint2cmp(int16 a, int16 b)
 int32
 btint4cmp(int32 a, int32 b)
 {
-      if (a > b)
-              return 1;
-      else if (a == b)
-              return 0;
-      else
-              return -1;
+	if (a > b)
+		return 1;
+	else if (a == b)
+		return 0;
+	else
+		return -1;
 }
 
 int32
diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c
index b891716a895bec4d02c71a01acec233f274d7ce1..975b53d658ac0a803bbe713722b8afa283be7fdc 100644
--- a/src/backend/access/nbtree/nbtinsert.c
+++ b/src/backend/access/nbtree/nbtinsert.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.56 2000/03/17 02:36:03 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.57 2000/04/12 17:14:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -21,10 +21,10 @@
 
 static InsertIndexResult _bt_insertonpg(Relation rel, Buffer buf, BTStack stack, int keysz, ScanKey scankey, BTItem btitem, BTItem afteritem);
 static Buffer _bt_split(Relation rel, Size keysz, ScanKey scankey,
-						Buffer buf, OffsetNumber firstright);
+		  Buffer buf, OffsetNumber firstright);
 static OffsetNumber _bt_findsplitloc(Relation rel, Size keysz, ScanKey scankey,
-									 Page page, OffsetNumber start,
-									 OffsetNumber maxoff, Size llimit);
+				 Page page, OffsetNumber start,
+				 OffsetNumber maxoff, Size llimit);
 static void _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf);
 static OffsetNumber _bt_pgaddtup(Relation rel, Buffer buf, int keysz, ScanKey itup_scankey, Size itemsize, BTItem btitem, BTItem afteritem);
 static bool _bt_goesonpg(Relation rel, Buffer buf, Size keysz, ScanKey scankey, BTItem afteritem);
@@ -267,21 +267,20 @@ _bt_insertonpg(Relation rel,
 	itemsz = IndexTupleDSize(btitem->bti_itup)
 		+ (sizeof(BTItemData) - sizeof(IndexTupleData));
 
-	itemsz = MAXALIGN(itemsz);		/* be safe, PageAddItem will do
-										 * this but we need to be
-										 * consistent */
+	itemsz = MAXALIGN(itemsz);	/* be safe, PageAddItem will do this but
+								 * we need to be consistent */
 
 	/*
-	 * Check whether the item can fit on a btree page at all.
-	 * (Eventually, we ought to try to apply TOAST methods if not.)
-	 * We actually need to be able to fit three items on every page,
-	 * so restrict any one item to 1/3 the per-page available space.
-	 * Note that at this point, itemsz doesn't include the ItemId.
+	 * Check whether the item can fit on a btree page at all. (Eventually,
+	 * we ought to try to apply TOAST methods if not.) We actually need to
+	 * be able to fit three items on every page, so restrict any one item
+	 * to 1/3 the per-page available space. Note that at this point,
+	 * itemsz doesn't include the ItemId.
 	 */
-	if (itemsz > (PageGetPageSize(page)-sizeof(PageHeaderData)-MAXALIGN(sizeof(BTPageOpaqueData)))/3 - sizeof(ItemIdData))
+	if (itemsz > (PageGetPageSize(page) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) / 3 - sizeof(ItemIdData))
 		elog(ERROR, "btree: index item size %u exceeds maximum %lu",
 			 itemsz,
-			 (PageGetPageSize(page)-sizeof(PageHeaderData)-MAXALIGN(sizeof(BTPageOpaqueData)))/3 - sizeof(ItemIdData));
+			 (PageGetPageSize(page) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) /3 - sizeof(ItemIdData));
 
 	/*
 	 * If we have to insert item on the leftmost page which is the first
@@ -415,8 +414,8 @@ _bt_insertonpg(Relation rel,
 		bool		is_root = lpageop->btpo_flags & BTP_ROOT;
 
 		/*
-		 * Instead of splitting leaf page in the chain of duplicates 
-		 * by new duplicate, insert it into some right page.
+		 * Instead of splitting leaf page in the chain of duplicates by
+		 * new duplicate, insert it into some right page.
 		 */
 		if ((lpageop->btpo_flags & BTP_CHAIN) &&
 			(lpageop->btpo_flags & BTP_LEAF) && keys_equal)
@@ -424,8 +423,9 @@ _bt_insertonpg(Relation rel,
 			rbuf = _bt_getbuf(rel, lpageop->btpo_next, BT_WRITE);
 			rpage = BufferGetPage(rbuf);
 			rpageop = (BTPageOpaque) PageGetSpecialPointer(rpage);
-			/* 
-			 * some checks 
+
+			/*
+			 * some checks
 			 */
 			if (!P_RIGHTMOST(rpageop))	/* non-rightmost page */
 			{					/* If we have the same hikey here then
@@ -442,6 +442,7 @@ _bt_insertonpg(Relation rel,
 									 BTGreaterStrategyNumber))
 					elog(FATAL, "btree: hikey is out of order");
 				else if (rpageop->btpo_flags & BTP_CHAIN)
+
 					/*
 					 * If hikey > scankey then it's last page in chain and
 					 * BTP_CHAIN must be OFF
@@ -450,9 +451,7 @@ _bt_insertonpg(Relation rel,
 			}
 			else
 /* rightmost page */
-			{
 				Assert(!(rpageop->btpo_flags & BTP_CHAIN));
-			}
 			_bt_relbuf(rel, buf, BT_WRITE);
 			return (_bt_insertonpg(rel, rbuf, stack, keysz,
 								   scankey, btitem, afteritem));
@@ -708,7 +707,7 @@ l_spl:	;
 				 */
 				if (!parent_chained &&
 					MAXALIGN(IndexTupleDSize(lowLeftItem->bti_itup)) ==
-					MAXALIGN(IndexTupleDSize(stack->bts_btitem->bti_itup)))
+				  MAXALIGN(IndexTupleDSize(stack->bts_btitem->bti_itup)))
 				{
 					_bt_updateitem(rel, keysz, pbuf,
 								   stack->bts_btitem, lowLeftItem);
diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c
index 60eaf3a9d23f84277f2a2ca2b14b86061dfd42fe..1a623698f57c34711c62225384e7c73feb510281 100644
--- a/src/backend/access/nbtree/nbtpage.c
+++ b/src/backend/access/nbtree/nbtpage.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.35 2000/01/26 05:55:58 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.36 2000/04/12 17:14:49 momjian Exp $
  *
  *	NOTES
  *	   Postgres btree pages look like ordinary relation pages.	The opaque
@@ -257,7 +257,7 @@ _bt_getroot(Relation rel, int access)
 	else
 	{
 		rootblkno = metad->btm_root;
-		_bt_relbuf(rel, metabuf, BT_READ);	/* done with the meta page */
+		_bt_relbuf(rel, metabuf, BT_READ);		/* done with the meta page */
 
 		rootbuf = _bt_getbuf(rel, rootblkno, access);
 	}
diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c
index da5dd70332e5b07a5552b309a98d52828298f684..72969d4d1b79b4729d3bd41aa508ebf6c5476ddd 100644
--- a/src/backend/access/nbtree/nbtree.c
+++ b/src/backend/access/nbtree/nbtree.c
@@ -12,7 +12,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.53 2000/02/18 09:29:54 inoue Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.54 2000/04/12 17:14:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -77,7 +77,7 @@ btbuild(Relation heap,
 #endif
 	Node	   *pred,
 			   *oldPred;
-	BTSpool	   *spool = NULL;
+	BTSpool    *spool = NULL;
 	bool		isunique;
 	bool		usefast;
 
@@ -185,7 +185,7 @@ btbuild(Relation heap,
 #ifndef OMIT_PARTIAL_INDEX
 			/* SetSlotContents(slot, htup); */
 			slot->val = htup;
-			if (! ExecQual((List *) pred, econtext, false))
+			if (!ExecQual((List *) pred, econtext, false))
 				continue;
 #endif	 /* OMIT_PARTIAL_INDEX */
 		}
@@ -276,9 +276,9 @@ btbuild(Relation heap,
 	}
 
 	/*
-	 * if we are doing bottom-up btree build, finish the build by
-	 * (1) completing the sort of the spool file, (2) inserting the
-	 * sorted tuples into btree pages and (3) building the upper levels.
+	 * if we are doing bottom-up btree build, finish the build by (1)
+	 * completing the sort of the spool file, (2) inserting the sorted
+	 * tuples into btree pages and (3) building the upper levels.
 	 */
 	if (usefast)
 	{
@@ -298,26 +298,27 @@ btbuild(Relation heap,
 	/*
 	 * Since we just counted the tuples in the heap, we update its stats
 	 * in pg_class to guarantee that the planner takes advantage of the
-	 * index we just created.  But, only update statistics during
-	 * normal index definitions, not for indices on system catalogs
-	 * created during bootstrap processing.  We must close the relations
-	 * before updating statistics to guarantee that the relcache entries
-	 * are flushed when we increment the command counter in UpdateStats().
-	 * But we do not release any locks on the relations; those will be
-	 * held until end of transaction.
+	 * index we just created.  But, only update statistics during normal
+	 * index definitions, not for indices on system catalogs created
+	 * during bootstrap processing.  We must close the relations before
+	 * updating statistics to guarantee that the relcache entries are
+	 * flushed when we increment the command counter in UpdateStats(). But
+	 * we do not release any locks on the relations; those will be held
+	 * until end of transaction.
 	 */
 	if (IsNormalProcessingMode())
 	{
-		Oid		hrelid = RelationGetRelid(heap);
-		Oid		irelid = RelationGetRelid(index);
+		Oid			hrelid = RelationGetRelid(heap);
+		Oid			irelid = RelationGetRelid(index);
 		bool		inplace = IsReindexProcessing();
 
 		heap_close(heap, NoLock);
 		index_close(index);
+
 		/*
-		UpdateStats(hrelid, nhtups, true);
-		UpdateStats(irelid, nitups, false);
-		*/
+		 * UpdateStats(hrelid, nhtups, true); UpdateStats(irelid, nitups,
+		 * false);
+		 */
 		UpdateStats(hrelid, nhtups, inplace);
 		UpdateStats(irelid, nitups, inplace);
 		if (oldPred != NULL)
@@ -623,7 +624,7 @@ _bt_restscan(IndexScanDesc scan)
 	BTItem		item;
 	BlockNumber blkno;
 
-	LockBuffer(buf, BT_READ);		/* lock buffer first! */
+	LockBuffer(buf, BT_READ);	/* lock buffer first! */
 	page = BufferGetPage(buf);
 	maxoff = PageGetMaxOffsetNumber(page);
 	opaque = (BTPageOpaque) PageGetSpecialPointer(page);
diff --git a/src/backend/access/nbtree/nbtscan.c b/src/backend/access/nbtree/nbtscan.c
index 95b1bf53ecbf8d332345927fdf7fd1592122c8fe..37469365bcd42e2b37c06346341d6a9bdf9e95ab 100644
--- a/src/backend/access/nbtree/nbtscan.c
+++ b/src/backend/access/nbtree/nbtscan.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.30 2000/01/26 05:55:58 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.31 2000/04/12 17:14:49 momjian Exp $
  *
  *
  * NOTES
@@ -52,13 +52,16 @@ static void _bt_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offn
 void
 AtEOXact_nbtree(void)
 {
-	/* Note: these actions should only be necessary during xact abort;
-	 * but they can't hurt during a commit.
+
+	/*
+	 * Note: these actions should only be necessary during xact abort; but
+	 * they can't hurt during a commit.
 	 */
 
-	/* Reset the active-scans list to empty.
-	 * We do not need to free the list elements, because they're all
-	 * palloc()'d, so they'll go away at end of transaction anyway.
+	/*
+	 * Reset the active-scans list to empty. We do not need to free the
+	 * list elements, because they're all palloc()'d, so they'll go away
+	 * at end of transaction anyway.
 	 */
 	BTScans = NULL;
 
@@ -96,7 +99,7 @@ _bt_dropscan(IndexScanDesc scan)
 		last = chk;
 
 	if (chk == (BTScanList) NULL)
-		elog(ERROR, "btree scan list trashed; can't find 0x%p", (void*)scan);
+		elog(ERROR, "btree scan list trashed; can't find 0x%p", (void *) scan);
 
 	if (last == (BTScanList) NULL)
 		BTScans = chk->btsl_next;
diff --git a/src/backend/access/nbtree/nbtsearch.c b/src/backend/access/nbtree/nbtsearch.c
index f36da9743f852f577e5b0b672dee82ec7c16e745..cad117e5e6174f239764079d3679ef90c2b61157 100644
--- a/src/backend/access/nbtree/nbtsearch.c
+++ b/src/backend/access/nbtree/nbtsearch.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.58 2000/03/17 02:36:04 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.59 2000/04/12 17:14:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -299,9 +299,7 @@ _bt_skeycmp(Relation rel,
 			compare = -1;		/* not-NULL key "<" NULL datum */
 		}
 		else
-		{
 			compare = (int32) FMGR_PTR2(&entry->sk_func, keyDatum, attrDatum);
-		}
 
 		if (compare != 0)
 			break;				/* done when we find unequal attributes */
@@ -368,26 +366,26 @@ _bt_binsrch(Relation rel,
 
 	/*
 	 * If there are no keys on the page, return the first available slot.
-	 * Note this covers two cases: the page is really empty (no keys),
-	 * or it contains only a high key.  The latter case is possible after
+	 * Note this covers two cases: the page is really empty (no keys), or
+	 * it contains only a high key.  The latter case is possible after
 	 * vacuuming.
 	 */
 	if (high < low)
 		return low;
 
 	/*
-	 * Binary search to find the first key on the page >= scan key.
-	 * Loop invariant: all slots before 'low' are < scan key, all slots
-	 * at or after 'high' are >= scan key.  Also, haveEq is true if the
-	 * tuple at 'high' is == scan key.
-	 * We can fall out when high == low.
+	 * Binary search to find the first key on the page >= scan key. Loop
+	 * invariant: all slots before 'low' are < scan key, all slots at or
+	 * after 'high' are >= scan key.  Also, haveEq is true if the tuple at
+	 * 'high' is == scan key. We can fall out when high == low.
 	 */
 	high++;						/* establish the loop invariant for high */
 	haveEq = false;
 
 	while (high > low)
 	{
-		OffsetNumber	mid = low + ((high - low) / 2);
+		OffsetNumber mid = low + ((high - low) / 2);
+
 		/* We have low <= mid < high, so mid points at a real slot */
 
 		result = _bt_compare(rel, itupdesc, page, keysz, scankey, mid);
@@ -403,7 +401,7 @@ _bt_binsrch(Relation rel,
 
 	/*--------------------
 	 * At this point we have high == low, but be careful: they could point
-	 * past the last slot on the page.  We also know that haveEq is true
+	 * past the last slot on the page.	We also know that haveEq is true
 	 * if and only if there is an equal key (in which case high&low point
 	 * at the first equal key).
 	 *
@@ -443,18 +441,20 @@ _bt_binsrch(Relation rel,
 
 	if (haveEq)
 	{
+
 		/*
 		 * There is an equal key.  We return either the first equal key
 		 * (which we just found), or the last lesser key.
 		 *
-		 * We need not check srchtype != BT_DESCENT here, since if that
-		 * is true then natts == keysz by assumption.
+		 * We need not check srchtype != BT_DESCENT here, since if that is
+		 * true then natts == keysz by assumption.
 		 */
 		if (natts == keysz)
 			return low;			/* return first equal key */
 	}
 	else
 	{
+
 		/*
 		 * There is no equal key.  We return either the first greater key
 		 * (which we just found), or the last lesser key.
@@ -524,6 +524,7 @@ _bt_compare(Relation rel,
 		&& P_LEFTMOST(opaque)
 		&& offnum == P_HIKEY)
 	{
+
 		/*
 		 * we just have to believe that this will only be called with
 		 * offnum == P_HIKEY when P_HIKEY is the OffsetNumber of the first
@@ -702,11 +703,12 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
 
 	bool		strategyCheck;
 	ScanKey		scankeys = 0;
-	int		keysCount = 0;
-	int		*nKeyIs = 0;
-	int		i, j;
-	StrategyNumber	strat_total;
-       
+	int			keysCount = 0;
+	int		   *nKeyIs = 0;
+	int			i,
+				j;
+	StrategyNumber strat_total;
+
 	rel = scan->relation;
 	so = (BTScanOpaque) scan->opaque;
 
@@ -723,15 +725,15 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
 		_bt_orderkeys(rel, so);
 
 		if (so->qual_ok)
-		     strategyCheck = true;
- 	}
+			strategyCheck = true;
+	}
 	strat_total = BTEqualStrategyNumber;
 	if (strategyCheck)
 	{
 		AttrNumber	attno;
 
-		nKeyIs = (int *)palloc(so->numberOfKeys*sizeof(int));
-		for (i=0; i < so->numberOfKeys; i++)
+		nKeyIs = (int *) palloc(so->numberOfKeys * sizeof(int));
+		for (i = 0; i < so->numberOfKeys; i++)
 		{
 			attno = so->keyData[i].sk_attno;
 			if (attno == keysCount)
@@ -739,16 +741,16 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
 			if (attno > keysCount + 1)
 				break;
 			strat = _bt_getstrat(rel, attno,
-					so->keyData[i].sk_procedure);
+								 so->keyData[i].sk_procedure);
 			if (strat == strat_total ||
-			    strat == BTEqualStrategyNumber)
+				strat == BTEqualStrategyNumber)
 			{
 				nKeyIs[keysCount++] = i;
 				continue;
 			}
 			if (ScanDirectionIsBackward(dir) &&
-			    (strat == BTLessStrategyNumber ||
-			     strat == BTLessEqualStrategyNumber) )
+				(strat == BTLessStrategyNumber ||
+				 strat == BTLessEqualStrategyNumber))
 			{
 				nKeyIs[keysCount++] = i;
 				strat_total = strat;
@@ -757,8 +759,8 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
 				continue;
 			}
 			if (ScanDirectionIsForward(dir) &&
-			    (strat == BTGreaterStrategyNumber ||
-			     strat == BTGreaterEqualStrategyNumber) )
+				(strat == BTGreaterStrategyNumber ||
+				 strat == BTGreaterEqualStrategyNumber))
 			{
 				nKeyIs[keysCount++] = i;
 				strat_total = strat;
@@ -794,8 +796,8 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
 	 * at the right place in the scan.
 	 */
 	/* _bt_orderkeys disallows it, but it's place to add some code latter */
-	scankeys = (ScanKey)palloc(keysCount*sizeof(ScanKeyData));
-	for (i=0; i < keysCount; i++)
+	scankeys = (ScanKey) palloc(keysCount * sizeof(ScanKeyData));
+	for (i = 0; i < keysCount; i++)
 	{
 		j = nKeyIs[i];
 		if (so->keyData[j].sk_flags & SK_ISNULL)
@@ -804,12 +806,13 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
 			pfree(scankeys);
 			elog(ERROR, "_bt_first: btree doesn't support is(not)null, yet");
 			return ((RetrieveIndexResult) NULL);
-		} 
-		proc = index_getprocid(rel, i+1, BTORDER_PROC);
-		ScanKeyEntryInitialize(scankeys+i, so->keyData[j].sk_flags,
-				i+1, proc, so->keyData[j].sk_argument);
+		}
+		proc = index_getprocid(rel, i + 1, BTORDER_PROC);
+		ScanKeyEntryInitialize(scankeys + i, so->keyData[j].sk_flags,
+							   i + 1, proc, so->keyData[j].sk_argument);
 	}
-	if   (nKeyIs)	pfree(nKeyIs);
+	if (nKeyIs)
+		pfree(nKeyIs);
 
 	stack = _bt_search(rel, keysCount, scankeys, &buf);
 	_bt_freestack(stack);
diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c
index f9cbf7121ff4fb078723e226e6e81255dbbc3d48..65e757e42b3b176ab7560768ed980e0d500d0d44 100644
--- a/src/backend/access/nbtree/nbtsort.c
+++ b/src/backend/access/nbtree/nbtsort.c
@@ -6,7 +6,7 @@
  *
  * We use tuplesort.c to sort the given index tuples into order.
  * Then we scan the index tuples in order and build the btree pages
- * for each level.  When we have only one page on a level, it must be the
+ * for each level.	When we have only one page on a level, it must be the
  * root -- it can be attached to the btree metapage and we are done.
  *
  * this code is moderately slow (~10% slower) compared to the regular
@@ -28,7 +28,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.51 2000/02/18 06:32:39 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.52 2000/04/12 17:14:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -70,12 +70,12 @@ struct BTSpool
 
 static void _bt_load(Relation index, BTSpool *btspool);
 static BTItem _bt_buildadd(Relation index, Size keysz, ScanKey scankey,
-						   BTPageState *state, BTItem bti, int flags);
+			 BTPageState *state, BTItem bti, int flags);
 static BTItem _bt_minitem(Page opage, BlockNumber oblkno, int atend);
 static BTPageState *_bt_pagestate(Relation index, int flags,
-								  int level, bool doupper);
+			  int level, bool doupper);
 static void _bt_uppershutdown(Relation index, Size keysz, ScanKey scankey,
-							  BTPageState *state);
+				  BTPageState *state);
 
 
 /*
@@ -86,7 +86,7 @@ static void _bt_uppershutdown(Relation index, Size keysz, ScanKey scankey,
 /*
  * create and initialize a spool structure
  */
-BTSpool *
+BTSpool    *
 _bt_spoolinit(Relation index, bool isunique)
 {
 	BTSpool    *btspool = (BTSpool *) palloc(sizeof(BTSpool));
@@ -99,9 +99,9 @@ _bt_spoolinit(Relation index, bool isunique)
 	btspool->sortstate = tuplesort_begin_index(index, isunique, false);
 
 	/*
-	 * Currently, tuplesort provides sort functions on IndexTuples.
-	 * If we kept anything in a BTItem other than a regular IndexTuple,
-	 * we'd need to modify tuplesort to understand BTItems as such.
+	 * Currently, tuplesort provides sort functions on IndexTuples. If we
+	 * kept anything in a BTItem other than a regular IndexTuple, we'd
+	 * need to modify tuplesort to understand BTItems as such.
 	 */
 	Assert(sizeof(BTItemData) == sizeof(IndexTupleData));
 
@@ -306,20 +306,20 @@ _bt_buildadd(Relation index, Size keysz, ScanKey scankey,
 	btisz = MAXALIGN(btisz);
 
 	/*
-	 * Check whether the item can fit on a btree page at all.
-	 * (Eventually, we ought to try to apply TOAST methods if not.)
-	 * We actually need to be able to fit three items on every page,
-	 * so restrict any one item to 1/3 the per-page available space.
-	 * Note that at this point, btisz doesn't include the ItemId.
+	 * Check whether the item can fit on a btree page at all. (Eventually,
+	 * we ought to try to apply TOAST methods if not.) We actually need to
+	 * be able to fit three items on every page, so restrict any one item
+	 * to 1/3 the per-page available space. Note that at this point, btisz
+	 * doesn't include the ItemId.
 	 *
 	 * NOTE: similar code appears in _bt_insertonpg() to defend against
-	 * oversize items being inserted into an already-existing index.
-	 * But during creation of an index, we don't go through there.
+	 * oversize items being inserted into an already-existing index. But
+	 * during creation of an index, we don't go through there.
 	 */
-	if (btisz > (PageGetPageSize(npage)-sizeof(PageHeaderData)-MAXALIGN(sizeof(BTPageOpaqueData)))/3 - sizeof(ItemIdData))
+	if (btisz > (PageGetPageSize(npage) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) / 3 - sizeof(ItemIdData))
 		elog(ERROR, "btree: index item size %d exceeds maximum %ld",
 			 btisz,
-			 (PageGetPageSize(npage)-sizeof(PageHeaderData)-MAXALIGN(sizeof(BTPageOpaqueData)))/3 - sizeof(ItemIdData));
+			 (PageGetPageSize(npage) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) /3 - sizeof(ItemIdData));
 
 	if (pgspc < btisz)
 	{
diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c
index 9d1cc7b10d0531f07d566b8847f56bc2f28e4a7d..38b152e61b28b214fa6c3a2afd848bf94fdfc7a7 100644
--- a/src/backend/access/nbtree/nbtutils.c
+++ b/src/backend/access/nbtree/nbtutils.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.35 2000/02/18 06:32:39 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.36 2000/04/12 17:14:50 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -141,7 +141,8 @@ _bt_orderkeys(Relation relation, BTScanOpaque so)
 	uint16		numberOfKeys = so->numberOfKeys;
 	uint16		new_numberOfKeys = 0;
 	AttrNumber	attno = 1;
-	bool		equalStrategyEnd, underEqualStrategy;
+	bool		equalStrategyEnd,
+				underEqualStrategy;
 
 	if (numberOfKeys < 1)
 		return;
@@ -194,6 +195,7 @@ _bt_orderkeys(Relation relation, BTScanOpaque so)
 				elog(ERROR, "_bt_orderkeys: key(s) for attribute %d missed", attno + 1);
 
 			underEqualStrategy = (!equalStrategyEnd);
+
 			/*
 			 * If = has been specified, no other key will be used. In case
 			 * of key < 2 && key == 1 and so on we have to set qual_ok to
diff --git a/src/backend/access/rtree/rtree.c b/src/backend/access/rtree/rtree.c
index 34cf0b6c9370e1d038d232b744871a2fdfda717e..53e5345a55d75f38219b800ee45ed82ff8e546c8 100644
--- a/src/backend/access/rtree/rtree.c
+++ b/src/backend/access/rtree/rtree.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.44 2000/03/01 05:39:23 inoue Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.45 2000/04/12 17:14:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -181,7 +181,7 @@ rtbuild(Relation heap,
 #ifndef OMIT_PARTIAL_INDEX
 			/* SetSlotContents(slot, htup); */
 			slot->val = htup;
-			if (! ExecQual((List *) pred, econtext, false))
+			if (!ExecQual((List *) pred, econtext, false))
 				continue;
 #endif	 /* OMIT_PARTIAL_INDEX */
 		}
@@ -249,18 +249,18 @@ rtbuild(Relation heap,
 	/*
 	 * Since we just counted the tuples in the heap, we update its stats
 	 * in pg_class to guarantee that the planner takes advantage of the
-	 * index we just created.  But, only update statistics during
-	 * normal index definitions, not for indices on system catalogs
-	 * created during bootstrap processing.  We must close the relations
-	 * before updating statistics to guarantee that the relcache entries
-	 * are flushed when we increment the command counter in UpdateStats().
-	 * But we do not release any locks on the relations; those will be
-	 * held until end of transaction.
+	 * index we just created.  But, only update statistics during normal
+	 * index definitions, not for indices on system catalogs created
+	 * during bootstrap processing.  We must close the relations before
+	 * updating statistics to guarantee that the relcache entries are
+	 * flushed when we increment the command counter in UpdateStats(). But
+	 * we do not release any locks on the relations; those will be held
+	 * until end of transaction.
 	 */
 	if (IsNormalProcessingMode())
 	{
-		Oid		hrelid = RelationGetRelid(heap);
-		Oid		irelid = RelationGetRelid(index);
+		Oid			hrelid = RelationGetRelid(heap);
+		Oid			irelid = RelationGetRelid(index);
 		bool		inplace = IsReindexProcessing();
 
 		heap_close(heap, NoLock);
diff --git a/src/backend/access/rtree/rtscan.c b/src/backend/access/rtree/rtscan.c
index ada386127788ed34e07403737d34b440c93f5f20..71e2acf5f88d0be5cf97e28763afa50a57a0ecbf 100644
--- a/src/backend/access/rtree/rtscan.c
+++ b/src/backend/access/rtree/rtscan.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.31 2000/01/26 05:56:00 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.32 2000/04/12 17:14:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -268,7 +268,7 @@ rtdropscan(IndexScanDesc s)
 		prev = l;
 
 	if (l == (RTScanList) NULL)
-		elog(ERROR, "rtree scan list corrupted -- cannot find 0x%p", (void*)s);
+		elog(ERROR, "rtree scan list corrupted -- cannot find 0x%p", (void *) s);
 
 	if (prev == (RTScanList) NULL)
 		RTScans = l->rtsl_next;
diff --git a/src/backend/access/transam/rmgr.c b/src/backend/access/transam/rmgr.c
index 36d50f08c0c32937d908c6a6ee2957a7d1da03a9..4efb53ea08c1ac14729c484f51f6dc9701e5b430 100644
--- a/src/backend/access/transam/rmgr.c
+++ b/src/backend/access/transam/rmgr.c
@@ -1,4 +1,4 @@
 #include "postgres.h"
 #include "access/rmgr.h"
 
-RmgrData	   *RmgrTable = NULL;
+RmgrData   *RmgrTable = NULL;
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index a5af2bdc533a43810bd4c5f081c4f59ed805c859..acca4a901a2f16083d1eff601ec4647046d1b527 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.33 2000/01/26 05:56:03 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.34 2000/04/12 17:14:52 momjian Exp $
  *
  * NOTES
  *	  This file contains the high level access-method interface to the
@@ -162,6 +162,7 @@ TransactionLogTest(TransactionId transactionId, /* transaction id to test */
 
 	if (!fail)
 	{
+
 		/*
 		 * DO NOT cache status for transactions in unknown state !!!
 		 */
diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c
index 6a31bfe429ecc50feea01380d44646a721069707..5ce334aa299682048c966bc19bc859fa8df0e24e 100644
--- a/src/backend/access/transam/varsup.c
+++ b/src/backend/access/transam/varsup.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.27 2000/03/31 02:43:31 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.28 2000/04/12 17:14:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -331,8 +331,8 @@ ReadNewTransactionId(TransactionId *xid)
 	SpinAcquire(OidGenLockId);	/* not good for concurrency... */
 
 	/*
-	 * Note that we don't check is ShmemVariableCache->xid_count equal
-	 * to 0 or not. This will work as long as we don't call 
+	 * Note that we don't check is ShmemVariableCache->xid_count equal to
+	 * 0 or not. This will work as long as we don't call
 	 * ReadNewTransactionId() before GetNewTransactionId().
 	 */
 	if (ShmemVariableCache->nextXid == 0)
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index 2522cca46c12296a4abfe76bc6391c120fede8ae..688741511fbaa8b280972b41cf95eac3da3c4f88 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.63 2000/04/09 04:43:16 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.64 2000/04/12 17:14:53 momjian Exp $
  *
  * NOTES
  *		Transaction aborts can now occur two ways:
@@ -160,7 +160,7 @@
 #include "utils/portal.h"
 #include "utils/relcache.h"
 
-extern bool	SharedBufferChanged;
+extern bool SharedBufferChanged;
 
 static void AbortTransaction(void);
 static void AtAbort_Cache(void);
@@ -517,8 +517,8 @@ CommandCounterIncrement()
 	CurrentTransactionStateData.scanCommandId = CurrentTransactionStateData.commandId;
 
 	/*
-	 * make cache changes visible to me.  AtCommit_LocalCache()
-	 * instead of AtCommit_Cache() is called here.
+	 * make cache changes visible to me.  AtCommit_LocalCache() instead of
+	 * AtCommit_Cache() is called here.
 	 */
 	AtCommit_LocalCache();
 	AtStart_Cache();
@@ -627,16 +627,15 @@ RecordTransactionCommit()
 	 */
 	xid = GetCurrentTransactionId();
 
-	/* 
-	 *	flush the buffer manager pages.  Note: if we have stable
-	 *	main memory, dirty shared buffers are not flushed
-	 *	plai 8/7/90
+	/*
+	 * flush the buffer manager pages.	Note: if we have stable main
+	 * memory, dirty shared buffers are not flushed plai 8/7/90
 	 */
 	leak = BufferPoolCheckLeak();
 
 	/*
-	 * If no one shared buffer was changed by this transaction then
-	 * we don't flush shared buffers and don't record commit status.
+	 * If no one shared buffer was changed by this transaction then we
+	 * don't flush shared buffers and don't record commit status.
 	 */
 	if (SharedBufferChanged)
 	{
@@ -645,13 +644,13 @@ RecordTransactionCommit()
 			ResetBufferPool(true);
 
 		/*
-		 *	have the transaction access methods record the status
-		 *	of this transaction id in the pg_log relation.
+		 * have the transaction access methods record the status of this
+		 * transaction id in the pg_log relation.
 		 */
 		TransactionIdCommit(xid);
 
 		/*
-		 *	Now write the log info to the disk too.
+		 * Now write the log info to the disk too.
 		 */
 		leak = BufferPoolCheckLeak();
 		FlushBufferPool();
@@ -751,10 +750,10 @@ RecordTransactionAbort()
 	 */
 	xid = GetCurrentTransactionId();
 
-	/* 
-	 * Have the transaction access methods record the status of
-	 * this transaction id in the pg_log relation. We skip it
-	 * if no one shared buffer was changed by this transaction.
+	/*
+	 * Have the transaction access methods record the status of this
+	 * transaction id in the pg_log relation. We skip it if no one shared
+	 * buffer was changed by this transaction.
 	 */
 	if (SharedBufferChanged && !TransactionIdDidCommit(xid))
 		TransactionIdAbort(xid);
@@ -936,7 +935,7 @@ CommitTransaction()
 	/* ----------------
 	 *	Tell the trigger manager that this transaction is about to be
 	 *	committed. He'll invoke all trigger deferred until XACT before
-	 *	we really start on committing the transaction. 
+	 *	we really start on committing the transaction.
 	 * ----------------
 	 */
 	DeferredTriggerEndXact();
@@ -965,13 +964,13 @@ CommitTransaction()
 	RecordTransactionCommit();
 
 	/*
-	 * Let others know about no transaction in progress by me.
-	 * Note that this must be done _before_ releasing locks we hold 
-	 * and SpinAcquire(SInvalLock) is required: UPDATE with xid 0 is 
-	 * blocked by xid 1' UPDATE, xid 1 is doing commit while xid 2 
-	 * gets snapshot - if xid 2' GetSnapshotData sees xid 1 as running
-	 * then it must see xid 0 as running as well or it will see two
-	 * tuple versions - one deleted by xid 1 and one inserted by xid 0.
+	 * Let others know about no transaction in progress by me. Note that
+	 * this must be done _before_ releasing locks we hold and
+	 * SpinAcquire(SInvalLock) is required: UPDATE with xid 0 is blocked
+	 * by xid 1' UPDATE, xid 1 is doing commit while xid 2 gets snapshot -
+	 * if xid 2' GetSnapshotData sees xid 1 as running then it must see
+	 * xid 0 as running as well or it will see two tuple versions - one
+	 * deleted by xid 1 and one inserted by xid 0.
 	 */
 	if (MyProc != (PROC *) NULL)
 	{
@@ -995,7 +994,7 @@ CommitTransaction()
 	 * ----------------
 	 */
 	s->state = TRANS_DEFAULT;
-	SharedBufferChanged = false;	/* safest place to do it */
+	SharedBufferChanged = false;/* safest place to do it */
 
 }
 
@@ -1031,7 +1030,7 @@ AbortTransaction()
 
 	/* ----------------
 	 *	Tell the trigger manager that this transaction is about to be
-	 *	aborted. 
+	 *	aborted.
 	 * ----------------
 	 */
 	DeferredTriggerAbortXact();
@@ -1070,7 +1069,7 @@ AbortTransaction()
 	 * ----------------
 	 */
 	s->state = TRANS_DEFAULT;
-	SharedBufferChanged = false;	/* safest place to do it */
+	SharedBufferChanged = false;/* safest place to do it */
 }
 
 /* --------------------------------
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 7d197cb5a3a36b89e0dfa6fe35c308facc887a55..b672cf2c7a9621fbab60fa58ae37870be2e06718 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -1,4 +1,4 @@
-/*------------------------------------------------------------------------- 
+/*-------------------------------------------------------------------------
  *
  * xlog.c
  *
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.12 2000/03/20 07:25:39 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.13 2000/04/12 17:14:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -44,64 +44,64 @@ bool		StopIfError = false;
 SPINLOCK	ControlFileLockId;
 SPINLOCK	XidGenLockId;
 
-extern bool				ReleaseDataFile(void);
+extern bool ReleaseDataFile(void);
 
-extern VariableCache	ShmemVariableCache;
+extern VariableCache ShmemVariableCache;
 
-#define	MinXLOGbuffers	4
+#define MinXLOGbuffers	4
 
 typedef struct XLgwrRqst
 {
-	XLogRecPtr		Write;		/* byte (1-based) to write out */
-	XLogRecPtr		Flush;		/* byte (1-based) to flush */
+	XLogRecPtr	Write;			/* byte (1-based) to write out */
+	XLogRecPtr	Flush;			/* byte (1-based) to flush */
 } XLgwrRqst;
 
 typedef struct XLgwrResult
 {
-	XLogRecPtr		Write;		/* bytes written out */
-	XLogRecPtr		Flush;		/* bytes flushed */
+	XLogRecPtr	Write;			/* bytes written out */
+	XLogRecPtr	Flush;			/* bytes flushed */
 } XLgwrResult;
 
 typedef struct XLogCtlInsert
 {
-	XLgwrResult		LgwrResult;
-	XLogRecPtr		PrevRecord;
-	uint16			curridx;	/* current block index in cache */
-	XLogPageHeader	currpage;
-	char		   *currpos;
+	XLgwrResult LgwrResult;
+	XLogRecPtr	PrevRecord;
+	uint16		curridx;		/* current block index in cache */
+	XLogPageHeader currpage;
+	char	   *currpos;
 } XLogCtlInsert;
 
 typedef struct XLogCtlWrite
 {
-	XLgwrResult		LgwrResult;
-	uint16			curridx;	/* index of next block to write */
+	XLgwrResult LgwrResult;
+	uint16		curridx;		/* index of next block to write */
 } XLogCtlWrite;
 
 
 #ifndef HAS_TEST_AND_SET
-#define	TAS(lck)		0
-#define	S_UNLOCK(lck)
-#define	S_INIT_LOCK(lck)
+#define TAS(lck)		0
+#define S_UNLOCK(lck)
+#define S_INIT_LOCK(lck)
 #endif
 
 typedef struct XLogCtlData
 {
-	XLogCtlInsert	Insert;
-	XLgwrRqst		LgwrRqst;
-	XLgwrResult		LgwrResult;
-	XLogCtlWrite	Write;
-	char		   *pages;
-	XLogRecPtr	   *xlblocks;	/* 1st byte ptr-s + BLCKSZ */
-	uint32			XLogCacheByte;
-	uint32			XLogCacheBlck;
+	XLogCtlInsert Insert;
+	XLgwrRqst	LgwrRqst;
+	XLgwrResult LgwrResult;
+	XLogCtlWrite Write;
+	char	   *pages;
+	XLogRecPtr *xlblocks;		/* 1st byte ptr-s + BLCKSZ */
+	uint32		XLogCacheByte;
+	uint32		XLogCacheBlck;
 #ifdef HAS_TEST_AND_SET
-	slock_t			insert_lck;
-	slock_t			info_lck;
-	slock_t			lgwr_lck;
+	slock_t		insert_lck;
+	slock_t		info_lck;
+	slock_t		lgwr_lck;
 #endif
 } XLogCtlData;
 
-static XLogCtlData		   *XLogCtl = NULL;
+static XLogCtlData *XLogCtl = NULL;
 
 typedef enum DBState
 {
@@ -114,69 +114,69 @@ typedef enum DBState
 
 typedef struct ControlFileData
 {
-	uint32			logId;			/* current log file id */
-	uint32			logSeg;			/* current log file segment (1-based) */
-	XLogRecPtr		checkPoint;		/* last check point record ptr */
-	time_t			time;			/* time stamp of last modification */
-	DBState			state;			/* */
+	uint32		logId;			/* current log file id */
+	uint32		logSeg;			/* current log file segment (1-based) */
+	XLogRecPtr	checkPoint;		/* last check point record ptr */
+	time_t		time;			/* time stamp of last modification */
+	DBState		state;			/* */
 
 	/*
-	 * this data is used to make sure that configuration of this DB
-	 * is compatible with the current backend
+	 * this data is used to make sure that configuration of this DB is
+	 * compatible with the current backend
 	 */
-	uint32			blcksz;			/* block size for this DB */
-	uint32			relseg_size;	/* blocks per segment of large relation */
-	uint32			catalog_version_no;	/* internal version number */
+	uint32		blcksz;			/* block size for this DB */
+	uint32		relseg_size;	/* blocks per segment of large relation */
+	uint32		catalog_version_no;		/* internal version number */
 
 	/*
-	 * MORE DATA FOLLOWS AT THE END OF THIS STRUCTURE
-	 * - locations of data dirs 
+	 * MORE DATA FOLLOWS AT THE END OF THIS STRUCTURE - locations of data
+	 * dirs
 	 */
 } ControlFileData;
 
-static ControlFileData	   *ControlFile = NULL;
+static ControlFileData *ControlFile = NULL;
 
 typedef struct CheckPoint
 {
-	XLogRecPtr		redo;		/* next RecPtr available when we */
-								/* began to create CheckPoint */
-								/* (i.e. REDO start point) */
-	XLogRecPtr		undo;		/* first record of oldest in-progress */
-								/* transaction when we started */
-								/* (i.e. UNDO end point) */
-	TransactionId	nextXid;
-	Oid				nextOid;
+	XLogRecPtr	redo;			/* next RecPtr available when we */
+	/* began to create CheckPoint */
+	/* (i.e. REDO start point) */
+	XLogRecPtr	undo;			/* first record of oldest in-progress */
+	/* transaction when we started */
+	/* (i.e. UNDO end point) */
+	TransactionId nextXid;
+	Oid			nextOid;
 } CheckPoint;
 
-/* 
- * We break each log file in 16Mb segments 
+/*
+ * We break each log file in 16Mb segments
  */
 #define XLogSegSize		(16*1024*1024)
-#define	XLogLastSeg		(0xffffffff / XLogSegSize)
-#define	XLogFileSize	(XLogLastSeg * XLogSegSize)
+#define XLogLastSeg		(0xffffffff / XLogSegSize)
+#define XLogFileSize	(XLogLastSeg * XLogSegSize)
 
-#define	XLogFileName(path, log, seg)	\
+#define XLogFileName(path, log, seg)	\
 			snprintf(path, MAXPGPATH, "%s%c%08X%08X",	\
 					 XLogDir, SEP_CHAR, log, seg)
 
-#define	PrevBufIdx(curridx)		\
+#define PrevBufIdx(curridx)		\
 		((curridx == 0) ? XLogCtl->XLogCacheBlck : (curridx - 1))
 
-#define	NextBufIdx(curridx)		\
+#define NextBufIdx(curridx)		\
 		((curridx == XLogCtl->XLogCacheBlck) ? 0 : (curridx + 1))
 
-#define	XLByteLT(left, right)		\
+#define XLByteLT(left, right)		\
 			(right.xlogid > left.xlogid || \
 			(right.xlogid == left.xlogid && right.xrecoff > left.xrecoff))
 
-#define	XLByteLE(left, right)		\
+#define XLByteLE(left, right)		\
 			(right.xlogid > left.xlogid || \
 			(right.xlogid == left.xlogid && right.xrecoff >=  left.xrecoff))
 
-#define	XLByteEQ(left, right)		\
+#define XLByteEQ(left, right)		\
 			(right.xlogid == left.xlogid && right.xrecoff ==  left.xrecoff)
 
-#define	InitXLBuffer(curridx)	(\
+#define InitXLBuffer(curridx)	(\
 				XLogCtl->xlblocks[curridx].xrecoff = \
 				(XLogCtl->xlblocks[Insert->curridx].xrecoff == XLogFileSize) ? \
 				BLCKSZ : (XLogCtl->xlblocks[Insert->curridx].xrecoff + BLCKSZ), \
@@ -192,46 +192,46 @@ typedef struct CheckPoint
 				Insert->currpage->xlp_info = 0 \
 				)
 
-#define	XRecOffIsValid(xrecoff)	\
+#define XRecOffIsValid(xrecoff) \
 		(xrecoff % BLCKSZ >= SizeOfXLogPHD && \
 		(BLCKSZ - xrecoff % BLCKSZ) >= SizeOfXLogRecord)
 
-static void				GetFreeXLBuffer(void);
-static void				XLogWrite(char *buffer);
-static int				XLogFileInit(uint32 log, uint32 seg);
-static int				XLogFileOpen(uint32 log, uint32 seg, bool econt);
-static XLogRecord	   *ReadRecord(XLogRecPtr *RecPtr, char *buffer);
-static char			   *str_time(time_t tnow);
-
-static XLgwrResult		LgwrResult = {{0, 0}, {0, 0}};
-static XLgwrRqst		LgwrRqst = {{0, 0}, {0, 0}};
-
-static int				logFile = -1;
-static uint32			logId = 0;
-static uint32			logSeg = 0;
-static uint32			logOff = 0;
-
-static XLogRecPtr		ReadRecPtr;
-static XLogRecPtr		EndRecPtr;
-static int				readFile = -1;
-static uint32			readId = 0;
-static uint32			readSeg = 0;
-static uint32			readOff = 0;
-static char				readBuf[BLCKSZ];
-static XLogRecord	   *nextRecord = NULL;
+static void GetFreeXLBuffer(void);
+static void XLogWrite(char *buffer);
+static int	XLogFileInit(uint32 log, uint32 seg);
+static int	XLogFileOpen(uint32 log, uint32 seg, bool econt);
+static XLogRecord *ReadRecord(XLogRecPtr *RecPtr, char *buffer);
+static char *str_time(time_t tnow);
+
+static XLgwrResult LgwrResult = {{0, 0}, {0, 0}};
+static XLgwrRqst LgwrRqst = {{0, 0}, {0, 0}};
+
+static int	logFile = -1;
+static uint32 logId = 0;
+static uint32 logSeg = 0;
+static uint32 logOff = 0;
+
+static XLogRecPtr ReadRecPtr;
+static XLogRecPtr EndRecPtr;
+static int	readFile = -1;
+static uint32 readId = 0;
+static uint32 readSeg = 0;
+static uint32 readOff = 0;
+static char readBuf[BLCKSZ];
+static XLogRecord *nextRecord = NULL;
 
 XLogRecPtr
 XLogInsert(RmgrId rmid, char *hdr, uint32 hdrlen, char *buf, uint32 buflen)
 {
-	XLogCtlInsert	   *Insert = &XLogCtl->Insert;
-	XLogRecord		   *record;
-	XLogSubRecord	   *subrecord;
-	XLogRecPtr			RecPtr;
-	uint32				len = hdrlen + buflen,
-						freespace,
-						wlen;
-	uint16				curridx;
-	bool				updrqst = false;
+	XLogCtlInsert *Insert = &XLogCtl->Insert;
+	XLogRecord *record;
+	XLogSubRecord *subrecord;
+	XLogRecPtr	RecPtr;
+	uint32		len = hdrlen + buflen,
+				freespace,
+				wlen;
+	uint16		curridx;
+	bool		updrqst = false;
 
 	if (len == 0 || len > MAXLOGRECSZ)
 		elog(STOP, "XLogInsert: invalid record len %u", len);
@@ -242,7 +242,7 @@ XLogInsert(RmgrId rmid, char *hdr, uint32 hdrlen, char *buf, uint32 buflen)
 		bool		do_lgwr = true;
 		unsigned	i = 0;
 
-		for ( ; ; )
+		for (;;)
 		{
 			/* try to read LgwrResult while waiting for insert lock */
 			if (!TAS(&(XLogCtl->info_lck)))
@@ -250,14 +250,15 @@ XLogInsert(RmgrId rmid, char *hdr, uint32 hdrlen, char *buf, uint32 buflen)
 				LgwrRqst = XLogCtl->LgwrRqst;
 				LgwrResult = XLogCtl->LgwrResult;
 				S_UNLOCK(&(XLogCtl->info_lck));
+
 				/*
 				 * If cache is half filled then try to acquire lgwr lock
 				 * and do LGWR work, but only once.
 				 */
-				if (do_lgwr && 
-					(LgwrRqst.Write.xlogid != LgwrResult.Write.xlogid || 
-					(LgwrRqst.Write.xrecoff - LgwrResult.Write.xrecoff >=
-					XLogCtl->XLogCacheByte / 2)))
+				if (do_lgwr &&
+					(LgwrRqst.Write.xlogid != LgwrResult.Write.xlogid ||
+					 (LgwrRqst.Write.xrecoff - LgwrResult.Write.xrecoff >=
+					  XLogCtl->XLogCacheByte / 2)))
 				{
 					if (!TAS(&(XLogCtl->lgwr_lck)))
 					{
@@ -282,13 +283,13 @@ XLogInsert(RmgrId rmid, char *hdr, uint32 hdrlen, char *buf, uint32 buflen)
 		}
 	}
 
-	freespace = ((char*) Insert->currpage) + BLCKSZ - Insert->currpos;
+	freespace = ((char *) Insert->currpage) + BLCKSZ - Insert->currpos;
 	if (freespace < SizeOfXLogRecord)
 	{
 		curridx = NextBufIdx(Insert->curridx);
 		if (XLByteLE(XLogCtl->xlblocks[curridx], LgwrResult.Write))
 			InitXLBuffer(curridx);
-		else 
+		else
 			GetFreeXLBuffer();
 		freespace = BLCKSZ - SizeOfXLogPHD;
 	}
@@ -296,7 +297,7 @@ XLogInsert(RmgrId rmid, char *hdr, uint32 hdrlen, char *buf, uint32 buflen)
 		curridx = Insert->curridx;
 
 	freespace -= SizeOfXLogRecord;
-	record = (XLogRecord*) Insert->currpos;
+	record = (XLogRecord *) Insert->currpos;
 	record->xl_prev = Insert->PrevRecord;
 	if (rmid != RM_XLOG_ID)
 		record->xl_xact_prev = MyLastRecPtr;
@@ -310,9 +311,9 @@ XLogInsert(RmgrId rmid, char *hdr, uint32 hdrlen, char *buf, uint32 buflen)
 	record->xl_info = (len > freespace) ? XLR_TO_BE_CONTINUED : 0;
 	record->xl_rmid = rmid;
 	RecPtr.xlogid = XLogCtl->xlblocks[curridx].xlogid;
-	RecPtr.xrecoff = 
-		XLogCtl->xlblocks[curridx].xrecoff - BLCKSZ + 
-		Insert->currpos - ((char*) Insert->currpage);
+	RecPtr.xrecoff =
+		XLogCtl->xlblocks[curridx].xrecoff - BLCKSZ +
+		Insert->currpos - ((char *) Insert->currpage);
 	if (MyLastRecPtr.xrecoff == 0 && rmid != RM_XLOG_ID)
 	{
 		SpinAcquire(SInvalLock);
@@ -339,8 +340,8 @@ XLogInsert(RmgrId rmid, char *hdr, uint32 hdrlen, char *buf, uint32 buflen)
 			buf += wlen;
 			Insert->currpos += wlen;
 		}
-		Insert->currpos = ((char*)Insert->currpage) + 
-					DOUBLEALIGN(Insert->currpos - ((char*)Insert->currpage));
+		Insert->currpos = ((char *) Insert->currpage) +
+			DOUBLEALIGN(Insert->currpos - ((char *) Insert->currpage));
 		len = hdrlen + buflen;
 	}
 
@@ -360,7 +361,7 @@ nbuf:
 		}
 		freespace = BLCKSZ - SizeOfXLogPHD - SizeOfXLogSubRecord;
 		Insert->currpage->xlp_info |= XLP_FIRST_IS_SUBRECORD;
-		subrecord = (XLogSubRecord*) Insert->currpos;
+		subrecord = (XLogSubRecord *) Insert->currpos;
 		Insert->currpos += SizeOfXLogSubRecord;
 		if (hdrlen > freespace)
 		{
@@ -398,17 +399,19 @@ nbuf:
 		}
 		subrecord->xl_info = 0;
 		RecPtr.xlogid = XLogCtl->xlblocks[curridx].xlogid;
-		RecPtr.xrecoff = XLogCtl->xlblocks[curridx].xrecoff - 
-				BLCKSZ + SizeOfXLogPHD + subrecord->xl_len;
-		Insert->currpos = ((char*)Insert->currpage) + 
-					DOUBLEALIGN(Insert->currpos - ((char*)Insert->currpage));
+		RecPtr.xrecoff = XLogCtl->xlblocks[curridx].xrecoff -
+			BLCKSZ + SizeOfXLogPHD + subrecord->xl_len;
+		Insert->currpos = ((char *) Insert->currpage) +
+			DOUBLEALIGN(Insert->currpos - ((char *) Insert->currpage));
 	}
-	freespace = ((char*) Insert->currpage) + BLCKSZ - Insert->currpos;
+	freespace = ((char *) Insert->currpage) + BLCKSZ - Insert->currpos;
+
 	/*
 	 * All done! Update global LgwrRqst if some block was filled up.
 	 */
 	if (freespace < SizeOfXLogRecord)
-		updrqst = true;		/* curridx is filled and available for writing out */
+		updrqst = true;			/* curridx is filled and available for
+								 * writing out */
 	else
 		curridx = PrevBufIdx(curridx);
 	LgwrRqst.Write = XLogCtl->xlblocks[curridx];
@@ -419,7 +422,7 @@ nbuf:
 	{
 		unsigned	i = 0;
 
-		for ( ; ; )
+		for (;;)
 		{
 			if (!TAS(&(XLogCtl->info_lck)))
 			{
@@ -433,21 +436,21 @@ nbuf:
 	}
 
 	return (RecPtr);
-}	
+}
 
 void
 XLogFlush(XLogRecPtr record)
 {
-	XLogRecPtr		WriteRqst;
-	char			buffer[BLCKSZ];
-	char		   *usebuf = NULL;
-	unsigned		i = 0;
-	bool			force_lgwr = false;
+	XLogRecPtr	WriteRqst;
+	char		buffer[BLCKSZ];
+	char	   *usebuf = NULL;
+	unsigned	i = 0;
+	bool		force_lgwr = false;
 
 	if (XLByteLE(record, LgwrResult.Flush))
 		return;
 	WriteRqst = LgwrRqst.Write;
-	for ( ; ; )
+	for (;;)
 	{
 		/* try to read LgwrResult */
 		if (!TAS(&(XLogCtl->info_lck)))
@@ -470,9 +473,9 @@ XLogFlush(XLogRecPtr record)
 		/* if something was added to log cache then try to flush this too */
 		if (!TAS(&(XLogCtl->insert_lck)))
 		{
-			XLogCtlInsert	   *Insert = &XLogCtl->Insert;
-			uint32				freespace = 
-					((char*) Insert->currpage) + BLCKSZ - Insert->currpos;
+			XLogCtlInsert *Insert = &XLogCtl->Insert;
+			uint32		freespace =
+			((char *) Insert->currpage) + BLCKSZ - Insert->currpos;
 
 			if (freespace < SizeOfXLogRecord)	/* buffer is full */
 			{
@@ -485,14 +488,14 @@ XLogFlush(XLogRecPtr record)
 				memcpy(usebuf, Insert->currpage, BLCKSZ - freespace);
 				memset(usebuf + BLCKSZ - freespace, 0, freespace);
 				WriteRqst = XLogCtl->xlblocks[Insert->curridx];
-				WriteRqst.xrecoff = WriteRqst.xrecoff - BLCKSZ + 
-						Insert->currpos - ((char*) Insert->currpage);
+				WriteRqst.xrecoff = WriteRqst.xrecoff - BLCKSZ +
+					Insert->currpos - ((char *) Insert->currpage);
 			}
 			S_UNLOCK(&(XLogCtl->insert_lck));
 			force_lgwr = true;
 		}
-		if (force_lgwr || WriteRqst.xlogid > record.xlogid || 
-			(WriteRqst.xlogid == record.xlogid && 
+		if (force_lgwr || WriteRqst.xlogid > record.xlogid ||
+			(WriteRqst.xlogid == record.xlogid &&
 			 WriteRqst.xrecoff >= record.xrecoff + BLCKSZ))
 		{
 			if (!TAS(&(XLogCtl->lgwr_lck)))
@@ -518,12 +521,12 @@ XLogFlush(XLogRecPtr record)
 		s_lock_sleep(i++);
 	}
 
-	if (logFile >= 0 && (LgwrResult.Write.xlogid != logId || 
-		(LgwrResult.Write.xrecoff - 1) / XLogSegSize != logSeg))
+	if (logFile >= 0 && (LgwrResult.Write.xlogid != logId ||
+				 (LgwrResult.Write.xrecoff - 1) / XLogSegSize != logSeg))
 	{
 		if (close(logFile) != 0)
-			elog(STOP, "Close(logfile %u seg %u) failed: %d", 
-						logId, logSeg, errno);
+			elog(STOP, "Close(logfile %u seg %u) failed: %d",
+				 logId, logSeg, errno);
 		logFile = -1;
 	}
 
@@ -536,11 +539,11 @@ XLogFlush(XLogRecPtr record)
 	}
 
 	if (fsync(logFile) != 0)
-		elog(STOP, "Fsync(logfile %u seg %u) failed: %d", 
-					logId, logSeg, errno);
+		elog(STOP, "Fsync(logfile %u seg %u) failed: %d",
+			 logId, logSeg, errno);
 	LgwrResult.Flush = LgwrResult.Write;
 
-	for (i = 0; ; )
+	for (i = 0;;)
 	{
 		if (!TAS(&(XLogCtl->info_lck)))
 		{
@@ -562,12 +565,12 @@ XLogFlush(XLogRecPtr record)
 static void
 GetFreeXLBuffer()
 {
-	XLogCtlInsert	   *Insert = &XLogCtl->Insert;
-	XLogCtlWrite	   *Write = &XLogCtl->Write;
-	uint16				curridx = NextBufIdx(Insert->curridx);
+	XLogCtlInsert *Insert = &XLogCtl->Insert;
+	XLogCtlWrite *Write = &XLogCtl->Write;
+	uint16		curridx = NextBufIdx(Insert->curridx);
 
 	LgwrRqst.Write = XLogCtl->xlblocks[Insert->curridx];
-	for ( ; ; )
+	for (;;)
 	{
 		if (!TAS(&(XLogCtl->info_lck)))
 		{
@@ -581,6 +584,7 @@ GetFreeXLBuffer()
 				return;
 			}
 		}
+
 		/*
 		 * LgwrResult lock is busy or un-updated. Try to acquire lgwr lock
 		 * and write full blocks.
@@ -595,9 +599,10 @@ GetFreeXLBuffer()
 				InitXLBuffer(curridx);
 				return;
 			}
-			/* 
-			 * Have to write buffers while holding insert lock -
-			 * not good...
+
+			/*
+			 * Have to write buffers while holding insert lock - not
+			 * good...
 			 */
 			XLogWrite(NULL);
 			S_UNLOCK(&(XLogCtl->lgwr_lck));
@@ -613,22 +618,22 @@ GetFreeXLBuffer()
 static void
 XLogWrite(char *buffer)
 {
-	XLogCtlWrite   *Write = &XLogCtl->Write;
-	char		   *from;
-	uint32			wcnt = 0;
-	int				i = 0;
+	XLogCtlWrite *Write = &XLogCtl->Write;
+	char	   *from;
+	uint32		wcnt = 0;
+	int			i = 0;
 
-	for ( ; XLByteLT(LgwrResult.Write,	LgwrRqst.Write); )
+	for (; XLByteLT(LgwrResult.Write, LgwrRqst.Write);)
 	{
 		LgwrResult.Write = XLogCtl->xlblocks[Write->curridx];
-		if (LgwrResult.Write.xlogid != logId || 
+		if (LgwrResult.Write.xlogid != logId ||
 			(LgwrResult.Write.xrecoff - 1) / XLogSegSize != logSeg)
 		{
 			if (wcnt > 0)
 			{
 				if (fsync(logFile) != 0)
-					elog(STOP, "Fsync(logfile %u seg %u) failed: %d", 
-								logId, logSeg, errno);
+					elog(STOP, "Fsync(logfile %u seg %u) failed: %d",
+						 logId, logSeg, errno);
 				if (LgwrResult.Write.xlogid != logId)
 					LgwrResult.Flush.xrecoff = XLogFileSize;
 				else
@@ -648,8 +653,8 @@ XLogWrite(char *buffer)
 			if (logFile >= 0)
 			{
 				if (close(logFile) != 0)
-					elog(STOP, "Close(logfile %u seg %u) failed: %d", 
-								logId, logSeg, errno);
+					elog(STOP, "Close(logfile %u seg %u) failed: %d",
+						 logId, logSeg, errno);
 				logFile = -1;
 			}
 			logId = LgwrResult.Write.xlogid;
@@ -675,9 +680,9 @@ XLogWrite(char *buffer)
 		if (logOff != (LgwrResult.Write.xrecoff - BLCKSZ) % XLogSegSize)
 		{
 			logOff = (LgwrResult.Write.xrecoff - BLCKSZ) % XLogSegSize;
-			if (lseek(logFile, (off_t)logOff, SEEK_SET) < 0)
-				elog(STOP, "Lseek(logfile %u seg %u off %u) failed: %d", 
-							logId, logSeg, logOff, errno);
+			if (lseek(logFile, (off_t) logOff, SEEK_SET) < 0)
+				elog(STOP, "Lseek(logfile %u seg %u off %u) failed: %d",
+					 logId, logSeg, logOff, errno);
 		}
 
 		if (buffer != NULL && XLByteLT(LgwrRqst.Write, LgwrResult.Write))
@@ -686,8 +691,8 @@ XLogWrite(char *buffer)
 			from = XLogCtl->pages + Write->curridx * BLCKSZ;
 
 		if (write(logFile, from, BLCKSZ) != BLCKSZ)
-			elog(STOP, "Write(logfile %u seg %u off %u) failed: %d", 
-						logId, logSeg, logOff, errno);
+			elog(STOP, "Write(logfile %u seg %u off %u) failed: %d",
+				 logId, logSeg, logOff, errno);
 
 		wcnt++;
 		logOff += BLCKSZ;
@@ -700,16 +705,16 @@ XLogWrite(char *buffer)
 	if (wcnt == 0)
 		elog(STOP, "XLogWrite: nothing written");
 
-	if (XLByteLT(LgwrResult.Flush, LgwrRqst.Flush) && 
+	if (XLByteLT(LgwrResult.Flush, LgwrRqst.Flush) &&
 		XLByteLE(LgwrRqst.Flush, LgwrResult.Write))
 	{
 		if (fsync(logFile) != 0)
-			elog(STOP, "Fsync(logfile %u seg %u) failed: %d", 
-						logId, logSeg, errno);
+			elog(STOP, "Fsync(logfile %u seg %u) failed: %d",
+				 logId, logSeg, errno);
 		LgwrResult.Flush = LgwrResult.Write;
 	}
 
-	for ( ; ; )
+	for (;;)
 	{
 		if (!TAS(&(XLogCtl->info_lck)))
 		{
@@ -727,54 +732,54 @@ XLogWrite(char *buffer)
 static int
 XLogFileInit(uint32 log, uint32 seg)
 {
-	char	path[MAXPGPATH];
-	int		fd;
+	char		path[MAXPGPATH];
+	int			fd;
 
 	XLogFileName(path, log, seg);
 	unlink(path);
 
 tryAgain:
 #ifndef __CYGWIN__
-	fd = open(path, O_RDWR|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR);
+	fd = open(path, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
 #else
-	fd = open(path, O_RDWR|O_CREAT|O_EXCL|O_BINARY, S_IRUSR|S_IWUSR);
+	fd = open(path, O_RDWR | O_CREAT | O_EXCL | O_BINARY, S_IRUSR | S_IWUSR);
 #endif
 	if (fd < 0 && (errno == EMFILE || errno == ENFILE))
 	{
 		fd = errno;
 		if (!ReleaseDataFile())
-			elog(STOP, "Create(logfile %u seg %u) failed: %d (and no one data file can be closed)", 
-						logId, logSeg, fd);
+			elog(STOP, "Create(logfile %u seg %u) failed: %d (and no one data file can be closed)",
+				 logId, logSeg, fd);
 		goto tryAgain;
 	}
 	if (fd < 0)
-		elog(STOP, "Init(logfile %u seg %u) failed: %d", 
-					logId, logSeg, errno);
+		elog(STOP, "Init(logfile %u seg %u) failed: %d",
+			 logId, logSeg, errno);
 
 	if (lseek(fd, XLogSegSize - 1, SEEK_SET) != (off_t) (XLogSegSize - 1))
-		elog(STOP, "Lseek(logfile %u seg %u) failed: %d", 
-					logId, logSeg, errno);
+		elog(STOP, "Lseek(logfile %u seg %u) failed: %d",
+			 logId, logSeg, errno);
 
 	if (write(fd, "", 1) != 1)
-		elog(STOP, "Init(logfile %u seg %u) failed: %d", 
-					logId, logSeg, errno);
+		elog(STOP, "Init(logfile %u seg %u) failed: %d",
+			 logId, logSeg, errno);
 
 	if (fsync(fd) != 0)
-		elog(STOP, "Fsync(logfile %u seg %u) failed: %d", 
-					logId, logSeg, errno);
+		elog(STOP, "Fsync(logfile %u seg %u) failed: %d",
+			 logId, logSeg, errno);
 
 	if (lseek(fd, 0, SEEK_SET) < 0)
-			elog(STOP, "Lseek(logfile %u seg %u off %u) failed: %d", 
-						log, seg, 0, errno);
+		elog(STOP, "Lseek(logfile %u seg %u off %u) failed: %d",
+			 log, seg, 0, errno);
 
-	return(fd);
+	return (fd);
 }
 
 static int
 XLogFileOpen(uint32 log, uint32 seg, bool econt)
 {
-	char	path[MAXPGPATH];
-	int		fd;
+	char		path[MAXPGPATH];
+	int			fd;
 
 	XLogFileName(path, log, seg);
 
@@ -788,8 +793,8 @@ tryAgain:
 	{
 		fd = errno;
 		if (!ReleaseDataFile())
-			elog(STOP, "Open(logfile %u seg %u) failed: %d (and no one data file can be closed)", 
-						logId, logSeg, fd);
+			elog(STOP, "Open(logfile %u seg %u) failed: %d (and no one data file can be closed)",
+				 logId, logSeg, fd);
 		goto tryAgain;
 	}
 	if (fd < 0)
@@ -797,24 +802,24 @@ tryAgain:
 		if (econt && errno == ENOENT)
 		{
 			elog(LOG, "Open(logfile %u seg %u) failed: file doesn't exist",
-						logId, logSeg);
+				 logId, logSeg);
 			return (fd);
 		}
-		elog(STOP, "Open(logfile %u seg %u) failed: %d", 
-					logId, logSeg, errno);
+		elog(STOP, "Open(logfile %u seg %u) failed: %d",
+			 logId, logSeg, errno);
 	}
 
-	return(fd);
+	return (fd);
 }
 
-static XLogRecord*
+static XLogRecord *
 ReadRecord(XLogRecPtr *RecPtr, char *buffer)
 {
-	XLogRecord	   *record;
-	XLogRecPtr		tmpRecPtr = EndRecPtr;
-	bool			nextmode = (RecPtr == NULL);
-	int				emode = (nextmode) ? LOG : STOP;
-	bool			noBlck = false;
+	XLogRecord *record;
+	XLogRecPtr	tmpRecPtr = EndRecPtr;
+	bool		nextmode = (RecPtr == NULL);
+	int			emode = (nextmode) ? LOG : STOP;
+	bool		noBlck = false;
 
 	if (nextmode)
 	{
@@ -835,10 +840,10 @@ ReadRecord(XLogRecPtr *RecPtr, char *buffer)
 	}
 	else if (!XRecOffIsValid(RecPtr->xrecoff))
 		elog(STOP, "ReadRecord: invalid record offset in (%u, %u)",
-					RecPtr->xlogid, RecPtr->xrecoff);
+			 RecPtr->xlogid, RecPtr->xrecoff);
 
-	if (readFile >= 0 && (RecPtr->xlogid != readId || 
-		RecPtr->xrecoff / XLogSegSize != readSeg))
+	if (readFile >= 0 && (RecPtr->xlogid != readId ||
+						  RecPtr->xrecoff / XLogSegSize != readSeg))
 	{
 		close(readFile);
 		readFile = -1;
@@ -856,59 +861,59 @@ ReadRecord(XLogRecPtr *RecPtr, char *buffer)
 	if (noBlck || readOff != (RecPtr->xrecoff % XLogSegSize) / BLCKSZ)
 	{
 		readOff = (RecPtr->xrecoff % XLogSegSize) / BLCKSZ;
-		if (lseek(readFile, (off_t)(readOff * BLCKSZ), SEEK_SET) < 0)
-			elog(STOP, "ReadRecord: lseek(logfile %u seg %u off %u) failed: %d", 
-						readId, readSeg, readOff, errno);
+		if (lseek(readFile, (off_t) (readOff * BLCKSZ), SEEK_SET) < 0)
+			elog(STOP, "ReadRecord: lseek(logfile %u seg %u off %u) failed: %d",
+				 readId, readSeg, readOff, errno);
 		if (read(readFile, readBuf, BLCKSZ) != BLCKSZ)
-			elog(STOP, "ReadRecord: read(logfile %u seg %u off %u) failed: %d", 
-						readId, readSeg, readOff, errno);
-		if (((XLogPageHeader)readBuf)->xlp_magic != XLOG_PAGE_MAGIC)
+			elog(STOP, "ReadRecord: read(logfile %u seg %u off %u) failed: %d",
+				 readId, readSeg, readOff, errno);
+		if (((XLogPageHeader) readBuf)->xlp_magic != XLOG_PAGE_MAGIC)
 		{
 			elog(emode, "ReadRecord: invalid magic number %u in logfile %u seg %u off %u",
-				((XLogPageHeader)readBuf)->xlp_magic,
-				readId, readSeg, readOff);
+				 ((XLogPageHeader) readBuf)->xlp_magic,
+				 readId, readSeg, readOff);
 			goto next_record_is_invalid;
 		}
 	}
-	if ((((XLogPageHeader)readBuf)->xlp_info & XLP_FIRST_IS_SUBRECORD) && 
+	if ((((XLogPageHeader) readBuf)->xlp_info & XLP_FIRST_IS_SUBRECORD) &&
 		RecPtr->xrecoff % BLCKSZ == SizeOfXLogPHD)
 	{
 		elog(emode, "ReadRecord: subrecord is requested by (%u, %u)",
-					RecPtr->xlogid, RecPtr->xrecoff);
+			 RecPtr->xlogid, RecPtr->xrecoff);
 		goto next_record_is_invalid;
 	}
-	record = (XLogRecord*)((char*) readBuf + RecPtr->xrecoff % BLCKSZ);
+	record = (XLogRecord *) ((char *) readBuf + RecPtr->xrecoff % BLCKSZ);
 
 got_record:;
-	if (record->xl_len == 0 || record->xl_len > 
+	if (record->xl_len == 0 || record->xl_len >
 		(BLCKSZ - RecPtr->xrecoff % BLCKSZ - SizeOfXLogRecord))
 	{
 		elog(emode, "ReadRecord: invalid record len %u in (%u, %u)",
-					record->xl_len, RecPtr->xlogid, RecPtr->xrecoff);
+			 record->xl_len, RecPtr->xlogid, RecPtr->xrecoff);
 		goto next_record_is_invalid;
 	}
 	if (record->xl_rmid > RM_MAX_ID)
 	{
 		elog(emode, "ReadRecord: invalid resource managed id %u in (%u, %u)",
-					record->xl_rmid, RecPtr->xlogid, RecPtr->xrecoff);
+			 record->xl_rmid, RecPtr->xlogid, RecPtr->xrecoff);
 		goto next_record_is_invalid;
 	}
 	nextRecord = NULL;
 	if (record->xl_info & XLR_TO_BE_CONTINUED)
 	{
-		XLogSubRecord	   *subrecord;
-		uint32				len = record->xl_len;
+		XLogSubRecord *subrecord;
+		uint32		len = record->xl_len;
 
 		if (record->xl_len + RecPtr->xrecoff % BLCKSZ + SizeOfXLogRecord != BLCKSZ)
 		{
 			elog(emode, "ReadRecord: invalid fragmented record len %u in (%u, %u)",
-						record->xl_len, RecPtr->xlogid, RecPtr->xrecoff);
+				 record->xl_len, RecPtr->xlogid, RecPtr->xrecoff);
 			goto next_record_is_invalid;
 		}
 		memcpy(buffer, record, record->xl_len + SizeOfXLogRecord);
-		record = (XLogRecord*) buffer;
+		record = (XLogRecord *) buffer;
 		buffer += record->xl_len + SizeOfXLogRecord;
-		for ( ; ; )
+		for (;;)
 		{
 			readOff++;
 			if (readOff == XLogSegSize / BLCKSZ)
@@ -926,114 +931,113 @@ got_record:;
 					goto next_record_is_invalid;
 			}
 			if (read(readFile, readBuf, BLCKSZ) != BLCKSZ)
-				elog(STOP, "ReadRecord: read(logfile %u seg %u off %u) failed: %d", 
-							readId, readSeg, readOff, errno);
-			if (((XLogPageHeader)readBuf)->xlp_magic != XLOG_PAGE_MAGIC)
+				elog(STOP, "ReadRecord: read(logfile %u seg %u off %u) failed: %d",
+					 readId, readSeg, readOff, errno);
+			if (((XLogPageHeader) readBuf)->xlp_magic != XLOG_PAGE_MAGIC)
 			{
 				elog(emode, "ReadRecord: invalid magic number %u in logfile %u seg %u off %u",
-					((XLogPageHeader)readBuf)->xlp_magic,
-					readId, readSeg, readOff);
+					 ((XLogPageHeader) readBuf)->xlp_magic,
+					 readId, readSeg, readOff);
 				goto next_record_is_invalid;
 			}
-			if (!(((XLogPageHeader)readBuf)->xlp_info & XLP_FIRST_IS_SUBRECORD))
+			if (!(((XLogPageHeader) readBuf)->xlp_info & XLP_FIRST_IS_SUBRECORD))
 			{
 				elog(emode, "ReadRecord: there is no subrecord flag in logfile %u seg %u off %u",
-							readId, readSeg, readOff);
+					 readId, readSeg, readOff);
 				goto next_record_is_invalid;
 			}
-			subrecord = (XLogSubRecord*)((char*) readBuf + SizeOfXLogPHD);
-			if (subrecord->xl_len == 0 || subrecord->xl_len > 
+			subrecord = (XLogSubRecord *) ((char *) readBuf + SizeOfXLogPHD);
+			if (subrecord->xl_len == 0 || subrecord->xl_len >
 				(BLCKSZ - SizeOfXLogPHD - SizeOfXLogSubRecord))
 			{
 				elog(emode, "ReadRecord: invalid subrecord len %u in logfile %u seg %u off %u",
-							subrecord->xl_len, readId, readSeg, readOff);
+					 subrecord->xl_len, readId, readSeg, readOff);
 				goto next_record_is_invalid;
 			}
 			len += subrecord->xl_len;
 			if (len > MAXLOGRECSZ)
 			{
 				elog(emode, "ReadRecord: too long record len %u in (%u, %u)",
-							len, RecPtr->xlogid, RecPtr->xrecoff);
+					 len, RecPtr->xlogid, RecPtr->xrecoff);
 				goto next_record_is_invalid;
 			}
-			memcpy(buffer, (char*)subrecord + SizeOfXLogSubRecord, subrecord->xl_len);
+			memcpy(buffer, (char *) subrecord + SizeOfXLogSubRecord, subrecord->xl_len);
 			buffer += subrecord->xl_len;
 			if (subrecord->xl_info & XLR_TO_BE_CONTINUED)
 			{
-				if (subrecord->xl_len + 
+				if (subrecord->xl_len +
 					SizeOfXLogPHD + SizeOfXLogSubRecord != BLCKSZ)
 				{
 					elog(emode, "ReadRecord: invalid fragmented subrecord len %u in logfile %u seg %u off %u",
-								subrecord->xl_len, readId, readSeg, readOff);
+						 subrecord->xl_len, readId, readSeg, readOff);
 					goto next_record_is_invalid;
 				}
 				continue;
 			}
 			break;
 		}
-		if (BLCKSZ - SizeOfXLogRecord >= 
+		if (BLCKSZ - SizeOfXLogRecord >=
 			subrecord->xl_len + SizeOfXLogPHD + SizeOfXLogSubRecord)
 		{
-			nextRecord = (XLogRecord*)
-				((char*)subrecord + subrecord->xl_len + SizeOfXLogSubRecord);
+			nextRecord = (XLogRecord *)
+				((char *) subrecord + subrecord->xl_len + SizeOfXLogSubRecord);
 		}
 		EndRecPtr.xlogid = readId;
-		EndRecPtr.xrecoff = readSeg * XLogSegSize + readOff * BLCKSZ + 
+		EndRecPtr.xrecoff = readSeg * XLogSegSize + readOff * BLCKSZ +
 			SizeOfXLogPHD + SizeOfXLogSubRecord + subrecord->xl_len;
 		ReadRecPtr = *RecPtr;
-		return(record);
+		return (record);
 	}
-	if (BLCKSZ - SizeOfXLogRecord >= 
+	if (BLCKSZ - SizeOfXLogRecord >=
 		record->xl_len + RecPtr->xrecoff % BLCKSZ + SizeOfXLogRecord)
-	{
-		nextRecord = (XLogRecord*)((char*)record + record->xl_len + SizeOfXLogRecord);
-	}
+		nextRecord = (XLogRecord *) ((char *) record + record->xl_len + SizeOfXLogRecord);
 	EndRecPtr.xlogid = RecPtr->xlogid;
 	EndRecPtr.xrecoff = RecPtr->xrecoff + record->xl_len + SizeOfXLogRecord;
 	ReadRecPtr = *RecPtr;
 
-	return(record);
+	return (record);
 
 next_record_is_invalid:;
 	close(readFile);
 	readFile = -1;
 	nextRecord = NULL;
 	memset(buffer, 0, SizeOfXLogRecord);
-	record = (XLogRecord*) buffer;
+	record = (XLogRecord *) buffer;
+
 	/*
 	 * If we assumed that next record began on the same page where
 	 * previous one ended - zero end of page.
 	 */
 	if (XLByteEQ(tmpRecPtr, EndRecPtr))
 	{
-		Assert (EndRecPtr.xrecoff % BLCKSZ > (SizeOfXLogPHD + SizeOfXLogSubRecord) && 
-				BLCKSZ - EndRecPtr.xrecoff % BLCKSZ >= SizeOfXLogRecord);
+		Assert(EndRecPtr.xrecoff % BLCKSZ > (SizeOfXLogPHD + SizeOfXLogSubRecord) &&
+			   BLCKSZ - EndRecPtr.xrecoff % BLCKSZ >= SizeOfXLogRecord);
 		readId = EndRecPtr.xlogid;
 		readSeg = EndRecPtr.xrecoff / XLogSegSize;
 		readOff = (EndRecPtr.xrecoff % XLogSegSize) / BLCKSZ;
 		elog(LOG, "Formatting logfile %u seg %u block %u at offset %u",
-					readId, readSeg, readOff, EndRecPtr.xrecoff % BLCKSZ);
+			 readId, readSeg, readOff, EndRecPtr.xrecoff % BLCKSZ);
 		readFile = XLogFileOpen(readId, readSeg, false);
-		if (lseek(readFile, (off_t)(readOff * BLCKSZ), SEEK_SET) < 0)
-			elog(STOP, "ReadRecord: lseek(logfile %u seg %u off %u) failed: %d", 
-						readId, readSeg, readOff, errno);
+		if (lseek(readFile, (off_t) (readOff * BLCKSZ), SEEK_SET) < 0)
+			elog(STOP, "ReadRecord: lseek(logfile %u seg %u off %u) failed: %d",
+				 readId, readSeg, readOff, errno);
 		if (read(readFile, readBuf, BLCKSZ) != BLCKSZ)
-			elog(STOP, "ReadRecord: read(logfile %u seg %u off %u) failed: %d", 
-						readId, readSeg, readOff, errno);
-		memset(readBuf + EndRecPtr.xrecoff % BLCKSZ, 0, 
-				BLCKSZ - EndRecPtr.xrecoff % BLCKSZ);
-		if (lseek(readFile, (off_t)(readOff * BLCKSZ), SEEK_SET) < 0)
-			elog(STOP, "ReadRecord: lseek(logfile %u seg %u off %u) failed: %d", 
-						readId, readSeg, readOff, errno);
+			elog(STOP, "ReadRecord: read(logfile %u seg %u off %u) failed: %d",
+				 readId, readSeg, readOff, errno);
+		memset(readBuf + EndRecPtr.xrecoff % BLCKSZ, 0,
+			   BLCKSZ - EndRecPtr.xrecoff % BLCKSZ);
+		if (lseek(readFile, (off_t) (readOff * BLCKSZ), SEEK_SET) < 0)
+			elog(STOP, "ReadRecord: lseek(logfile %u seg %u off %u) failed: %d",
+				 readId, readSeg, readOff, errno);
 		if (write(readFile, readBuf, BLCKSZ) != BLCKSZ)
-			elog(STOP, "ReadRecord: write(logfile %u seg %u off %u) failed: %d", 
-						readId, readSeg, readOff, errno);
+			elog(STOP, "ReadRecord: write(logfile %u seg %u off %u) failed: %d",
+				 readId, readSeg, readOff, errno);
 		readOff++;
 	}
 	else
 	{
-		Assert (EndRecPtr.xrecoff % BLCKSZ == 0 || 
-				BLCKSZ - EndRecPtr.xrecoff % BLCKSZ < SizeOfXLogRecord);
+		Assert(EndRecPtr.xrecoff % BLCKSZ == 0 ||
+			   BLCKSZ - EndRecPtr.xrecoff % BLCKSZ < SizeOfXLogRecord);
 		readId = tmpRecPtr.xlogid;
 		readSeg = tmpRecPtr.xrecoff / XLogSegSize;
 		readOff = (tmpRecPtr.xrecoff % XLogSegSize) / BLCKSZ;
@@ -1043,26 +1047,26 @@ next_record_is_invalid:;
 	{
 		if (!XLByteEQ(tmpRecPtr, EndRecPtr))
 			elog(LOG, "Formatting logfile %u seg %u block %u at offset 0",
-						readId, readSeg, readOff);
+				 readId, readSeg, readOff);
 		readOff *= BLCKSZ;
 		memset(readBuf, 0, BLCKSZ);
 		readFile = XLogFileOpen(readId, readSeg, false);
-		if (lseek(readFile, (off_t)readOff, SEEK_SET) < 0)
-			elog(STOP, "ReadRecord: lseek(logfile %u seg %u off %u) failed: %d", 
-						readId, readSeg, readOff, errno);
+		if (lseek(readFile, (off_t) readOff, SEEK_SET) < 0)
+			elog(STOP, "ReadRecord: lseek(logfile %u seg %u off %u) failed: %d",
+				 readId, readSeg, readOff, errno);
 		while (readOff < XLogSegSize)
 		{
 			if (write(readFile, readBuf, BLCKSZ) != BLCKSZ)
-				elog(STOP, "ReadRecord: write(logfile %u seg %u off %u) failed: %d", 
-							readId, readSeg, readOff, errno);
+				elog(STOP, "ReadRecord: write(logfile %u seg %u off %u) failed: %d",
+					 readId, readSeg, readOff, errno);
 			readOff += BLCKSZ;
 		}
 	}
 	if (readFile >= 0)
 	{
 		if (fsync(readFile) < 0)
-			elog(STOP, "ReadRecord: fsync(logfile %u seg %u) failed: %d", 
-							readId, readSeg, errno);
+			elog(STOP, "ReadRecord: fsync(logfile %u seg %u) failed: %d",
+				 readId, readSeg, errno);
 		close(readFile);
 		readFile = -1;
 	}
@@ -1084,19 +1088,19 @@ next_record_is_invalid:;
 		readId++;
 	}
 	{
-		char	path[MAXPGPATH];
+		char		path[MAXPGPATH];
 
 		XLogFileName(path, readId, readSeg);
 		unlink(path);
 	}
 
-	return(record);
+	return (record);
 }
 
 void
 UpdateControlFile()
 {
-	int		fd;
+	int			fd;
 
 tryAgain:
 #ifndef __CYGWIN__
@@ -1108,8 +1112,8 @@ tryAgain:
 	{
 		fd = errno;
 		if (!ReleaseDataFile())
-			elog(STOP, "Open(cntlfile) failed: %d (and no one data file can be closed)", 
-						fd);
+			elog(STOP, "Open(cntlfile) failed: %d (and no one data file can be closed)",
+				 fd);
 		goto tryAgain;
 	}
 	if (fd < 0)
@@ -1132,23 +1136,23 @@ XLOGShmemSize()
 	if (XLOGbuffers < MinXLOGbuffers)
 		XLOGbuffers = MinXLOGbuffers;
 
-	return(sizeof(XLogCtlData) + BLCKSZ * XLOGbuffers + 
+	return (sizeof(XLogCtlData) + BLCKSZ * XLOGbuffers +
 			sizeof(XLogRecPtr) * XLOGbuffers + BLCKSZ);
 }
 
 void
 XLOGShmemInit(void)
 {
-	bool				found;
+	bool		found;
 
 	if (XLOGbuffers < MinXLOGbuffers)
 		XLOGbuffers = MinXLOGbuffers;
 
-	ControlFile = (ControlFileData*) 
+	ControlFile = (ControlFileData *)
 		ShmemInitStruct("Control File", BLCKSZ, &found);
 	Assert(!found);
-	XLogCtl = (XLogCtlData*)
-		ShmemInitStruct("XLOG Ctl", sizeof(XLogCtlData) + BLCKSZ * XLOGbuffers + 
+	XLogCtl = (XLogCtlData *)
+		ShmemInitStruct("XLOG Ctl", sizeof(XLogCtlData) + BLCKSZ * XLOGbuffers +
 						sizeof(XLogRecPtr) * XLOGbuffers, &found);
 	Assert(!found);
 }
@@ -1159,43 +1163,45 @@ XLOGShmemInit(void)
 void
 BootStrapXLOG()
 {
-	int				fd;
-	char			buffer[BLCKSZ];
-	CheckPoint		checkPoint;
+	int			fd;
+	char		buffer[BLCKSZ];
+	CheckPoint	checkPoint;
 
 #ifdef NOT_USED
-	XLogPageHeader	page = (XLogPageHeader)buffer;
-	XLogRecord	   *record;
+	XLogPageHeader page = (XLogPageHeader) buffer;
+	XLogRecord *record;
+
 #endif
 
 #ifndef __CYGWIN__
-	fd = open(ControlFilePath, O_RDWR|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR);
+	fd = open(ControlFilePath, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
 #else
-	fd = open(ControlFilePath, O_RDWR|O_CREAT|O_EXCL|O_BINARY, S_IRUSR|S_IWUSR);
+	fd = open(ControlFilePath, O_RDWR | O_CREAT | O_EXCL | O_BINARY, S_IRUSR | S_IWUSR);
 #endif
 	if (fd < 0)
-		elog(STOP, "BootStrapXLOG failed to create control file (%s): %d", 
-					ControlFilePath, errno);
+		elog(STOP, "BootStrapXLOG failed to create control file (%s): %d",
+			 ControlFilePath, errno);
 
 	checkPoint.redo.xlogid = 0;
 	checkPoint.redo.xrecoff = SizeOfXLogPHD;
 	checkPoint.undo = checkPoint.redo;
 	checkPoint.nextXid = FirstTransactionId;
-	checkPoint.nextOid =  BootstrapObjectIdData;
+	checkPoint.nextOid = BootstrapObjectIdData;
 
 #ifdef NOT_USED
 
 	memset(buffer, 0, BLCKSZ);
 	page->xlp_magic = XLOG_PAGE_MAGIC;
 	page->xlp_info = 0;
-	record = (XLogRecord*) ((char*)page + SizeOfXLogPHD);
-	record->xl_prev.xlogid = 0; record->xl_prev.xrecoff = 0;
+	record = (XLogRecord *) ((char *) page + SizeOfXLogPHD);
+	record->xl_prev.xlogid = 0;
+	record->xl_prev.xrecoff = 0;
 	record->xl_xact_prev = record->xl_prev;
 	record->xl_xid = InvalidTransactionId;
 	record->xl_len = sizeof(checkPoint);
 	record->xl_info = 0;
 	record->xl_rmid = RM_XLOG_ID;
-	memcpy((char*)record + SizeOfXLogRecord, &checkPoint, sizeof(checkPoint));
+	memcpy((char *) record + SizeOfXLogRecord, &checkPoint, sizeof(checkPoint));
 
 	logFile = XLogFileInit(0, 0);
 
@@ -1211,7 +1217,7 @@ BootStrapXLOG()
 #endif
 
 	memset(buffer, 0, BLCKSZ);
-	ControlFile = (ControlFileData*) buffer;
+	ControlFile = (ControlFileData *) buffer;
 	ControlFile->logId = 0;
 	ControlFile->logSeg = 1;
 	ControlFile->checkPoint = checkPoint.redo;
@@ -1230,16 +1236,16 @@ BootStrapXLOG()
 	close(fd);
 }
 
-static char*
+static char *
 str_time(time_t tnow)
 {
-	char   *result = ctime(&tnow);
-	char   *p = strchr(result, '\n');
+	char	   *result = ctime(&tnow);
+	char	   *p = strchr(result, '\n');
 
 	if (p != NULL)
 		*p = 0;
 
-	return(result);
+	return (result);
 }
 
 /*
@@ -1249,21 +1255,22 @@ void
 StartupXLOG()
 {
 #ifdef NOT_USED
-	XLogCtlInsert	   *Insert;
-	CheckPoint			checkPoint;
-	XLogRecPtr			RecPtr,
-						LastRec;
-	XLogRecord		   *record;
-	char				buffer[MAXLOGRECSZ+SizeOfXLogRecord];
-	int					recovery = 0;
-	bool				sie_saved = false;
+	XLogCtlInsert *Insert;
+	CheckPoint	checkPoint;
+	XLogRecPtr	RecPtr,
+				LastRec;
+	XLogRecord *record;
+	char		buffer[MAXLOGRECSZ + SizeOfXLogRecord];
+	int			recovery = 0;
+	bool		sie_saved = false;
+
 #endif
-	int					fd;
+	int			fd;
 
 	elog(LOG, "Data Base System is starting up at %s", str_time(time(NULL)));
 
-	XLogCtl->xlblocks = (XLogRecPtr*) (((char *)XLogCtl) + sizeof(XLogCtlData));
-	XLogCtl->pages = ((char *)XLogCtl->xlblocks + sizeof(XLogRecPtr) * XLOGbuffers);
+	XLogCtl->xlblocks = (XLogRecPtr *) (((char *) XLogCtl) + sizeof(XLogCtlData));
+	XLogCtl->pages = ((char *) XLogCtl->xlblocks + sizeof(XLogRecPtr) * XLOGbuffers);
 	XLogCtl->XLogCacheByte = BLCKSZ * XLOGbuffers;
 	XLogCtl->XLogCacheBlck = XLOGbuffers - 1;
 	memset(XLogCtl->xlblocks, 0, sizeof(XLogRecPtr) * XLOGbuffers);
@@ -1291,8 +1298,8 @@ tryAgain:
 	{
 		fd = errno;
 		if (!ReleaseDataFile())
-			elog(STOP, "Open(\"%s\") failed: %d (and no one data file can be closed)", 
-						ControlFilePath, fd);
+			elog(STOP, "Open(\"%s\") failed: %d (and no one data file can be closed)",
+				 ControlFilePath, fd);
 		goto tryAgain;
 	}
 	if (fd < 0)
@@ -1303,10 +1310,10 @@ tryAgain:
 
 	close(fd);
 
-	if (ControlFile->logSeg == 0 || 
-		ControlFile->time <= 0 || 
-		ControlFile->state < DB_SHUTDOWNED || 
-		ControlFile->state > DB_IN_PRODUCTION || 
+	if (ControlFile->logSeg == 0 ||
+		ControlFile->time <= 0 ||
+		ControlFile->state < DB_SHUTDOWNED ||
+		ControlFile->state > DB_IN_PRODUCTION ||
 		!XRecOffIsValid(ControlFile->checkPoint.xrecoff))
 		elog(STOP, "Control file context is broken");
 
@@ -1323,20 +1330,20 @@ tryAgain:
 
 	if (ControlFile->state == DB_SHUTDOWNED)
 		elog(LOG, "Data Base System was shut down at %s",
-					str_time(ControlFile->time));
+			 str_time(ControlFile->time));
 	else if (ControlFile->state == DB_SHUTDOWNING)
 		elog(LOG, "Data Base System was interrupted when shutting down at %s",
-					str_time(ControlFile->time));
+			 str_time(ControlFile->time));
 	else if (ControlFile->state == DB_IN_RECOVERY)
 	{
 		elog(LOG, "Data Base System was interrupted being in recovery at %s\n"
-				  "\tThis propably means that some data blocks are corrupted\n"
-				  "\tAnd you will have to use last backup for recovery",
-					str_time(ControlFile->time));
+			 "\tThis propably means that some data blocks are corrupted\n"
+			 "\tAnd you will have to use last backup for recovery",
+			 str_time(ControlFile->time));
 	}
 	else if (ControlFile->state == DB_IN_PRODUCTION)
 		elog(LOG, "Data Base System was interrupted being in production at %s",
-					str_time(ControlFile->time));
+			 str_time(ControlFile->time));
 
 #ifdef NOT_USED
 
@@ -1350,14 +1357,14 @@ tryAgain:
 		elog(STOP, "Invalid RMID in checkPoint record");
 	if (record->xl_len != sizeof(checkPoint))
 		elog(STOP, "Invalid length of checkPoint record");
-	checkPoint = *((CheckPoint*)((char*)record + SizeOfXLogRecord));
+	checkPoint = *((CheckPoint *) ((char *) record + SizeOfXLogRecord));
 
 	elog(LOG, "Redo record at (%u, %u); Undo record at (%u, %u)",
-				checkPoint.redo.xlogid, checkPoint.redo.xrecoff,
-				checkPoint.undo.xlogid, checkPoint.undo.xrecoff);
+		 checkPoint.redo.xlogid, checkPoint.redo.xrecoff,
+		 checkPoint.undo.xlogid, checkPoint.undo.xrecoff);
 	elog(LOG, "NextTransactionId: %u; NextOid: %u",
-				checkPoint.nextXid, checkPoint.nextOid);
-	if (checkPoint.nextXid < FirstTransactionId || 
+		 checkPoint.nextXid, checkPoint.nextOid);
+	if (checkPoint.nextXid < FirstTransactionId ||
 		checkPoint.nextOid < BootstrapObjectIdData)
 #ifdef XLOG
 		elog(STOP, "Invalid NextTransactionId/NextOid");
@@ -1389,7 +1396,7 @@ tryAgain:
 	if (recovery > 0)
 	{
 		elog(LOG, "The DataBase system was not properly shut down\n"
-					"\tAutomatic recovery is in progress...");
+			 "\tAutomatic recovery is in progress...");
 		ControlFile->state = DB_IN_RECOVERY;
 		ControlFile->time = time(NULL);
 		UpdateControlFile();
@@ -1400,14 +1407,15 @@ tryAgain:
 		/* Is REDO required ? */
 		if (XLByteLT(checkPoint.redo, RecPtr))
 			record = ReadRecord(&(checkPoint.redo), buffer);
-		else	/* read past CheckPoint record */
+		else
+/* read past CheckPoint record */
 			record = ReadRecord(NULL, buffer);
 
 		/* REDO */
 		if (record->xl_len != 0)
 		{
-			elog(LOG, "Redo starts at (%u, %u)", 
-						ReadRecPtr.xlogid, ReadRecPtr.xrecoff);
+			elog(LOG, "Redo starts at (%u, %u)",
+				 ReadRecPtr.xlogid, ReadRecPtr.xrecoff);
 			do
 			{
 #ifdef XLOG
@@ -1417,8 +1425,8 @@ tryAgain:
 				RmgrTable[record->xl_rmid].rm_redo(EndRecPtr, record);
 				record = ReadRecord(NULL, buffer);
 			} while (record->xl_len != 0);
-			elog(LOG, "Redo done at (%u, %u)", 
-						ReadRecPtr.xlogid, ReadRecPtr.xrecoff);
+			elog(LOG, "Redo done at (%u, %u)",
+				 ReadRecPtr.xlogid, ReadRecPtr.xrecoff);
 			LastRec = ReadRecPtr;
 		}
 		else
@@ -1431,18 +1439,18 @@ tryAgain:
 		RecPtr = ReadRecPtr;
 		if (XLByteLT(checkPoint.undo, RecPtr))
 		{
-			elog(LOG, "Undo starts at (%u, %u)", 
-						RecPtr.xlogid, RecPtr.xrecoff);
+			elog(LOG, "Undo starts at (%u, %u)",
+				 RecPtr.xlogid, RecPtr.xrecoff);
 			do
 			{
 				record = ReadRecord(&RecPtr, buffer);
-				if (TransactionIdIsValid(record->xl_xid) && 
+				if (TransactionIdIsValid(record->xl_xid) &&
 					!TransactionIdDidCommit(record->xl_xid))
 					RmgrTable[record->xl_rmid].rm_undo(record);
 				RecPtr = record->xl_prev;
 			} while (XLByteLE(checkPoint.undo, RecPtr));
-			elog(LOG, "Undo done at (%u, %u)", 
-						ReadRecPtr.xlogid, ReadRecPtr.xrecoff);
+			elog(LOG, "Undo done at (%u, %u)",
+				 ReadRecPtr.xlogid, ReadRecPtr.xrecoff);
 		}
 		else
 		{
@@ -1458,19 +1466,19 @@ tryAgain:
 	logOff = 0;
 	logFile = XLogFileOpen(logId, logSeg, false);
 	XLogCtl->xlblocks[0].xlogid = logId;
-	XLogCtl->xlblocks[0].xrecoff = 
-			((EndRecPtr.xrecoff - 1) / BLCKSZ + 1) * BLCKSZ;
+	XLogCtl->xlblocks[0].xrecoff =
+		((EndRecPtr.xrecoff - 1) / BLCKSZ + 1) * BLCKSZ;
 	Insert = &XLogCtl->Insert;
-	memcpy((char*)(Insert->currpage), readBuf, BLCKSZ);
-	Insert->currpos = ((char*) Insert->currpage) + 
+	memcpy((char *) (Insert->currpage), readBuf, BLCKSZ);
+	Insert->currpos = ((char *) Insert->currpage) +
 		(EndRecPtr.xrecoff + BLCKSZ - XLogCtl->xlblocks[0].xrecoff);
 	Insert->PrevRecord = ControlFile->checkPoint;
 
 	if (recovery > 0)
 	{
-		int		i;
+		int			i;
 
-		/* 
+		/*
 		 * Let resource managers know that recovery is done
 		 */
 		for (i = 0; i <= RM_MAX_ID; i++)
@@ -1479,7 +1487,7 @@ tryAgain:
 		StopIfError = sie_saved;
 	}
 
-#endif	/* NOT_USED */
+#endif	 /* NOT_USED */
 
 	ControlFile->state = DB_IN_PRODUCTION;
 	ControlFile->time = time(NULL);
@@ -1508,11 +1516,11 @@ void
 CreateCheckPoint(bool shutdown)
 {
 #ifdef NOT_USED
-	CheckPoint			checkPoint;
-	XLogRecPtr			recptr;
-	XLogCtlInsert	   *Insert = &XLogCtl->Insert;
-	uint32				freespace;
-	uint16				curridx;
+	CheckPoint	checkPoint;
+	XLogRecPtr	recptr;
+	XLogCtlInsert *Insert = &XLogCtl->Insert;
+	uint32		freespace;
+	uint16		curridx;
 
 	memset(&checkPoint, 0, sizeof(checkPoint));
 	if (shutdown)
@@ -1531,21 +1539,21 @@ CreateCheckPoint(bool shutdown)
 			elog(STOP, "XLog insert lock is busy while data base is shutting down");
 		(void) select(0, NULL, NULL, NULL, &delay);
 	}
-	freespace = ((char*) Insert->currpage) + BLCKSZ - Insert->currpos;
+	freespace = ((char *) Insert->currpage) + BLCKSZ - Insert->currpos;
 	if (freespace < SizeOfXLogRecord)
 	{
 		curridx = NextBufIdx(Insert->curridx);
 		if (XLByteLE(XLogCtl->xlblocks[curridx], LgwrResult.Write))
 			InitXLBuffer(curridx);
-		else 
+		else
 			GetFreeXLBuffer();
 		freespace = BLCKSZ - SizeOfXLogPHD;
 	}
 	else
 		curridx = Insert->curridx;
 	checkPoint.redo.xlogid = XLogCtl->xlblocks[curridx].xlogid;
-	checkPoint.redo.xrecoff = XLogCtl->xlblocks[curridx].xrecoff - BLCKSZ + 
-								Insert->currpos - ((char*) Insert->currpage);
+	checkPoint.redo.xrecoff = XLogCtl->xlblocks[curridx].xrecoff - BLCKSZ +
+		Insert->currpos - ((char *) Insert->currpage);
 	S_UNLOCK(&(XLogCtl->insert_lck));
 
 	SpinAcquire(XidGenLockId);
@@ -1563,14 +1571,14 @@ CreateCheckPoint(bool shutdown)
 	if (shutdown && checkPoint.undo.xrecoff != 0)
 		elog(STOP, "Active transaction while data base is shutting down");
 
-	recptr = XLogInsert(RM_XLOG_ID, (char*)&checkPoint, sizeof(checkPoint), NULL, 0);
+	recptr = XLogInsert(RM_XLOG_ID, (char *) &checkPoint, sizeof(checkPoint), NULL, 0);
 
 	if (shutdown && !XLByteEQ(checkPoint.redo, MyLastRecPtr))
 		elog(STOP, "XLog concurrent activity while data base is shutting down");
 
 	XLogFlush(recptr);
 
-#endif	/* NOT_USED */
+#endif	 /* NOT_USED */
 
 	SpinAcquire(ControlFileLockId);
 	if (shutdown)
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 8e129a460a9e56cb6b33ba66f5f1d17d98215f39..a12bca949327c59397eea46ebc87b76d16b444bd 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.80 2000/02/18 09:28:39 inoue Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.81 2000/04/12 17:14:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -39,13 +39,13 @@
 
 #define ALLOC(t, c)		(t *)calloc((unsigned)(c), sizeof(t))
 
-extern void		BaseInit(void);
-extern void		StartupXLOG(void);
-extern void		ShutdownXLOG(void);
-extern void		BootStrapXLOG(void);
+extern void BaseInit(void);
+extern void StartupXLOG(void);
+extern void ShutdownXLOG(void);
+extern void BootStrapXLOG(void);
 
-extern char		XLogDir[];
-extern char		ControlFilePath[];
+extern char XLogDir[];
+extern char ControlFilePath[];
 
 extern int	Int_yyparse(void);
 static hashnode *AddStr(char *str, int strlength, int mderef);
@@ -107,7 +107,7 @@ static struct typinfo Procid[] = {
 	{"char", CHAROID, 0, 1, F_CHARIN, F_CHAROUT},
 	{"name", NAMEOID, 0, NAMEDATALEN, F_NAMEIN, F_NAMEOUT},
 	{"int2", INT2OID, 0, 2, F_INT2IN, F_INT2OUT},
-	{"int2vector", INT2VECTOROID, 0, INDEX_MAX_KEYS*2, F_INT2VECTORIN, F_INT2VECTOROUT},
+	{"int2vector", INT2VECTOROID, 0, INDEX_MAX_KEYS * 2, F_INT2VECTORIN, F_INT2VECTOROUT},
 	{"int4", INT4OID, 0, 4, F_INT4IN, F_INT4OUT},
 	{"regproc", REGPROCOID, 0, 4, F_REGPROCIN, F_REGPROCOUT},
 	{"text", TEXTOID, 0, -1, F_TEXTIN, F_TEXTOUT},
@@ -115,7 +115,7 @@ static struct typinfo Procid[] = {
 	{"tid", TIDOID, 0, 6, F_TIDIN, F_TIDOUT},
 	{"xid", XIDOID, 0, 4, F_XIDIN, F_XIDOUT},
 	{"cid", CIDOID, 0, 4, F_CIDIN, F_CIDOUT},
-	{"oidvector", 30, 0, INDEX_MAX_KEYS*4, F_OIDVECTORIN, F_OIDVECTOROUT},
+	{"oidvector", 30, 0, INDEX_MAX_KEYS * 4, F_OIDVECTORIN, F_OIDVECTOROUT},
 	{"smgr", 210, 0, 2, F_SMGRIN, F_SMGROUT},
 	{"_int4", 1007, INT4OID, -1, F_ARRAY_IN, F_ARRAY_OUT},
 	{"_aclitem", 1034, 1033, -1, F_ARRAY_IN, F_ARRAY_OUT}
@@ -325,8 +325,8 @@ BootstrapMain(int argc, char *argv[])
 	}
 
 	/*
-	 * Bootstrap under Postmaster means two things:
-	 * (xloginit) ? StartupXLOG : ShutdownXLOG
+	 * Bootstrap under Postmaster means two things: (xloginit) ?
+	 * StartupXLOG : ShutdownXLOG
 	 *
 	 * If !under Postmaster and xloginit then BootStrapXLOG.
 	 */
@@ -345,9 +345,7 @@ BootstrapMain(int argc, char *argv[])
 	}
 
 	if (!IsUnderPostmaster && xloginit)
-	{
 		BootStrapXLOG();
-	}
 
 	/*
 	 * backend initialization
@@ -478,7 +476,7 @@ boot_openrel(char *relname)
 		 */
 		if (namestrcmp(&attrtypes[i]->attname, "attisset") == 0)
 			attrtypes[i]->attisset = get_attisset(RelationGetRelid(reldesc),
-											 NameStr(attrtypes[i]->attname));
+										 NameStr(attrtypes[i]->attname));
 		else
 			attrtypes[i]->attisset = false;
 
@@ -1153,8 +1151,10 @@ build_indices()
 		index_build(heap, ind, ILHead->il_natts, ILHead->il_attnos,
 				 ILHead->il_nparams, ILHead->il_params, ILHead->il_finfo,
 					ILHead->il_predInfo);
-		/* In normal processing mode, index_build would close the heap
-		 * and index, but in bootstrap mode it will not.
+
+		/*
+		 * In normal processing mode, index_build would close the heap and
+		 * index, but in bootstrap mode it will not.
 		 */
 
 		/*
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index e3fec88e97e469b351ce4465ab62e89cdc1ba215..c342b067ff4078b610db7eae0eb8197d6d8894b7 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.37 2000/01/26 05:56:09 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.38 2000/04/12 17:14:55 momjian Exp $
  *
  * NOTES
  *	  See acl.h.
@@ -364,7 +364,7 @@ pg_aclcheck(char *relname, char *usename, AclMode mode)
 	 */
 	if (((mode & ACL_WR) || (mode & ACL_AP)) &&
 		!allowSystemTableMods && IsSystemRelationName(relname) &&
-		strncmp(relname,"pg_temp.", strlen("pg_temp.")) != 0 &&
+		strncmp(relname, "pg_temp.", strlen("pg_temp.")) != 0 &&
 		!((Form_pg_shadow) GETSTRUCT(tuple))->usecatupd)
 	{
 		elog(DEBUG, "pg_aclcheck: catalog update to \"%s\": permission denied",
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index 5425387b3fe32c5c1134d421ae83f06126cee8cb..4a5b1d9df2a96fadb9ef466b24ead3a65d140bc0 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.31 2000/04/09 04:43:15 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.32 2000/04/12 17:14:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -44,6 +44,7 @@ relpath(const char *relname)
 		snprintf(path, bufsize, "%s%c%s", DataDir, SEP_CHAR, relname);
 		return path;
 	}
+
 	/*
 	 * If it is in the current database, assume it is in current working
 	 * directory.  NB: this does not work during bootstrap!
@@ -55,7 +56,7 @@ relpath(const char *relname)
  * relpath_blind			- construct path to a relation's file
  *
  * Construct the path using only the info available to smgrblindwrt,
- * namely the names and OIDs of the database and relation.  (Shared system
+ * namely the names and OIDs of the database and relation.	(Shared system
  * relations are identified with dbid = 0.)  Note that we may have to
  * access a relation belonging to a different database!
  *
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index ae8d32bb8d522c6e50bc3a7b9b717a402ae2a3d0..b7c56d5eb63be3d22fe60ffd20c41a7c579d8a39 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.124 2000/03/17 02:36:05 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.125 2000/04/12 17:14:55 momjian Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -69,9 +69,9 @@
 
 
 static void AddNewRelationTuple(Relation pg_class_desc,
-								Relation new_rel_desc, Oid new_rel_oid,
-								int natts,
-								char relkind, char *temp_relname);
+					Relation new_rel_desc, Oid new_rel_oid,
+					int natts,
+					char relkind, char *temp_relname);
 static void AddToNoNameRelList(Relation r);
 
 static void DeleteAttributeTuples(Relation rel);
@@ -82,7 +82,7 @@ static void RelationRemoveInheritance(Relation relation);
 static void RemoveFromNoNameRelList(Relation r);
 static void AddNewRelationType(char *typeName, Oid new_rel_oid);
 static void StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin,
-							 bool updatePgAttribute);
+				 bool updatePgAttribute);
 static void StoreRelCheck(Relation rel, char *ccname, char *ccbin);
 static void StoreConstraints(Relation rel);
 static void RemoveConstraints(Relation rel);
@@ -271,8 +271,9 @@ heap_create(char *relname,
 
 	rel = (Relation) palloc(len);
 	MemSet((char *) rel, 0, len);
-	rel->rd_fd = -1;		/* table is not open */
+	rel->rd_fd = -1;			/* table is not open */
 	rel->rd_unlinked = TRUE;	/* table is not created yet */
+
 	/*
 	 * create a new tuple descriptor from the one passed in
 	 */
@@ -345,7 +346,7 @@ heap_create(char *relname,
 bool
 heap_storage_create(Relation rel)
 {
-	bool smgrcall = false;
+	bool		smgrcall = false;
 
 	if (rel->rd_unlinked)
 	{
@@ -715,6 +716,7 @@ AddNewRelationTuple(Relation pg_class_desc,
 
 	if (!IsIgnoringSystemIndexes())
 	{
+
 		/*
 		 * First, open the catalog indices and insert index tuples for the
 		 * new relation.
@@ -878,7 +880,7 @@ heap_create_with_catalog(char *relname,
 	 *	SOMEDAY: fill the STATISTIC relation properly.
 	 * ----------------
 	 */
-	heap_close(new_rel_desc, NoLock); /* do not unlock till end of xact */
+	heap_close(new_rel_desc, NoLock);	/* do not unlock till end of xact */
 	heap_close(pg_class_desc, RowExclusiveLock);
 
 	return new_rel_oid;
@@ -893,7 +895,7 @@ heap_create_with_catalog(char *relname,
  *		3)	remove indexes
  *		4)	remove pg_class tuple
  *		5)	remove pg_attribute tuples and related descriptions
- *              6)      remove pg_description tuples
+ *				6)		remove pg_description tuples
  *		7)	remove pg_type tuples
  *		8)	RemoveConstraints ()
  *		9)	unlink relation
@@ -963,7 +965,7 @@ RelationRemoveInheritance(Relation relation)
 	tuple = heap_getnext(scan, 0);
 	if (HeapTupleIsValid(tuple))
 	{
-		Oid		subclass = ((Form_pg_inherits) GETSTRUCT(tuple))->inhrelid;
+		Oid			subclass = ((Form_pg_inherits) GETSTRUCT(tuple))->inhrelid;
 
 		heap_endscan(scan);
 		heap_close(catalogRelation, RowExclusiveLock);
@@ -1073,7 +1075,7 @@ DeleteRelationTuple(Relation rel)
 	{
 		heap_close(pg_class_desc, RowExclusiveLock);
 		elog(ERROR, "Relation '%s' does not exist",
-					RelationGetRelationName(rel));
+			 RelationGetRelationName(rel));
 	}
 
 	/* ----------------
@@ -1096,19 +1098,27 @@ DeleteRelationTuple(Relation rel)
 static void
 RelationTruncateIndexes(Relation heapRelation)
 {
-	Relation indexRelation, currentIndex;
+	Relation	indexRelation,
+				currentIndex;
 	ScanKeyData entry;
 	HeapScanDesc scan;
-	HeapTuple indexTuple, procTuple, classTuple;
+	HeapTuple	indexTuple,
+				procTuple,
+				classTuple;
 	Form_pg_index index;
-	Oid heapId, indexId, procId, accessMethodId;
-	Node *oldPred = NULL;
-	PredInfo *predInfo;
-	List *cnfPred = NULL;
+	Oid			heapId,
+				indexId,
+				procId,
+				accessMethodId;
+	Node	   *oldPred = NULL;
+	PredInfo   *predInfo;
+	List	   *cnfPred = NULL;
 	AttrNumber *attributeNumberA;
-	FuncIndexInfo fInfo, *funcInfo = NULL;
-	int i, numberOfAttributes;
-	char *predString;
+	FuncIndexInfo fInfo,
+			   *funcInfo = NULL;
+	int			i,
+				numberOfAttributes;
+	char	   *predString;
 
 	heapId = RelationGetRelid(heapRelation);
 
@@ -1120,8 +1130,10 @@ RelationTruncateIndexes(Relation heapRelation)
 	scan = heap_beginscan(indexRelation, false, SnapshotNow, 1, &entry);
 	while (HeapTupleIsValid(indexTuple = heap_getnext(scan, 0)))
 	{
+
 		/*
-		 * For each index, fetch index attributes so we can apply index_build
+		 * For each index, fetch index attributes so we can apply
+		 * index_build
 		 */
 		index = (Form_pg_index) GETSTRUCT(indexTuple);
 		indexId = index->indexrelid;
@@ -1181,8 +1193,8 @@ RelationTruncateIndexes(Relation heapRelation)
 		LockRelation(currentIndex, AccessExclusiveLock);
 
 		/*
-		 * Release any buffers associated with this index.  If they're dirty,
-		 * they're just dropped without bothering to flush to disk.
+		 * Release any buffers associated with this index.	If they're
+		 * dirty, they're just dropped without bothering to flush to disk.
 		 */
 		ReleaseRelationBuffers(currentIndex);
 		if (FlushRelationBuffers(currentIndex, (BlockNumber) 0, false) < 0)
@@ -1198,35 +1210,35 @@ RelationTruncateIndexes(Relation heapRelation)
 					attributeNumberA, 0, NULL, funcInfo, predInfo);
 
 		/*
-		 * index_build will close both the heap and index relations
-		 * (but not give up the locks we hold on them).  That's fine
-		 * for the index, but we need to open the heap again.  We need
-		 * no new lock, since this backend still has the exclusive lock
-		 * grabbed by heap_truncate.
+		 * index_build will close both the heap and index relations (but
+		 * not give up the locks we hold on them).	That's fine for the
+		 * index, but we need to open the heap again.  We need no new
+		 * lock, since this backend still has the exclusive lock grabbed
+		 * by heap_truncate.
 		 */
 		heapRelation = heap_open(heapId, NoLock);
 		Assert(heapRelation != NULL);
 	}
 
 	/* Complete the scan and close pg_index */
-    heap_endscan(scan);
+	heap_endscan(scan);
 	heap_close(indexRelation, AccessShareLock);
 }
 
 /* ----------------------------
- *   heap_truncate
+ *	 heap_truncate
  *
- *   This routine is used to truncate the data from the
- *   storage manager of any data within the relation handed
- *   to this routine.
+ *	 This routine is used to truncate the data from the
+ *	 storage manager of any data within the relation handed
+ *	 to this routine.
  * ----------------------------
  */
 
 void
 heap_truncate(char *relname)
 {
-	Relation rel;
-	Oid rid;
+	Relation	rel;
+	Oid			rid;
 
 	/* Open relation for processing, and grab exclusive access on it. */
 
@@ -1245,12 +1257,12 @@ heap_truncate(char *relname)
 	 *	they don't exist anyway.  So, no warning in that case.
 	 * ----------------
 	 */
-	if (IsTransactionBlock() && ! rel->rd_myxactonly)
+	if (IsTransactionBlock() && !rel->rd_myxactonly)
 		elog(NOTICE, "Caution: TRUNCATE TABLE cannot be rolled back, so don't abort now");
 
 	/*
-	 * Release any buffers associated with this relation.  If they're dirty,
-	 * they're just dropped without bothering to flush to disk.
+	 * Release any buffers associated with this relation.  If they're
+	 * dirty, they're just dropped without bothering to flush to disk.
 	 */
 
 	ReleaseRelationBuffers(rel);
@@ -1300,17 +1312,17 @@ DeleteAttributeTuples(Relation rel)
 		 attnum++)
 	{
 		if (HeapTupleIsValid(tup = SearchSysCacheTupleCopy(ATTNUM,
-								   ObjectIdGetDatum(RelationGetRelid(rel)),
-								   Int16GetDatum(attnum),
+								 ObjectIdGetDatum(RelationGetRelid(rel)),
+												   Int16GetDatum(attnum),
 														   0, 0)))
 		{
-		  
-		  /*** Delete any comments associated with this attribute ***/
 
-		  DeleteComments(tup->t_data->t_oid);
+			/*** Delete any comments associated with this attribute ***/
+
+			DeleteComments(tup->t_data->t_oid);
 
-		  heap_delete(pg_attribute_desc, &tup->t_self, NULL);
-		  heap_freetuple(tup);
+			heap_delete(pg_attribute_desc, &tup->t_self, NULL);
+			heap_freetuple(tup);
 
 		}
 	}
@@ -1429,7 +1441,7 @@ DeleteTypeTuple(Relation rel)
 	 *	we release the read lock on pg_type.  -mer 13 Aug 1991
 	 * ----------------
 	 */
-	
+
 	heap_delete(pg_type_desc, &tup->t_self, NULL);
 
 	heap_endscan(pg_type_scan);
@@ -1477,7 +1489,7 @@ heap_drop_with_catalog(const char *relname)
 	 *	they don't exist anyway.  So, no warning in that case.
 	 * ----------------
 	 */
-	if (IsTransactionBlock() && ! rel->rd_myxactonly)
+	if (IsTransactionBlock() && !rel->rd_myxactonly)
 		elog(NOTICE, "Caution: DROP TABLE cannot be rolled back, so don't abort now");
 
 	/* ----------------
@@ -1547,8 +1559,8 @@ heap_drop_with_catalog(const char *relname)
 
 	/*
 	 * Close relcache entry, but *keep* AccessExclusiveLock on the
-	 * relation until transaction commit.  This ensures no one else
-	 * will try to do something with the doomed relation.
+	 * relation until transaction commit.  This ensures no one else will
+	 * try to do something with the doomed relation.
 	 */
 	heap_close(rel, NoLock);
 
@@ -1704,7 +1716,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin,
 	Relation	idescs[Num_pg_attrdef_indices];
 	HeapTuple	tuple;
 	Datum		values[4];
-	static char	nulls[4] = {' ', ' ', ' ', ' '};
+	static char nulls[4] = {' ', ' ', ' ', ' '};
 	Relation	attrrel;
 	Relation	attridescs[Num_pg_attr_indices];
 	HeapTuple	atttup;
@@ -1714,6 +1726,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin,
 	 * Need to construct source equivalent of given node-string.
 	 */
 	expr = stringToNode(adbin);
+
 	/*
 	 * deparse_expression needs a RangeTblEntry list, so make one
 	 */
@@ -1747,18 +1760,18 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin,
 	heap_freetuple(tuple);
 	pfree(adsrc);
 
-	if (! updatePgAttribute)
+	if (!updatePgAttribute)
 		return;					/* done if pg_attribute is OK */
 
 	attrrel = heap_openr(AttributeRelationName, RowExclusiveLock);
 	atttup = SearchSysCacheTupleCopy(ATTNUM,
-									 ObjectIdGetDatum(RelationGetRelid(rel)),
+								 ObjectIdGetDatum(RelationGetRelid(rel)),
 									 (Datum) attnum, 0, 0);
 	if (!HeapTupleIsValid(atttup))
 		elog(ERROR, "cache lookup of attribute %d in relation %u failed",
 			 attnum, RelationGetRelid(rel));
 	attStruct = (Form_pg_attribute) GETSTRUCT(atttup);
-	if (! attStruct->atthasdef)
+	if (!attStruct->atthasdef)
 	{
 		attStruct->atthasdef = true;
 		heap_update(attrrel, &atttup->t_self, atttup, NULL);
@@ -1789,13 +1802,14 @@ StoreRelCheck(Relation rel, char *ccname, char *ccbin)
 	Relation	idescs[Num_pg_relcheck_indices];
 	HeapTuple	tuple;
 	Datum		values[4];
-	static char	nulls[4] = {' ', ' ', ' ', ' '};
+	static char nulls[4] = {' ', ' ', ' ', ' '};
 
 	/*
 	 * Convert condition to a normal boolean expression tree.
 	 */
 	expr = stringToNode(ccbin);
 	expr = (Node *) make_ands_explicit((List *) expr);
+
 	/*
 	 * deparse_expression needs a RangeTblEntry list, so make one
 	 */
@@ -1850,9 +1864,10 @@ StoreConstraints(Relation rel)
 	if (!constr)
 		return;
 
-	/* deparsing of constraint expressions will fail unless the just-created
-	 * pg_attribute tuples for this relation are made visible.  So, bump
-	 * the command counter.
+	/*
+	 * deparsing of constraint expressions will fail unless the
+	 * just-created pg_attribute tuples for this relation are made
+	 * visible.  So, bump the command counter.
 	 */
 	CommandCounterIncrement();
 
@@ -1882,7 +1897,7 @@ StoreConstraints(Relation rel)
  * expression.
  *
  * NB: caller should have opened rel with AccessExclusiveLock, and should
- * hold that lock till end of transaction.  Also, we assume the caller has
+ * hold that lock till end of transaction.	Also, we assume the caller has
  * done a CommandCounterIncrement if necessary to make the relation's catalog
  * tuples visible.
  */
@@ -1921,8 +1936,8 @@ AddRelationRawConstraints(Relation rel,
 	}
 
 	/*
-	 * Create a dummy ParseState and insert the target relation as
-	 * its sole rangetable entry.  We need a ParseState for transformExpr.
+	 * Create a dummy ParseState and insert the target relation as its
+	 * sole rangetable entry.  We need a ParseState for transformExpr.
 	 */
 	pstate = make_parsestate(NULL);
 	makeRangeTable(pstate, NULL);
@@ -1938,25 +1953,28 @@ AddRelationRawConstraints(Relation rel,
 		Oid			type_id;
 
 		Assert(colDef->raw_default != NULL);
+
 		/*
 		 * Transform raw parsetree to executable expression.
 		 */
 		expr = transformExpr(pstate, colDef->raw_default, EXPR_COLUMN_FIRST);
+
 		/*
 		 * Make sure default expr does not refer to any vars.
 		 */
 		if (contain_var_clause(expr))
 			elog(ERROR, "Cannot use attribute(s) in DEFAULT clause");
+
 		/*
-		 * Check that it will be possible to coerce the expression
-		 * to the column's type.  We store the expression without
-		 * coercion, however, to avoid premature coercion in cases like
+		 * Check that it will be possible to coerce the expression to the
+		 * column's type.  We store the expression without coercion,
+		 * however, to avoid premature coercion in cases like
 		 *
 		 * CREATE TABLE tbl (fld datetime DEFAULT 'now');
 		 *
-		 * NB: this should match the code in updateTargetListEntry()
-		 * that will actually do the coercion, to ensure we don't accept
-		 * an unusable default expression.
+		 * NB: this should match the code in updateTargetListEntry() that
+		 * will actually do the coercion, to ensure we don't accept an
+		 * unusable default expression.
 		 */
 		type_id = exprType(expr);
 		if (type_id != InvalidOid)
@@ -1966,23 +1984,26 @@ AddRelationRawConstraints(Relation rel,
 			if (type_id != atp->atttypid)
 			{
 				if (CoerceTargetExpr(NULL, expr, type_id,
-									 atp->atttypid, atp->atttypmod) == NULL)
+								  atp->atttypid, atp->atttypmod) == NULL)
 					elog(ERROR, "Attribute '%s' is of type '%s'"
 						 " but default expression is of type '%s'"
-						 "\n\tYou will need to rewrite or cast the expression",
+					"\n\tYou will need to rewrite or cast the expression",
 						 NameStr(atp->attname),
 						 typeidTypeName(atp->atttypid),
 						 typeidTypeName(type_id));
 			}
 		}
+
 		/*
 		 * Might as well try to reduce any constant expressions.
 		 */
 		expr = eval_const_expressions(expr);
+
 		/*
 		 * Must fix opids, in case any operators remain...
 		 */
 		fix_opids(expr);
+
 		/*
 		 * OK, store it.
 		 */
@@ -2037,26 +2058,31 @@ AddRelationRawConstraints(Relation rel,
 			ccname = (char *) palloc(NAMEDATALEN);
 			snprintf(ccname, NAMEDATALEN, "$%d", numchecks + 1);
 		}
+
 		/*
 		 * Transform raw parsetree to executable expression.
 		 */
 		expr = transformExpr(pstate, cdef->raw_expr, EXPR_COLUMN_FIRST);
+
 		/*
 		 * Make sure it yields a boolean result.
 		 */
 		if (exprType(expr) != BOOLOID)
 			elog(ERROR, "CHECK '%s' does not yield boolean result",
 				 ccname);
+
 		/*
 		 * Make sure no outside relations are referred to.
 		 */
 		if (length(pstate->p_rtable) != 1)
 			elog(ERROR, "Only relation '%s' can be referenced in CHECK",
 				 relname);
+
 		/*
 		 * Might as well try to reduce any constant expressions.
 		 */
 		expr = eval_const_expressions(expr);
+
 		/*
 		 * Constraints are evaluated with execQual, which expects an
 		 * implicit-AND list, so convert expression to implicit-AND form.
@@ -2064,10 +2090,12 @@ AddRelationRawConstraints(Relation rel,
 		 * overkill...)
 		 */
 		expr = (Node *) make_ands_implicit((Expr *) expr);
+
 		/*
 		 * Must fix opids in operator clauses.
 		 */
 		fix_opids(expr);
+
 		/*
 		 * OK, store it.
 		 */
@@ -2081,12 +2109,12 @@ AddRelationRawConstraints(Relation rel,
 	 * We do this even if there was no change, in order to ensure that an
 	 * SI update message is sent out for the pg_class tuple, which will
 	 * force other backends to rebuild their relcache entries for the rel.
-	 * (Of course, for a newly created rel there is no need for an SI message,
-	 * but for ALTER TABLE ADD ATTRIBUTE this'd be important.)
+	 * (Of course, for a newly created rel there is no need for an SI
+	 * message, but for ALTER TABLE ADD ATTRIBUTE this'd be important.)
 	 */
 	relrel = heap_openr(RelationRelationName, RowExclusiveLock);
 	reltup = SearchSysCacheTupleCopy(RELOID,
-									 ObjectIdGetDatum(RelationGetRelid(rel)),
+								 ObjectIdGetDatum(RelationGetRelid(rel)),
 									 0, 0, 0);
 	if (!HeapTupleIsValid(reltup))
 		elog(ERROR, "cache lookup of relation %u failed", RelationGetRelid(rel));
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 2a4cd3e6c5efcb5c2e880a49c87da825e93327f0..a8c649bc82da57c3da3df977a2dc9f654b9092f7 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.107 2000/03/01 05:39:24 inoue Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.108 2000/04/12 17:14:55 momjian Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -56,37 +56,41 @@
 
 /* non-export function prototypes */
 static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName,
-		bool istemp);
+				   bool istemp);
 static TupleDesc BuildFuncTupleDesc(FuncIndexInfo *funcInfo);
 static TupleDesc ConstructTupleDescriptor(Oid heapoid, Relation heapRelation,
-		List *attributeList, int numatts, AttrNumber *attNums);
+				  List *attributeList, int numatts, AttrNumber *attNums);
 
 static void ConstructIndexReldesc(Relation indexRelation, Oid amoid);
 static Oid	UpdateRelationRelation(Relation indexRelation, char *temp_relname);
 static void InitializeAttributeOids(Relation indexRelation,
-		int numatts, Oid indexoid);
+						int numatts, Oid indexoid);
 static void AppendAttributeTuples(Relation indexRelation, int numatts);
 static void UpdateIndexRelation(Oid indexoid, Oid heapoid,
-		FuncIndexInfo *funcInfo, int natts,
-		AttrNumber *attNums, Oid *classOids, Node *predicate,
-		List *attributeList, bool islossy, bool unique, bool primary);
+					FuncIndexInfo *funcInfo, int natts,
+					AttrNumber *attNums, Oid *classOids, Node *predicate,
+		   List *attributeList, bool islossy, bool unique, bool primary);
 static void DefaultBuild(Relation heapRelation, Relation indexRelation,
-		int numberOfAttributes, AttrNumber *attributeNumber,
-		IndexStrategy indexStrategy, uint16 parameterCount,
+			 int numberOfAttributes, AttrNumber *attributeNumber,
+			 IndexStrategy indexStrategy, uint16 parameterCount,
 		Datum *parameter, FuncIndexInfoPtr funcInfo, PredInfo *predInfo);
-static Oid IndexGetRelation(Oid indexId);
+static Oid	IndexGetRelation(Oid indexId);
 
-static bool	reindexing = false;
-extern bool	SetReindexProcessing(bool reindexmode)
+static bool reindexing = false;
+extern bool
+SetReindexProcessing(bool reindexmode)
 {
-	bool	old = reindexing;
+	bool		old = reindexing;
+
 	reindexing = reindexmode;
 	return old;
 }
-extern bool	IsReindexProcessing(void)
+extern bool
+IsReindexProcessing(void)
 {
 	return reindexing;
 }
+
 /* ----------------------------------------------------------------
  *	  sysatts is a structure containing attribute tuple forms
  *	  for system attributes (numbered -1, -2, ...).  This really
@@ -1011,7 +1015,7 @@ index_create(char *heapRelationName,
 	 * ----------------
 	 */
 	indexRelation = heap_create(indexRelationName,
-				indexTupDesc, false, istemp, false);
+								indexTupDesc, false, istemp, false);
 
 	/* ----------------
 	 *	  construct the index relation descriptor
@@ -1075,9 +1079,9 @@ index_create(char *heapRelationName,
 	 * bootstrapping.  Otherwise, we call the routine that constructs the
 	 * index.
 	 *
-	 * In normal processing mode, the heap and index relations are closed
-	 * by index_build() --- but we continue to hold the ShareLock on the
-	 * heap that we acquired above, until end of transaction.
+	 * In normal processing mode, the heap and index relations are closed by
+	 * index_build() --- but we continue to hold the ShareLock on the heap
+	 * that we acquired above, until end of transaction.
 	 */
 	if (IsBootstrapProcessingMode())
 	{
@@ -1139,7 +1143,7 @@ index_drop(Oid indexId)
 	 *	they don't exist anyway.  So, no warning in that case.
 	 * ----------------
 	 */
-	if (IsTransactionBlock() && ! userIndexRelation->rd_myxactonly)
+	if (IsTransactionBlock() && !userIndexRelation->rd_myxactonly)
 		elog(NOTICE, "Caution: DROP INDEX cannot be rolled back, so don't abort now");
 
 	/* ----------------
@@ -1147,7 +1151,7 @@ index_drop(Oid indexId)
 	 * ----------------
 	 */
 	DeleteComments(indexId);
-	
+
 	/* ----------------
 	 * fix RELATION relation
 	 * ----------------
@@ -1267,15 +1271,16 @@ FormIndexDatum(int numberOfAttributes,
  * --------------------------------------------
  */
 static
-bool LockClassinfoForUpdate(Oid relid, HeapTuple rtup, Buffer *buffer, bool confirmCommitted)
+bool
+LockClassinfoForUpdate(Oid relid, HeapTuple rtup, Buffer *buffer, bool confirmCommitted)
 {
 	HeapTuple	classTuple;
-	Form_pg_class	pgcform;
+	Form_pg_class pgcform;
 	bool		test;
 	Relation	relationRelation;
 
 	classTuple = SearchSysCacheTuple(RELOID, PointerGetDatum(relid),
-							0, 0, 0);
+									 0, 0, 0);
 	if (!HeapTupleIsValid(classTuple))
 		return false;
 	rtup->t_self = classTuple->t_self;
@@ -1294,7 +1299,8 @@ bool LockClassinfoForUpdate(Oid relid, HeapTuple rtup, Buffer *buffer, bool conf
 	RelationInvalidateHeapTuple(relationRelation, rtup);
 	if (confirmCommitted)
 	{
-		HeapTupleHeader	th = rtup->t_data;
+		HeapTupleHeader th = rtup->t_data;
+
 		if (!(th->t_infomask & HEAP_XMIN_COMMITTED))
 			elog(ERROR, "The tuple isn't committed");
 		if (th->t_infomask & HEAP_XMAX_COMMITTED)
@@ -1309,28 +1315,29 @@ bool LockClassinfoForUpdate(Oid relid, HeapTuple rtup, Buffer *buffer, bool conf
  *		Indexes of the relation active ?
  * ---------------------------------------------
  */
-bool IndexesAreActive(Oid relid, bool confirmCommitted)
+bool
+IndexesAreActive(Oid relid, bool confirmCommitted)
 {
-	HeapTupleData	tuple;
+	HeapTupleData tuple;
 	Relation	indexRelation;
 	Buffer		buffer;
-	HeapScanDesc	scan;
-	ScanKeyData	entry;
+	HeapScanDesc scan;
+	ScanKeyData entry;
 	bool		isactive;
 
 	if (!LockClassinfoForUpdate(relid, &tuple, &buffer, confirmCommitted))
 		elog(ERROR, "IndexesAreActive couldn't lock %u", relid);
 	if (((Form_pg_class) GETSTRUCT(&tuple))->relkind != RELKIND_RELATION)
-		elog(ERROR, "relation %u isn't an relation", relid); 
+		elog(ERROR, "relation %u isn't an relation", relid);
 	isactive = ((Form_pg_class) GETSTRUCT(&tuple))->relhasindex;
 	ReleaseBuffer(buffer);
 	if (isactive)
 		return isactive;
 	indexRelation = heap_openr(IndexRelationName, AccessShareLock);
 	ScanKeyEntryInitialize(&entry, 0, Anum_pg_index_indrelid,
-			F_OIDEQ, ObjectIdGetDatum(relid));
+						   F_OIDEQ, ObjectIdGetDatum(relid));
 	scan = heap_beginscan(indexRelation, false, SnapshotNow,
-					1, &entry);
+						  1, &entry);
 	if (!heap_getnext(scan, 0))
 		isactive = true;
 	heap_endscan(scan);
@@ -1348,8 +1355,8 @@ setRelhasindexInplace(Oid relid, bool hasindex, bool immediate)
 	Relation	whichRel;
 	Relation	pg_class;
 	HeapTuple	tuple;
-	Form_pg_class	rd_rel;
-	HeapScanDesc	pg_class_scan = NULL;
+	Form_pg_class rd_rel;
+	HeapScanDesc pg_class_scan = NULL;
 
 	/* ----------------
 	 * This routine handles updates for only the heap relation
@@ -1384,7 +1391,7 @@ setRelhasindexInplace(Oid relid, bool hasindex, bool immediate)
 	if (!IsIgnoringSystemIndexes())
 	{
 		tuple = SearchSysCacheTupleCopy(RELOID,
-													ObjectIdGetDatum(relid), 0, 0, 0);
+										ObjectIdGetDatum(relid), 0, 0, 0);
 	}
 	else
 	{
@@ -1406,13 +1413,15 @@ setRelhasindexInplace(Oid relid, bool hasindex, bool immediate)
 		heap_close(pg_class, RowExclusiveLock);
 		elog(ERROR, "setRelhasindexInplace: cannot scan RELATION relation");
 	}
+
 	/*
-	 * Confirm that target tuple is locked by this transaction
-	 * in case of immedaite updation.
+	 * Confirm that target tuple is locked by this transaction in case of
+	 * immedaite updation.
 	 */
 	if (immediate)
 	{
-		HeapTupleHeader	th = tuple->t_data;
+		HeapTupleHeader th = tuple->t_data;
+
 		if (!(th->t_infomask & HEAP_XMIN_COMMITTED))
 			elog(ERROR, "Immediate hasindex updation can be done only for committed tuples %x", th->t_infomask);
 		if (th->t_infomask & HEAP_XMAX_INVALID)
@@ -1447,7 +1456,7 @@ setRelhasindexInplace(Oid relid, bool hasindex, bool immediate)
 	}
 	else
 	{
-		HeapTupleData	htup;
+		HeapTupleData htup;
 		Buffer		buffer;
 
 		htup.t_self = tuple->t_self;
@@ -1485,7 +1494,7 @@ UpdateStats(Oid relid, long reltuples, bool inplace)
 	Datum		values[Natts_pg_class];
 	char		nulls[Natts_pg_class];
 	char		replace[Natts_pg_class];
-	HeapScanDesc	pg_class_scan = NULL;
+	HeapScanDesc pg_class_scan = NULL;
 	bool		in_place_upd;
 
 	/* ----------------
@@ -1560,7 +1569,7 @@ UpdateStats(Oid relid, long reltuples, bool inplace)
 	 * pattern "CREATE TABLE; CREATE INDEX; insert data" leaves the table
 	 * with zero size statistics until a VACUUM is done.  The optimizer will
 	 * generate very bad plans if the stats claim the table is empty when
-	 * it is actually sizable.  See also CREATE TABLE in heap.c.
+	 * it is actually sizable.	See also CREATE TABLE in heap.c.
 	 * ----------------
 	 */
 	relpages = RelationGetNumberOfBlocks(whichRel);
@@ -1697,10 +1706,12 @@ DefaultBuild(Relation heapRelation,
 	char	   *nullv;
 	long		reltuples,
 				indtuples;
+
 #ifndef OMIT_PARTIAL_INDEX
 	ExprContext *econtext;
 	TupleTable	tupleTable;
 	TupleTableSlot *slot;
+
 #endif
 	Node	   *predicate;
 	Node	   *oldPred;
@@ -1781,6 +1792,7 @@ DefaultBuild(Relation heapRelation,
 		reltuples++;
 
 #ifndef OMIT_PARTIAL_INDEX
+
 		/*
 		 * If oldPred != NULL, this is an EXTEND INDEX command, so skip
 		 * this tuple if it was already in the existing partial index
@@ -1804,7 +1816,7 @@ DefaultBuild(Relation heapRelation,
 		{
 			/* SetSlotContents(slot, heapTuple); */
 			slot->val = heapTuple;
-			if (! ExecQual((List *) predicate, econtext, false))
+			if (!ExecQual((List *) predicate, econtext, false))
 				continue;
 		}
 #endif	 /* OMIT_PARTIAL_INDEX */
@@ -1854,18 +1866,18 @@ DefaultBuild(Relation heapRelation,
 	/*
 	 * Since we just counted the tuples in the heap, we update its stats
 	 * in pg_class to guarantee that the planner takes advantage of the
-	 * index we just created.  But, only update statistics during
-	 * normal index definitions, not for indices on system catalogs
-	 * created during bootstrap processing.  We must close the relations
-	 * before updating statistics to guarantee that the relcache entries
-	 * are flushed when we increment the command counter in UpdateStats().
-	 * But we do not release any locks on the relations; those will be
-	 * held until end of transaction.
+	 * index we just created.  But, only update statistics during normal
+	 * index definitions, not for indices on system catalogs created
+	 * during bootstrap processing.  We must close the relations before
+	 * updating statistics to guarantee that the relcache entries are
+	 * flushed when we increment the command counter in UpdateStats(). But
+	 * we do not release any locks on the relations; those will be held
+	 * until end of transaction.
 	 */
 	if (IsNormalProcessingMode())
 	{
-		Oid		hrelid = RelationGetRelid(heapRelation);
-		Oid		irelid = RelationGetRelid(indexRelation);
+		Oid			hrelid = RelationGetRelid(heapRelation);
+		Oid			irelid = RelationGetRelid(indexRelation);
 		bool		inplace = IsReindexProcessing();
 
 		heap_close(heapRelation, NoLock);
@@ -1936,7 +1948,7 @@ index_build(Relation heapRelation,
 
 /*
  * IndexGetRelation: given an index's relation OID, get the OID of the
- * relation it is an index on.  Uses the system cache.
+ * relation it is an index on.	Uses the system cache.
  */
 static Oid
 IndexGetRelation(Oid indexId)
@@ -2037,11 +2049,11 @@ IndexIsUniqueNoCache(Oid indexId)
 bool
 activate_index(Oid indexId, bool activate)
 {
-	if (!activate)	/* Currently does nothing */
+	if (!activate)				/* Currently does nothing */
 		return true;
 	return reindex_index(indexId, false);
 }
- 
+
 /* --------------------------------
  * reindex_index - This routine is used to recreate an index
  * --------------------------------
@@ -2049,18 +2061,26 @@ activate_index(Oid indexId, bool activate)
 bool
 reindex_index(Oid indexId, bool force)
 {
-	Relation	iRel, indexRelation, heapRelation;
-	ScanKeyData	entry;
-	HeapScanDesc	scan;
-	HeapTuple	indexTuple, procTuple, classTuple;
-	Form_pg_index	index;
-	Oid		heapId, procId, accessMethodId;
-	Node		*oldPred = NULL;
-	PredInfo	*predInfo;
-	AttrNumber	*attributeNumberA;
-	FuncIndexInfo	fInfo, *funcInfo = NULL;
-	int		i, numberOfAttributes;
-	char		*predString;
+	Relation	iRel,
+				indexRelation,
+				heapRelation;
+	ScanKeyData entry;
+	HeapScanDesc scan;
+	HeapTuple	indexTuple,
+				procTuple,
+				classTuple;
+	Form_pg_index index;
+	Oid			heapId,
+				procId,
+				accessMethodId;
+	Node	   *oldPred = NULL;
+	PredInfo   *predInfo;
+	AttrNumber *attributeNumberA;
+	FuncIndexInfo fInfo,
+			   *funcInfo = NULL;
+	int			i,
+				numberOfAttributes;
+	char	   *predString;
 	bool		old;
 
 	old = SetReindexProcessing(true);
@@ -2135,7 +2155,7 @@ reindex_index(Oid indexId, bool force)
 	LockRelation(iRel, AccessExclusiveLock);
 
 	/*
-	 * Release any buffers associated with this index.  If they're dirty,
+	 * Release any buffers associated with this index.	If they're dirty,
 	 * they're just dropped without bothering to flush to disk.
 	 */
 	ReleaseRelationBuffers(iRel);
@@ -2149,14 +2169,13 @@ reindex_index(Oid indexId, bool force)
 	/* Initialize the index and rebuild */
 	InitIndexStrategy(numberOfAttributes, iRel, accessMethodId);
 	index_build(heapRelation, iRel, numberOfAttributes,
-			attributeNumberA, 0, NULL, funcInfo, predInfo);
+				attributeNumberA, 0, NULL, funcInfo, predInfo);
 
 	/*
-	 * index_build will close both the heap and index relations
-	 * (but not give up the locks we hold on them).  That's fine
-	 * for the index, but we need to open the heap again.  We need
-	 * no new lock, since this backend still has the exclusive lock
-	 * grabbed by heap_truncate.
+	 * index_build will close both the heap and index relations (but not
+	 * give up the locks we hold on them).	That's fine for the index, but
+	 * we need to open the heap again.	We need no new lock, since this
+	 * backend still has the exclusive lock grabbed by heap_truncate.
 	 */
 	iRel = index_open(indexId);
 	Assert(iRel != NULL);
@@ -2170,7 +2189,7 @@ reindex_index(Oid indexId, bool force)
 
 /*
  * ----------------------------
- * activate_indexes_of_a_table  
+ * activate_indexes_of_a_table
  *	activate/deactivate indexes of the specified table.
  * ----------------------------
  */
@@ -2182,21 +2201,18 @@ activate_indexes_of_a_table(Oid relid, bool activate)
 		if (!activate)
 			setRelhasindexInplace(relid, false, true);
 		else
-		{
 			return false;
-		}
 	}
 	else
 	{
 		if (activate)
 			reindex_relation(relid, false);
 		else
-		{
 			return false;
-		}	
 	}
 	return true;
 }
+
 /* --------------------------------
  * reindex_relation - This routine is used to recreate indexes
  * of a relation.
@@ -2206,10 +2222,11 @@ bool
 reindex_relation(Oid relid, bool force)
 {
 	Relation	indexRelation;
-	ScanKeyData	entry;
-	HeapScanDesc	scan;
+	ScanKeyData entry;
+	HeapScanDesc scan;
 	HeapTuple	indexTuple;
-	bool		old, reindexed;
+	bool		old,
+				reindexed;
 
 	old = SetReindexProcessing(true);
 	if (IndexesAreActive(relid, true))
@@ -2224,13 +2241,14 @@ reindex_relation(Oid relid, bool force)
 
 	indexRelation = heap_openr(IndexRelationName, AccessShareLock);
 	ScanKeyEntryInitialize(&entry, 0, Anum_pg_index_indrelid,
-			F_OIDEQ, ObjectIdGetDatum(relid));
+						   F_OIDEQ, ObjectIdGetDatum(relid));
 	scan = heap_beginscan(indexRelation, false, SnapshotNow,
-					1, &entry);
+						  1, &entry);
 	reindexed = false;
 	while (HeapTupleIsValid(indexTuple = heap_getnext(scan, 0)))
 	{
-		Form_pg_index	index = (Form_pg_index) GETSTRUCT(indexTuple);
+		Form_pg_index index = (Form_pg_index) GETSTRUCT(indexTuple);
+
 		if (activate_index(index->indexrelid, true))
 			reindexed = true;
 		else
@@ -2242,9 +2260,7 @@ reindex_relation(Oid relid, bool force)
 	heap_endscan(scan);
 	heap_close(indexRelation, AccessShareLock);
 	if (reindexed)
-	{
 		setRelhasindexInplace(relid, true, false);
-	}
 	SetReindexProcessing(old);
 	return reindexed;
 }
diff --git a/src/backend/catalog/indexing.c b/src/backend/catalog/indexing.c
index 41337da77f8a469b682fc764b24d857fc97a18fd..eb3d6debcc585e2452abf7324b804f8b8bf4b950 100644
--- a/src/backend/catalog/indexing.c
+++ b/src/backend/catalog/indexing.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.59 2000/02/18 09:28:41 inoue Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.60 2000/04/12 17:14:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -31,54 +31,54 @@
  */
 
 char	   *Name_pg_aggregate_indices[Num_pg_aggregate_indices] =
-			{AggregateNameTypeIndex};
+{AggregateNameTypeIndex};
 char	   *Name_pg_am_indices[Num_pg_am_indices] =
-			{AmNameIndex};
+{AmNameIndex};
 char	   *Name_pg_amop_indices[Num_pg_amop_indices] =
-		 	{AccessMethodOpidIndex, AccessMethodStrategyIndex};
+{AccessMethodOpidIndex, AccessMethodStrategyIndex};
 char	   *Name_pg_attr_indices[Num_pg_attr_indices] =
-		 	{AttributeRelidNameIndex, AttributeRelidNumIndex};
+{AttributeRelidNameIndex, AttributeRelidNumIndex};
 char	   *Name_pg_attrdef_indices[Num_pg_attrdef_indices] =
-		 	{AttrDefaultIndex};
+{AttrDefaultIndex};
 char	   *Name_pg_class_indices[Num_pg_class_indices] =
-		 	{ClassNameIndex, ClassOidIndex};
+{ClassNameIndex, ClassOidIndex};
 char	   *Name_pg_group_indices[Num_pg_group_indices] =
-		 	{GroupNameIndex, GroupSysidIndex};
+{GroupNameIndex, GroupSysidIndex};
 char	   *Name_pg_index_indices[Num_pg_index_indices] =
-		 	{IndexRelidIndex};
+{IndexRelidIndex};
 char	   *Name_pg_inherits_indices[Num_pg_inherits_indices] =
-		 	{InheritsRelidSeqnoIndex};
+{InheritsRelidSeqnoIndex};
 char	   *Name_pg_language_indices[Num_pg_language_indices] =
-		 	{LanguageOidIndex, LanguageNameIndex};
+{LanguageOidIndex, LanguageNameIndex};
 char	   *Name_pg_listener_indices[Num_pg_listener_indices] =
-		 	{ListenerRelnamePidIndex};
+{ListenerRelnamePidIndex};
 char	   *Name_pg_opclass_indices[Num_pg_opclass_indices] =
-		 	{OpclassNameIndex, OpclassDeftypeIndex};
+{OpclassNameIndex, OpclassDeftypeIndex};
 char	   *Name_pg_operator_indices[Num_pg_operator_indices] =
-		 	{OperatorOidIndex, OperatorNameIndex};
+{OperatorOidIndex, OperatorNameIndex};
 char	   *Name_pg_proc_indices[Num_pg_proc_indices] =
-		 	{ProcedureOidIndex, ProcedureNameIndex};
+{ProcedureOidIndex, ProcedureNameIndex};
 char	   *Name_pg_relcheck_indices[Num_pg_relcheck_indices] =
-		 	{RelCheckIndex};
+{RelCheckIndex};
 char	   *Name_pg_rewrite_indices[Num_pg_rewrite_indices] =
-		 	{RewriteOidIndex, RewriteRulenameIndex};
+{RewriteOidIndex, RewriteRulenameIndex};
 char	   *Name_pg_shadow_indices[Num_pg_shadow_indices] =
-		 	{ShadowNameIndex, ShadowSysidIndex};
+{ShadowNameIndex, ShadowSysidIndex};
 char	   *Name_pg_statistic_indices[Num_pg_statistic_indices] =
-		 	{StatisticRelidAttnumIndex};
+{StatisticRelidAttnumIndex};
 char	   *Name_pg_trigger_indices[Num_pg_trigger_indices] =
-		 	{TriggerRelidIndex,	TriggerConstrNameIndex, TriggerConstrRelidIndex};
+{TriggerRelidIndex, TriggerConstrNameIndex, TriggerConstrRelidIndex};
 char	   *Name_pg_type_indices[Num_pg_type_indices] =
-		 	{TypeNameIndex, TypeOidIndex};
-char       *Name_pg_description_indices[Num_pg_description_indices] =
-		 	{DescriptionObjIndex};
+{TypeNameIndex, TypeOidIndex};
+char	   *Name_pg_description_indices[Num_pg_description_indices] =
+{DescriptionObjIndex};
 
 
 
 static HeapTuple CatalogIndexFetchTuple(Relation heapRelation,
-										   Relation idesc,
-										   ScanKey skey,
-										   int16 num_keys);
+					   Relation idesc,
+					   ScanKey skey,
+					   int16 num_keys);
 
 
 /*
@@ -279,7 +279,7 @@ CatalogIndexFetchTuple(Relation heapRelation,
 
 
 /*---------------------------------------------------------------------
- *                       Class-specific index lookups
+ *						 Class-specific index lookups
  *---------------------------------------------------------------------
  */
 
@@ -297,7 +297,7 @@ AggregateNameTypeIndexScan(Relation heapRelation, char *aggName, Oid aggType)
 	Relation	idesc;
 	ScanKeyData skey[2];
 	HeapTuple	tuple;
-	
+
 	ScanKeyEntryInitialize(&skey[0],
 						   (bits16) 0x0,
 						   (AttrNumber) 1,
@@ -324,7 +324,7 @@ AmNameIndexScan(Relation heapRelation, char *amName)
 	Relation	idesc;
 	ScanKeyData skey[1];
 	HeapTuple	tuple;
-	
+
 	ScanKeyEntryInitialize(&skey[0],
 						   (bits16) 0x0,
 						   (AttrNumber) 1,
@@ -414,8 +414,8 @@ AccessMethodStrategyIndexScan(Relation heapRelation,
 
 HeapTuple
 AttributeRelidNameIndexScan(Relation heapRelation,
-					   Oid relid,
-					   char *attname)
+							Oid relid,
+							char *attname)
 {
 	Relation	idesc;
 	ScanKeyData skey[2];
@@ -444,8 +444,8 @@ AttributeRelidNameIndexScan(Relation heapRelation,
 
 HeapTuple
 AttributeRelidNumIndexScan(Relation heapRelation,
-					  Oid relid,
-					  AttrNumber attnum)
+						   Oid relid,
+						   AttrNumber attnum)
 {
 	Relation	idesc;
 	ScanKeyData skey[2];
@@ -500,7 +500,7 @@ OpclassNameIndexScan(Relation heapRelation, char *opcName)
 	Relation	idesc;
 	ScanKeyData skey[1];
 	HeapTuple	tuple;
-	
+
 	ScanKeyEntryInitialize(&skey[0],
 						   (bits16) 0x0,
 						   (AttrNumber) 1,
@@ -521,7 +521,7 @@ GroupNameIndexScan(Relation heapRelation, char *groName)
 	Relation	idesc;
 	ScanKeyData skey[1];
 	HeapTuple	tuple;
-	
+
 	ScanKeyEntryInitialize(&skey[0],
 						   (bits16) 0x0,
 						   (AttrNumber) 1,
@@ -542,7 +542,7 @@ GroupSysidIndexScan(Relation heapRelation, int4 sysId)
 	Relation	idesc;
 	ScanKeyData skey[1];
 	HeapTuple	tuple;
-	
+
 	ScanKeyEntryInitialize(&skey[0],
 						   (bits16) 0x0,
 						   (AttrNumber) 1,
@@ -581,8 +581,8 @@ IndexRelidIndexScan(Relation heapRelation, Oid relid)
 
 HeapTuple
 InheritsRelidSeqnoIndexScan(Relation heapRelation,
-						   Oid relid,
-						   int4 seqno)
+							Oid relid,
+							int4 seqno)
 {
 	Relation	idesc;
 	ScanKeyData skey[2];
@@ -615,7 +615,7 @@ LanguageNameIndexScan(Relation heapRelation, char *lanName)
 	Relation	idesc;
 	ScanKeyData skey[1];
 	HeapTuple	tuple;
-	
+
 	ScanKeyEntryInitialize(&skey[0],
 						   (bits16) 0x0,
 						   (AttrNumber) 1,
@@ -658,7 +658,7 @@ ListenerRelnamePidIndexScan(Relation heapRelation, char *relName, int4 pid)
 	Relation	idesc;
 	ScanKeyData skey[2];
 	HeapTuple	tuple;
-	
+
 	ScanKeyEntryInitialize(&skey[0],
 						   (bits16) 0x0,
 						   (AttrNumber) 1,
@@ -681,10 +681,10 @@ ListenerRelnamePidIndexScan(Relation heapRelation, char *relName, int4 pid)
 
 HeapTuple
 OperatorNameIndexScan(Relation heapRelation,
-					   char *oprName,
-					   Oid   oprLeft,
-					   Oid   oprRight,
-                       char  oprKind)
+					  char *oprName,
+					  Oid oprLeft,
+					  Oid oprRight,
+					  char oprKind)
 {
 	Relation	idesc;
 	ScanKeyData skey[4];
@@ -810,7 +810,7 @@ ClassNameIndexScan(Relation heapRelation, char *relName)
 	Relation	idesc;
 	ScanKeyData skey[1];
 	HeapTuple	tuple;
-	
+
 	ScanKeyEntryInitialize(&skey[0],
 						   (bits16) 0x0,
 						   (AttrNumber) 1,
@@ -853,7 +853,7 @@ RewriteRulenameIndexScan(Relation heapRelation, char *ruleName)
 	Relation	idesc;
 	ScanKeyData skey[1];
 	HeapTuple	tuple;
-	
+
 	ScanKeyEntryInitialize(&skey[0],
 						   (bits16) 0x0,
 						   (AttrNumber) 1,
@@ -896,7 +896,7 @@ ShadowNameIndexScan(Relation heapRelation, char *useName)
 	Relation	idesc;
 	ScanKeyData skey[1];
 	HeapTuple	tuple;
-	
+
 	ScanKeyEntryInitialize(&skey[0],
 						   (bits16) 0x0,
 						   (AttrNumber) 1,
@@ -917,7 +917,7 @@ ShadowSysidIndexScan(Relation heapRelation, int4 sysId)
 	Relation	idesc;
 	ScanKeyData skey[1];
 	HeapTuple	tuple;
-	
+
 	ScanKeyEntryInitialize(&skey[0],
 						   (bits16) 0x0,
 						   (AttrNumber) 1,
@@ -934,8 +934,8 @@ ShadowSysidIndexScan(Relation heapRelation, int4 sysId)
 
 HeapTuple
 StatisticRelidAttnumIndexScan(Relation heapRelation,
-					   Oid relId,
-					   AttrNumber attNum)
+							  Oid relId,
+							  AttrNumber attNum)
 {
 	Relation	idesc;
 	ScanKeyData skey[2];
@@ -1004,4 +1004,3 @@ TypeOidIndexScan(Relation heapRelation, Oid typeId)
 
 	return tuple;
 }
-
diff --git a/src/backend/catalog/pg_aggregate.c b/src/backend/catalog/pg_aggregate.c
index 5554752bf3fdbe19e477150a6e026598151b5247..79d796ab49d692145c5b818d76303b4a37d5a28f 100644
--- a/src/backend/catalog/pg_aggregate.c
+++ b/src/backend/catalog/pg_aggregate.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.30 2000/03/26 19:43:58 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.31 2000/04/12 17:14:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -168,7 +168,7 @@ AggregateCreate(char *aggName,
 	/* handle finalfn */
 	if (aggfinalfnName)
 	{
-		int	nargs = 0;
+		int			nargs = 0;
 
 		if (OidIsValid(xret1))
 			fnArgs[nargs++] = xret1;
@@ -184,7 +184,7 @@ AggregateCreate(char *aggName,
 		{
 			if (nargs == 2)
 				elog(ERROR, "AggregateCreate: '%s'('%s','%s') does not exist",
-					 aggfinalfnName, aggtransfn1typeName, aggtransfn2typeName);
+				aggfinalfnName, aggtransfn1typeName, aggtransfn2typeName);
 			else if (OidIsValid(xret1))
 				elog(ERROR, "AggregateCreate: '%s'('%s') does not exist",
 					 aggfinalfnName, aggtransfn1typeName);
@@ -200,8 +200,10 @@ AggregateCreate(char *aggName,
 	}
 	else
 	{
-		/* If no finalfn, aggregate result type is type of the sole
-		 * state value (we already checked there is only one)
+
+		/*
+		 * If no finalfn, aggregate result type is type of the sole state
+		 * value (we already checked there is only one)
 		 */
 		if (OidIsValid(xret1))
 			fret = xret1;
@@ -284,9 +286,9 @@ AggNameGetInitVal(char *aggName, Oid basetype, int xfuncno, bool *isNull)
 	Assert(xfuncno == 1 || xfuncno == 2);
 
 	/*
-	 * since we will have to use fastgetattr (in case one or both init vals
-	 * are NULL), we will need to open the relation.  Do that first to
-	 * ensure we don't get a stale tuple from the cache.
+	 * since we will have to use fastgetattr (in case one or both init
+	 * vals are NULL), we will need to open the relation.  Do that first
+	 * to ensure we don't get a stale tuple from the cache.
 	 */
 
 	aggRel = heap_openr(AggregateRelationName, AccessShareLock);
diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c
index 6557335d994b0bd8dfb3695d3a518556dc2e7caf..aa23a3be8c2d9718541d050457d1d63ec402ad6c 100644
--- a/src/backend/catalog/pg_proc.c
+++ b/src/backend/catalog/pg_proc.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.41 2000/04/04 21:44:37 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.42 2000/04/12 17:14:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -154,7 +154,7 @@ ProcedureCreate(char *procedureName,
 				return tup->t_data->t_oid;
 #else
 			elog(ERROR, "lookup for procedure by source needs fix (Jan)");
-#endif /* SETS_FIXED */
+#endif	 /* SETS_FIXED */
 		}
 	}
 
@@ -245,7 +245,7 @@ ProcedureCreate(char *procedureName,
 			prosrc = procedureName;
 		if (fmgr_lookupByName(prosrc) == (func_ptr) NULL)
 			elog(ERROR,
-				 "ProcedureCreate: there is no builtin function named \"%s\"",
+			"ProcedureCreate: there is no builtin function named \"%s\"",
 				 prosrc);
 	}
 
diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c
index a4e970fbfc48bf16315e3a7258e69a19425857c4..4c3120c40f4015b02de9a7602eeb159573d9b024 100644
--- a/src/backend/catalog/pg_type.c
+++ b/src/backend/catalog/pg_type.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.49 2000/01/26 05:56:11 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.50 2000/04/12 17:14:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -374,7 +374,7 @@ TypeCreate(char *typeName,
 	values[i++] = (Datum) GetUserId();	/* 2 */
 	values[i++] = (Datum) internalSize; /* 3 */
 	values[i++] = (Datum) externalSize; /* 4 */
-	values[i++] = (Datum) passedByValue;/* 5 */
+	values[i++] = (Datum) passedByValue;		/* 5 */
 	values[i++] = (Datum) typeType;		/* 6 */
 	values[i++] = (Datum) (bool) 1;		/* 7 */
 	values[i++] = (Datum) typDelim;		/* 8 */
diff --git a/src/backend/commands/_deadcode/recipe.c b/src/backend/commands/_deadcode/recipe.c
index 6fd21c9e57d2e8b84df77a321a032df06ac16a3c..a0b87743f5b24a32a43bbff26ccce77fa413b953 100644
--- a/src/backend/commands/_deadcode/recipe.c
+++ b/src/backend/commands/_deadcode/recipe.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.10 2000/01/26 05:56:17 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.11 2000/04/12 17:15:06 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -702,7 +702,7 @@ getParamTypes(TgElement * elem, Oid *typev)
 		if (parameterCount == FUNC_MAX_ARGS)
 		{
 			elog(ERROR,
-				 "getParamTypes: Ingredients cannot take > %d arguments",FUNC_MAX_ARGS);
+				 "getParamTypes: Ingredients cannot take > %d arguments", FUNC_MAX_ARGS);
 		}
 		t = elem->inTypes->val[j];
 		if (strcmp(t, "opaque") == 0)
@@ -810,7 +810,7 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo)
 {
 	TgElement  *elem;
 	char	   *funcName;
-	Oid			typev[FUNC_MAX_ARGS],		/* eight arguments maximum	*/
+	Oid			typev[FUNC_MAX_ARGS],	/* eight arguments maximum	*/
 				relid;
 	int			i,
 				parameterCount;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index e7cf7ac6748d8cb186bff18f0378250f35f894e7..f6079885fa718bfcf42f19a3d1ccac9f6fc73876 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.58 2000/01/26 05:56:12 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.59 2000/04/12 17:14:57 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -155,12 +155,13 @@ Async_Notify(char *relname)
 	/* no point in making duplicate entries in the list ... */
 	if (!AsyncExistsPendingNotify(relname))
 	{
+
 		/*
 		 * We allocate list memory from the global malloc pool to ensure
-		 * that it will live until we want to use it.  This is probably not
-		 * necessary any longer, since we will use it before the end of the
-		 * transaction. DLList only knows how to use malloc() anyway, but we
-		 * could probably palloc() the strings...
+		 * that it will live until we want to use it.  This is probably
+		 * not necessary any longer, since we will use it before the end
+		 * of the transaction. DLList only knows how to use malloc()
+		 * anyway, but we could probably palloc() the strings...
 		 */
 		notifyName = strdup(relname);
 		DLAddHead(pendingNotifies, DLNewElem(notifyName));
@@ -466,6 +467,7 @@ AtCommit_Notify()
 
 			if (listenerPID == MyProcPid)
 			{
+
 				/*
 				 * Self-notify: no need to bother with table update.
 				 * Indeed, we *must not* clear the notification field in
@@ -491,6 +493,7 @@ AtCommit_Notify()
 				 */
 				if (kill(listenerPID, SIGUSR2) < 0)
 				{
+
 					/*
 					 * Get rid of pg_listener entry if it refers to a PID
 					 * that no longer exists.  Presumably, that backend
@@ -514,7 +517,7 @@ AtCommit_Notify()
 						if (RelationGetForm(lRel)->relhasindex)
 						{
 							Relation	idescs[Num_pg_listener_indices];
-					
+
 							CatalogOpenIndices(Num_pg_listener_indices, Name_pg_listener_indices, idescs);
 							CatalogIndexInsert(idescs, Num_pg_listener_indices, lRel, rTuple);
 							CatalogCloseIndices(Num_pg_listener_indices, idescs);
@@ -780,7 +783,7 @@ ProcessIncomingNotify(void)
 			if (RelationGetForm(lRel)->relhasindex)
 			{
 				Relation	idescs[Num_pg_listener_indices];
-		
+
 				CatalogOpenIndices(Num_pg_listener_indices, Name_pg_listener_indices, idescs);
 				CatalogIndexInsert(idescs, Num_pg_listener_indices, lRel, rTuple);
 				CatalogCloseIndices(Num_pg_listener_indices, idescs);
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index 299101337f1cc274c6b928b7be54d5049e401384..0cbf4a2177b29698af4ad906ceccd06f53481847 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -15,7 +15,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.50 2000/01/26 05:56:13 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.51 2000/04/12 17:14:57 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -104,8 +104,8 @@ cluster(char *oldrelname, char *oldindexname)
 	 * Like vacuum, cluster spans transactions, so I'm going to handle it
 	 * in the same way: commit and restart transactions where needed.
 	 *
-	 * We grab exclusive access to the target rel and index for the
-	 * duration of the initial transaction.
+	 * We grab exclusive access to the target rel and index for the duration
+	 * of the initial transaction.
 	 */
 
 	OldHeap = heap_openr(oldrelname, AccessExclusiveLock);
@@ -115,7 +115,7 @@ cluster(char *oldrelname, char *oldindexname)
 	LockRelation(OldIndex, AccessExclusiveLock);
 	OIDOldIndex = RelationGetRelid(OldIndex);
 
-	heap_close(OldHeap, NoLock); /* do NOT give up the locks */
+	heap_close(OldHeap, NoLock);/* do NOT give up the locks */
 	index_close(OldIndex);
 
 	/*
diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c
index b75f3840a879a819b2e541aac5b2a07d314e5421..2b9f6a257b12f87bc800374ee0a0a8dc80ea6c29 100644
--- a/src/backend/commands/command.c
+++ b/src/backend/commands/command.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.70 2000/03/09 05:00:23 inoue Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.71 2000/04/12 17:14:57 momjian Exp $
  *
  * NOTES
  *	  The PortalExecutorHeapMemory crap needs to be eliminated
@@ -51,7 +51,7 @@
 #include "access/genam.h"
 #include "optimizer/clauses.h"
 #include "../parser/parse.h"
-#endif	/* _DROP_COLUMN_HACK__ */
+#endif	 /* _DROP_COLUMN_HACK__ */
 
 /* ----------------
  *		PortalExecutorHeapMemory stuff
@@ -262,7 +262,7 @@ PerformPortalClose(char *name, CommandDest dest)
 }
 
 /* ----------------
- *      AlterTableAddColumn
+ *		AlterTableAddColumn
  *		(formerly known as PerformAddAttribute)
  *
  *		adds an additional attribute to a relation
@@ -327,8 +327,8 @@ AlterTableAddColumn(const char *relationName,
 #endif
 
 	/*
-	 * Grab an exclusive lock on the target table, which we will NOT release
-	 * until end of transaction.
+	 * Grab an exclusive lock on the target table, which we will NOT
+	 * release until end of transaction.
 	 */
 	rel = heap_openr(relationName, AccessExclusiveLock);
 	myrelid = RelationGetRelid(rel);
@@ -341,7 +341,7 @@ AlterTableAddColumn(const char *relationName,
 		elog(ERROR, "Can't add a NOT NULL attribute to an existing relation");
 
 	if (colDef->raw_default || colDef->cooked_default)
-        elog(ERROR, "Adding columns with defaults is not implemented.");
+		elog(ERROR, "Adding columns with defaults is not implemented.");
 
 
 	/*
@@ -370,7 +370,7 @@ AlterTableAddColumn(const char *relationName,
 			 */
 			foreach(child, children)
 			{
-				Oid		childrelid = lfirsti(child);
+				Oid			childrelid = lfirsti(child);
 
 				if (childrelid == myrelid)
 					continue;
@@ -514,13 +514,13 @@ static void drop_default(Oid relid, int16 attnum);
  */
 void
 AlterTableAlterColumn(const char *relationName,
-                      bool inh, const char *colName,
-                      Node *newDefault)
+					  bool inh, const char *colName,
+					  Node *newDefault)
 {
-    Relation rel;
-    HeapTuple tuple;
-    int16 attnum;
-    Oid myrelid;
+	Relation	rel;
+	HeapTuple	tuple;
+	int16		attnum;
+	Oid			myrelid;
 
 	if (!allowSystemTableMods && IsSystemRelationName(relationName))
 		elog(ERROR, "ALTER TABLE: relation \"%s\" is a system catalog",
@@ -530,121 +530,122 @@ AlterTableAlterColumn(const char *relationName,
 		elog(ERROR, "ALTER TABLE: permission denied");
 #endif
 
-    rel = heap_openr(relationName, AccessExclusiveLock);
-    myrelid = RelationGetRelid(rel);
-    heap_close(rel, NoLock);
+	rel = heap_openr(relationName, AccessExclusiveLock);
+	myrelid = RelationGetRelid(rel);
+	heap_close(rel, NoLock);
 
-    /*
-     * Propagate to children if desired
-     */
+	/*
+	 * Propagate to children if desired
+	 */
 	if (inh)
-    {
-        List	   *child,
-            *children;
-
-        /* this routine is actually in the planner */
-        children = find_all_inheritors(myrelid);
-
-        /*
-         * find_all_inheritors does the recursive search of the
-         * inheritance hierarchy, so all we have to do is process all
-         * of the relids in the list that it returns.
-         */
-        foreach(child, children)
+	{
+		List	   *child,
+				   *children;
+
+		/* this routine is actually in the planner */
+		children = find_all_inheritors(myrelid);
+
+		/*
+		 * find_all_inheritors does the recursive search of the
+		 * inheritance hierarchy, so all we have to do is process all of
+		 * the relids in the list that it returns.
+		 */
+		foreach(child, children)
 		{
-            Oid		childrelid = lfirsti(child);
-
-            if (childrelid == myrelid)
-                continue;
-            rel = heap_open(childrelid, AccessExclusiveLock);
-            AlterTableAlterColumn(RelationGetRelationName(rel),
-                                  false, colName, newDefault);
-            heap_close(rel, AccessExclusiveLock);
-        }
-    }
-
-    /* -= now do the thing on this relation =- */
-
-    /* reopen the business */
-    rel = heap_openr((char *)relationName, AccessExclusiveLock);
-
-    /*
-     * get the number of the attribute
-     */
-    tuple = SearchSysCacheTuple(ATTNAME,
-                                ObjectIdGetDatum(myrelid),
-                                NameGetDatum(namein((char *)colName)),
-                                0, 0);
-
-    if (!HeapTupleIsValid(tuple))
-    {
-        heap_close(rel, AccessExclusiveLock);
-        elog(ERROR, "ALTER TABLE: relation \"%s\" has no column \"%s\"",
-             relationName, colName);
-    }
-
-    attnum = ((Form_pg_attribute) GETSTRUCT(tuple))->attnum;
-
-    if (newDefault) /* SET DEFAULT */
-    {
-        List* rawDefaults = NIL;
-   		RawColumnDefault *rawEnt;
-
-        /* Get rid of the old one first */
-        drop_default(myrelid, attnum);
+			Oid			childrelid = lfirsti(child);
+
+			if (childrelid == myrelid)
+				continue;
+			rel = heap_open(childrelid, AccessExclusiveLock);
+			AlterTableAlterColumn(RelationGetRelationName(rel),
+								  false, colName, newDefault);
+			heap_close(rel, AccessExclusiveLock);
+		}
+	}
+
+	/* -= now do the thing on this relation =- */
+
+	/* reopen the business */
+	rel = heap_openr((char *) relationName, AccessExclusiveLock);
+
+	/*
+	 * get the number of the attribute
+	 */
+	tuple = SearchSysCacheTuple(ATTNAME,
+								ObjectIdGetDatum(myrelid),
+								NameGetDatum(namein((char *) colName)),
+								0, 0);
+
+	if (!HeapTupleIsValid(tuple))
+	{
+		heap_close(rel, AccessExclusiveLock);
+		elog(ERROR, "ALTER TABLE: relation \"%s\" has no column \"%s\"",
+			 relationName, colName);
+	}
+
+	attnum = ((Form_pg_attribute) GETSTRUCT(tuple))->attnum;
+
+	if (newDefault)				/* SET DEFAULT */
+	{
+		List	   *rawDefaults = NIL;
+		RawColumnDefault *rawEnt;
+
+		/* Get rid of the old one first */
+		drop_default(myrelid, attnum);
 
 		rawEnt = (RawColumnDefault *) palloc(sizeof(RawColumnDefault));
 		rawEnt->attnum = attnum;
-        rawEnt->raw_default = newDefault;
+		rawEnt->raw_default = newDefault;
 		rawDefaults = lappend(rawDefaults, rawEnt);
 
-        /*
-         * This function is intended for CREATE TABLE,
-         * so it processes a _list_ of defaults, but we just do one.
-         */
-        AddRelationRawConstraints(rel, rawDefaults, NIL);
-    }
-
-    else /* DROP DEFAULT */
-    {
-        Relation attr_rel;
-        ScanKeyData scankeys[3];
-        HeapScanDesc scan;
-        HeapTuple tuple;
-
-        attr_rel = heap_openr(AttributeRelationName, AccessExclusiveLock);
-        ScanKeyEntryInitialize(&scankeys[0], 0x0, Anum_pg_attribute_attrelid, F_OIDEQ,
-                               ObjectIdGetDatum(myrelid));
-        ScanKeyEntryInitialize(&scankeys[1], 0x0, Anum_pg_attribute_attnum, F_INT2EQ,
-                               Int16GetDatum(attnum));
-        ScanKeyEntryInitialize(&scankeys[2], 0x0, Anum_pg_attribute_atthasdef, F_BOOLEQ,
-                               TRUE);
-
-        scan = heap_beginscan(attr_rel, false, SnapshotNow, 3, scankeys);
-        AssertState(scan!=NULL);
-
-        if (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
-        {
-            HeapTuple newtuple;
-            Relation	irelations[Num_pg_attr_indices];
-
-            /* update to false */
-            newtuple = heap_copytuple(tuple);
-            ((Form_pg_attribute) GETSTRUCT(newtuple))->atthasdef = FALSE;
-            heap_update(attr_rel, &tuple->t_self, newtuple, NULL);
-
-            /* keep the system catalog indices current */
-            CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, irelations);
-            CatalogIndexInsert(irelations, Num_pg_attr_indices, attr_rel, newtuple);
-            CatalogCloseIndices(Num_pg_attr_indices, irelations);
-
-            /* get rid of actual default definition */
-            drop_default(myrelid, attnum);
-        }
-
-        heap_endscan(scan);
-        heap_close(attr_rel, NoLock);
-    }
+		/*
+		 * This function is intended for CREATE TABLE, so it processes a
+		 * _list_ of defaults, but we just do one.
+		 */
+		AddRelationRawConstraints(rel, rawDefaults, NIL);
+	}
+
+	else
+/* DROP DEFAULT */
+	{
+		Relation	attr_rel;
+		ScanKeyData scankeys[3];
+		HeapScanDesc scan;
+		HeapTuple	tuple;
+
+		attr_rel = heap_openr(AttributeRelationName, AccessExclusiveLock);
+		ScanKeyEntryInitialize(&scankeys[0], 0x0, Anum_pg_attribute_attrelid, F_OIDEQ,
+							   ObjectIdGetDatum(myrelid));
+		ScanKeyEntryInitialize(&scankeys[1], 0x0, Anum_pg_attribute_attnum, F_INT2EQ,
+							   Int16GetDatum(attnum));
+		ScanKeyEntryInitialize(&scankeys[2], 0x0, Anum_pg_attribute_atthasdef, F_BOOLEQ,
+							   TRUE);
+
+		scan = heap_beginscan(attr_rel, false, SnapshotNow, 3, scankeys);
+		AssertState(scan != NULL);
+
+		if (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
+		{
+			HeapTuple	newtuple;
+			Relation	irelations[Num_pg_attr_indices];
+
+			/* update to false */
+			newtuple = heap_copytuple(tuple);
+			((Form_pg_attribute) GETSTRUCT(newtuple))->atthasdef = FALSE;
+			heap_update(attr_rel, &tuple->t_self, newtuple, NULL);
+
+			/* keep the system catalog indices current */
+			CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, irelations);
+			CatalogIndexInsert(irelations, Num_pg_attr_indices, attr_rel, newtuple);
+			CatalogCloseIndices(Num_pg_attr_indices, irelations);
+
+			/* get rid of actual default definition */
+			drop_default(myrelid, attnum);
+		}
+
+		heap_endscan(scan);
+		heap_close(attr_rel, NoLock);
+	}
 
 	heap_close(rel, NoLock);
 }
@@ -654,33 +655,33 @@ AlterTableAlterColumn(const char *relationName,
 static void
 drop_default(Oid relid, int16 attnum)
 {
-    ScanKeyData scankeys[2];
-    HeapScanDesc scan;
-    Relation attrdef_rel;
-    HeapTuple tuple;
+	ScanKeyData scankeys[2];
+	HeapScanDesc scan;
+	Relation	attrdef_rel;
+	HeapTuple	tuple;
 
-    attrdef_rel = heap_openr(AttrDefaultRelationName, AccessExclusiveLock);
-    ScanKeyEntryInitialize(&scankeys[0], 0x0, Anum_pg_attrdef_adrelid, F_OIDEQ,
-                           ObjectIdGetDatum(relid));
-    ScanKeyEntryInitialize(&scankeys[1], 0x0, Anum_pg_attrdef_adnum, F_INT2EQ,
-                           Int16GetDatum(attnum));
+	attrdef_rel = heap_openr(AttrDefaultRelationName, AccessExclusiveLock);
+	ScanKeyEntryInitialize(&scankeys[0], 0x0, Anum_pg_attrdef_adrelid, F_OIDEQ,
+						   ObjectIdGetDatum(relid));
+	ScanKeyEntryInitialize(&scankeys[1], 0x0, Anum_pg_attrdef_adnum, F_INT2EQ,
+						   Int16GetDatum(attnum));
 
-    scan = heap_beginscan(attrdef_rel, false, SnapshotNow, 2, scankeys);
-    AssertState(scan!=NULL);
+	scan = heap_beginscan(attrdef_rel, false, SnapshotNow, 2, scankeys);
+	AssertState(scan != NULL);
 
-    if (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
-        heap_delete(attrdef_rel, &tuple->t_self, NULL);
+	if (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
+		heap_delete(attrdef_rel, &tuple->t_self, NULL);
 
-    heap_endscan(scan);
+	heap_endscan(scan);
 
-    heap_close(attrdef_rel, NoLock);
+	heap_close(attrdef_rel, NoLock);
 }
 
 
 #ifdef	_DROP_COLUMN_HACK__
 /*
  *	ALTER TABLE DROP COLUMN trial implementation
- *		
+ *
  */
 
 /*
@@ -690,17 +691,17 @@ typedef struct SysScanDescData
 {
 	Relation	heap_rel;
 	Relation	irel;
-	HeapScanDesc	scan;
-	IndexScanDesc	iscan;
-	HeapTupleData	tuple;
+	HeapScanDesc scan;
+	IndexScanDesc iscan;
+	HeapTupleData tuple;
 	Buffer		buffer;
-} SysScanDescData, *SysScanDesc;
-	
+}			SysScanDescData, *SysScanDesc;
+
 static void *
 systable_beginscan(Relation rel, const char *indexRelname, int nkeys, ScanKey entry)
 {
-	bool	hasindex = (rel->rd_rel->relhasindex && !IsIgnoringSystemIndexes());
-	SysScanDesc	sysscan;
+	bool		hasindex = (rel->rd_rel->relhasindex && !IsIgnoringSystemIndexes());
+	SysScanDesc sysscan;
 
 	sysscan = (SysScanDesc) palloc(sizeof(SysScanDescData));
 	sysscan->heap_rel = rel;
@@ -710,7 +711,7 @@ systable_beginscan(Relation rel, const char *indexRelname, int nkeys, ScanKey en
 	sysscan->buffer = InvalidBuffer;
 	if (hasindex)
 	{
-		sysscan->irel = index_openr((char *)indexRelname);
+		sysscan->irel = index_openr((char *) indexRelname);
 		sysscan->iscan = index_beginscan(sysscan->irel, false, nkeys, entry);
 	}
 	else
@@ -720,7 +721,7 @@ systable_beginscan(Relation rel, const char *indexRelname, int nkeys, ScanKey en
 static void
 systable_endscan(void *scan)
 {
-	SysScanDesc	sysscan = (SysScanDesc) scan;
+	SysScanDesc sysscan = (SysScanDesc) scan;
 
 	if (sysscan->irel)
 	{
@@ -736,9 +737,9 @@ systable_endscan(void *scan)
 static HeapTuple
 systable_getnext(void *scan)
 {
-	SysScanDesc	sysscan = (SysScanDesc) scan;
+	SysScanDesc sysscan = (SysScanDesc) scan;
 	HeapTuple	htup = (HeapTuple) NULL;
-	RetrieveIndexResult	indexRes;
+	RetrieveIndexResult indexRes;
 
 	if (sysscan->irel)
 	{
@@ -774,50 +775,55 @@ find_attribute_walker(Node *node, int attnum)
 		return false;
 	if (IsA(node, Var))
 	{
-		Var	*var = (Var *) node;
+		Var		   *var = (Var *) node;
+
 		if (var->varlevelsup == 0 && var->varno == 1 &&
 			var->varattno == attnum)
 			return true;
 	}
-	return expression_tree_walker(node, find_attribute_walker, (void *)attnum); 
+	return expression_tree_walker(node, find_attribute_walker, (void *) attnum);
 }
 static bool
 find_attribute_in_node(Node *node, int attnum)
 {
-	return	expression_tree_walker(node, find_attribute_walker, (void *)attnum);
+	return expression_tree_walker(node, find_attribute_walker, (void *) attnum);
 }
+
 /*
  *	Remove/check references for the column
  */
 static bool
 RemoveColumnReferences(Oid reloid, int attnum, bool checkonly, HeapTuple reltup)
 {
-	Relation	indexRelation, rcrel;
-	ScanKeyData	entry;
-	HeapScanDesc	scan;
-	void		*sysscan;
-	HeapTuple	htup, indexTuple;
-	Form_pg_index	index;
-	Form_pg_relcheck	relcheck;
-	Form_pg_class	pgcform = (Form_pg_class) NULL;
-	int		i;
+	Relation	indexRelation,
+				rcrel;
+	ScanKeyData entry;
+	HeapScanDesc scan;
+	void	   *sysscan;
+	HeapTuple	htup,
+				indexTuple;
+	Form_pg_index index;
+	Form_pg_relcheck relcheck;
+	Form_pg_class pgcform = (Form_pg_class) NULL;
+	int			i;
 	bool		checkok = true;
 
-	
+
 	if (!checkonly)
-		pgcform = (Form_pg_class) GETSTRUCT (reltup);
+		pgcform = (Form_pg_class) GETSTRUCT(reltup);
+
 	/*
-	 *	Remove/check constraints here
+	 * Remove/check constraints here
 	 */
 	ScanKeyEntryInitialize(&entry, (bits16) 0x0, Anum_pg_relcheck_rcrelid,
-			(RegProcedure) F_OIDEQ, ObjectIdGetDatum(reloid));
+					   (RegProcedure) F_OIDEQ, ObjectIdGetDatum(reloid));
 	rcrel = heap_openr(RelCheckRelationName, RowExclusiveLock);
-	sysscan = systable_beginscan(rcrel, RelCheckIndex,1 ,&entry);
+	sysscan = systable_beginscan(rcrel, RelCheckIndex, 1, &entry);
 
 	while (HeapTupleIsValid(htup = systable_getnext(sysscan)))
 	{
-		char	*ccbin;
-		Node	*node;
+		char	   *ccbin;
+		Node	   *node;
 
 		relcheck = (Form_pg_relcheck) GETSTRUCT(htup);
 		ccbin = textout(&relcheck->rcbin);
@@ -843,15 +849,15 @@ RemoveColumnReferences(Oid reloid, int attnum, bool checkonly, HeapTuple reltup)
 	heap_close(rcrel, NoLock);
 
 	/*
-	 *	What to do with triggers/rules/views/procedues ?
+	 * What to do with triggers/rules/views/procedues ?
 	 */
 
 	/*
-	 *	Remove/check indexes
+	 * Remove/check indexes
 	 */
 	indexRelation = heap_openr(IndexRelationName, RowExclusiveLock);
 	ScanKeyEntryInitialize(&entry, 0, Anum_pg_index_indrelid, F_OIDEQ,
-				ObjectIdGetDatum(reloid));
+						   ObjectIdGetDatum(reloid));
 	scan = heap_beginscan(indexRelation, false, SnapshotNow, 1, &entry);
 	while (HeapTupleIsValid(indexTuple = heap_getnext(scan, 0)))
 	{
@@ -870,8 +876,8 @@ RemoveColumnReferences(Oid reloid, int attnum, bool checkonly, HeapTuple reltup)
 				else
 				{
 					htup = SearchSysCacheTuple(RELOID,
-						ObjectIdGetDatum(index->indexrelid),
-						0, 0, 0); 
+									 ObjectIdGetDatum(index->indexrelid),
+											   0, 0, 0);
 					RemoveIndex(NameStr(((Form_pg_class) GETSTRUCT(htup))->relname));
 				}
 				break;
@@ -883,33 +889,38 @@ RemoveColumnReferences(Oid reloid, int attnum, bool checkonly, HeapTuple reltup)
 
 	return checkok;
 }
-#endif	/* _DROP_COLUMN_HACK__ */
+
+#endif	 /* _DROP_COLUMN_HACK__ */
 
 /*
  * ALTER TABLE DROP COLUMN
  */
 void
 AlterTableDropColumn(const char *relationName,
-                     bool inh, const char *colName,
-                     int behavior)
+					 bool inh, const char *colName,
+					 int behavior)
 {
 #ifdef	_DROP_COLUMN_HACK__
-	Relation	rel, attrdesc, adrel;
-	Oid		myrelid, attoid;
+	Relation	rel,
+				attrdesc,
+				adrel;
+	Oid			myrelid,
+				attoid;
 	HeapTuple	reltup;
-	HeapTupleData	classtuple;
+	HeapTupleData classtuple;
 	Buffer		buffer;
 	Form_pg_attribute attribute;
 	HeapTuple	tup;
 	Relation	idescs[Num_pg_attr_indices];
-	int		attnum;
+	int			attnum;
 	bool		hasindex;
 	char		dropColname[32];
-	void		*sysscan;
-    	ScanKeyData	scankeys[2];
+	void	   *sysscan;
+	ScanKeyData scankeys[2];
 
-	if (inh)	
+	if (inh)
 		elog(ERROR, "ALTER TABLE / DROP COLUMN with inherit option is not supported yet");
+
 	/*
 	 * permissions checking.  this would normally be done in utility.c,
 	 * but this particular routine is recursive.
@@ -925,25 +936,25 @@ AlterTableDropColumn(const char *relationName,
 #endif
 
 	/*
-	 * Grab an exclusive lock on the target table, which we will NOT release
-	 * until end of transaction.
+	 * Grab an exclusive lock on the target table, which we will NOT
+	 * release until end of transaction.
 	 */
 	rel = heap_openr(relationName, AccessExclusiveLock);
 	myrelid = RelationGetRelid(rel);
 	heap_close(rel, NoLock);	/* close rel but keep lock! */
 
 	/*
-	 *	What to do when rel has inheritors ?
+	 * What to do when rel has inheritors ?
 	 */
 	if (length(find_all_inheritors(myrelid)) > 1)
 		elog(ERROR, "ALTER TABLE: cannot drop a column on table that is inherited from");
 
 
 	/*
-	 *	lock the pg_class tuple for update
+	 * lock the pg_class tuple for update
 	 */
 	reltup = SearchSysCacheTuple(RELNAME, PointerGetDatum(relationName),
-							0, 0, 0);
+								 0, 0, 0);
 
 	if (!HeapTupleIsValid(reltup))
 		elog(ERROR, "ALTER TABLE: relation \"%s\" not found",
@@ -976,19 +987,20 @@ AlterTableDropColumn(const char *relationName,
 	 * Get the target pg_attribute tuple
 	 */
 	tup = SearchSysCacheTupleCopy(ATTNAME,
-				ObjectIdGetDatum(reltup->t_data->t_oid),
-				PointerGetDatum(colName), 0, 0);
+								  ObjectIdGetDatum(reltup->t_data->t_oid),
+								  PointerGetDatum(colName), 0, 0);
 	if (!HeapTupleIsValid(tup))
 		elog(ERROR, "ALTER TABLE: column name \"%s\" doesn't exist in table \"%s\"",
-				 colName, relationName);
+			 colName, relationName);
 
 	attribute = (Form_pg_attribute) GETSTRUCT(tup);
 	if (attribute->attnum <= 0)
 		elog(ERROR, "ALTER TABLE: column name \"%s\" was already dropped", colName);
 	attnum = attribute->attnum;
 	attoid = tup->t_data->t_oid;
+
 	/*
-	 *	Check constraints/indices etc here
+	 * Check constraints/indices etc here
 	 */
 	if (behavior != CASCADE)
 	{
@@ -997,7 +1009,7 @@ AlterTableDropColumn(const char *relationName,
 	}
 
 	/*
-	 *	change the target pg_attribute tuple
+	 * change the target pg_attribute tuple
 	 */
 	sprintf(dropColname, "*already Dropped*%d", attnum);
 	namestrcpy(&(attribute->attname), dropColname);
@@ -1009,7 +1021,7 @@ AlterTableDropColumn(const char *relationName,
 	{
 		CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, idescs);
 		CatalogIndexInsert(idescs, Num_pg_attr_indices,
-				attrdesc, tup);
+						   attrdesc, tup);
 		CatalogCloseIndices(Num_pg_attr_indices, idescs);
 	}
 	heap_close(attrdesc, NoLock);
@@ -1020,15 +1032,17 @@ AlterTableDropColumn(const char *relationName,
 	/* delete attrdef */
 	adrel = heap_openr(AttrDefaultRelationName, RowExclusiveLock);
 	ScanKeyEntryInitialize(&scankeys[0], 0x0, Anum_pg_attrdef_adrelid,
-			F_OIDEQ, ObjectIdGetDatum(myrelid));
-	/* Oops pg_attrdef doesn't have (adrelid,adnum) index
-	ScanKeyEntryInitialize(&scankeys[1], 0x0, Anum_pg_attrdef_adnum,
-			F_INT2EQ, Int16GetDatum(attnum));
-	sysscan = systable_beginscan(adrel, AttrDefaultIndex, 2, scankeys);
-	*/
+						   F_OIDEQ, ObjectIdGetDatum(myrelid));
+
+	/*
+	 * Oops pg_attrdef doesn't have (adrelid,adnum) index
+	 * ScanKeyEntryInitialize(&scankeys[1], 0x0, Anum_pg_attrdef_adnum,
+	 * F_INT2EQ, Int16GetDatum(attnum)); sysscan =
+	 * systable_beginscan(adrel, AttrDefaultIndex, 2, scankeys);
+	 */
 	sysscan = systable_beginscan(adrel, AttrDefaultIndex, 1, scankeys);
 	while (HeapTupleIsValid(tup = systable_getnext(sysscan)))
-	{ 
+	{
 		if (((Form_pg_attrdef) GETSTRUCT(tup))->adnum == attnum)
 		{
 			heap_delete(adrel, &tup->t_self, NULL);
@@ -1037,8 +1051,9 @@ AlterTableDropColumn(const char *relationName,
 	}
 	systable_endscan(sysscan);
 	heap_close(adrel, NoLock);
+
 	/*
-	 *	Remove objects which reference this column
+	 * Remove objects which reference this column
 	 */
 	if (behavior == CASCADE)
 	{
@@ -1055,8 +1070,8 @@ AlterTableDropColumn(const char *relationName,
 	heap_freetuple(reltup);
 	heap_close(rel, NoLock);
 #else
-    elog(ERROR, "ALTER TABLE / DROP COLUMN is not implemented");
-#endif	/* _DROP_COLUMN_HACK__ */
+				elog(ERROR, "ALTER TABLE / DROP COLUMN is not implemented");
+#endif	 /* _DROP_COLUMN_HACK__ */
 }
 
 
@@ -1066,76 +1081,80 @@ AlterTableDropColumn(const char *relationName,
  */
 void
 AlterTableAddConstraint(const char *relationName,
-                        bool inh, Node *newConstraint)
+						bool inh, Node *newConstraint)
 {
-	if (newConstraint == NULL) 
+	if (newConstraint == NULL)
 		elog(ERROR, "ALTER TABLE / ADD CONSTRAINT passed invalid constraint.");
 
-	switch (nodeTag(newConstraint)) 
+	switch (nodeTag(newConstraint))
 	{
 		case T_Constraint:
 			elog(ERROR, "ALTER TABLE / ADD CONSTRAINT is not implemented");
 		case T_FkConstraint:
 			{
-				FkConstraint *fkconstraint=(FkConstraint *)newConstraint;
-				Relation rel;
+				FkConstraint *fkconstraint = (FkConstraint *) newConstraint;
+				Relation	rel;
 				HeapScanDesc scan;
-				HeapTuple tuple;
-				Trigger trig;
-				List *list;
-				int count;
+				HeapTuple	tuple;
+				Trigger		trig;
+				List	   *list;
+				int			count;
 
-				/* 
+				/*
 				 * Grab an exclusive lock on the pk table, so that someone
-				 * doesn't delete rows out from under us.  
+				 * doesn't delete rows out from under us.
 				 */
 
 				rel = heap_openr(fkconstraint->pktable_name, AccessExclusiveLock);
 				heap_close(rel, NoLock);
 
-				/* 
-				 * Grab an exclusive lock on the fk table, and then scan through
-				 * each tuple, calling the RI_FKey_Match_Ins (insert trigger)
-				 * as if that tuple had just been inserted.  If any of those
-				 * fail, it should elog(ERROR) and that's that.
+				/*
+				 * Grab an exclusive lock on the fk table, and then scan
+				 * through each tuple, calling the RI_FKey_Match_Ins
+				 * (insert trigger) as if that tuple had just been
+				 * inserted.  If any of those fail, it should elog(ERROR)
+				 * and that's that.
 				 */
 				rel = heap_openr(relationName, AccessExclusiveLock);
 				trig.tgoid = 0;
 				trig.tgname = "<unknown>";
-				trig.tgfoid = 0; 
+				trig.tgfoid = 0;
 				trig.tgtype = 0;
 				trig.tgenabled = TRUE;
 				trig.tgisconstraint = TRUE;
 				trig.tginitdeferred = FALSE;
 				trig.tgdeferrable = FALSE;
 
-				trig.tgargs = (char **)palloc(
-						sizeof(char *) * (4 + length(fkconstraint->fk_attrs) 
-						                    + length(fkconstraint->pk_attrs)));
-				
+				trig.tgargs = (char **) palloc(
+					 sizeof(char *) * (4 + length(fkconstraint->fk_attrs)
+									   + length(fkconstraint->pk_attrs)));
+
 				trig.tgargs[0] = "<unnamed>";
-				trig.tgargs[1] = (char *)relationName;
+				trig.tgargs[1] = (char *) relationName;
 				trig.tgargs[2] = fkconstraint->pktable_name;
 				trig.tgargs[3] = fkconstraint->match_type;
 				count = 4;
-				foreach (list, fkconstraint->fk_attrs) 
+				foreach(list, fkconstraint->fk_attrs)
 				{
-					Ident *fk_at = lfirst(list);
+					Ident	   *fk_at = lfirst(list);
+
 					trig.tgargs[count++] = fk_at->name;
 				}
-				foreach (list, fkconstraint->pk_attrs) 
+				foreach(list, fkconstraint->pk_attrs)
 				{
-					Ident *pk_at = lfirst(list);
+					Ident	   *pk_at = lfirst(list);
+
 					trig.tgargs[count++] = pk_at->name;
 				}
 				trig.tgnargs = count;
 
 				scan = heap_beginscan(rel, false, SnapshotNow, 0, NULL);
-				AssertState(scan!=NULL);
+				AssertState(scan != NULL);
 
 				while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
 				{
 					TriggerData newtrigdata;
+
 					newtrigdata.tg_event = TRIGGER_EVENT_INSERT | TRIGGER_EVENT_ROW;
 					newtrigdata.tg_relation = rel;
 					newtrigdata.tg_trigtuple = tuple;
@@ -1149,7 +1168,8 @@ AlterTableAddConstraint(const char *relationName,
 					/* Make a call to the check function */
 				}
 				heap_endscan(scan);
-				heap_close(rel, NoLock);	 /* close rel but keep lock! */
+				heap_close(rel, NoLock);		/* close rel but keep
+												 * lock! */
 
 				pfree(trig.tgargs);
 			}
@@ -1166,10 +1186,10 @@ AlterTableAddConstraint(const char *relationName,
  */
 void
 AlterTableDropConstraint(const char *relationName,
-                         bool inh, const char *constrName,
-                         int behavior)
+						 bool inh, const char *constrName,
+						 int behavior)
 {
-    elog(ERROR, "ALTER TABLE / DROP CONSTRAINT is not implemented");
+	elog(ERROR, "ALTER TABLE / DROP CONSTRAINT is not implemented");
 }
 
 
@@ -1186,7 +1206,7 @@ LockTableCommand(LockStmt *lockstmt)
 	int			aclresult;
 
 	rel = heap_openr(lockstmt->relname, NoLock);
-	if (! RelationIsValid(rel))
+	if (!RelationIsValid(rel))
 		elog(ERROR, "Relation '%s' does not exist", lockstmt->relname);
 
 	if (lockstmt->mode == AccessShareLock)
diff --git a/src/backend/commands/comment.c b/src/backend/commands/comment.c
index 649025b4a136be32831c255b1f511b0ee2caf07a..3fe7b6f63470b74fdff6a577dbb52c874177073c 100644
--- a/src/backend/commands/comment.c
+++ b/src/backend/commands/comment.c
@@ -67,44 +67,47 @@ static void CommentTrigger(char *trigger, char *relation, char *comments);
  *------------------------------------------------------------------
 */
 
-void CommentObject(int objtype, char *objname, char *objproperty,
-		   List *objlist, char *comment) {
-
-  switch (objtype) {
-  case (INDEX):
-  case (SEQUENCE):
-  case (TABLE):
-  case (VIEW):
-    CommentRelation(objtype, objname, comment);
-    break;
-  case (COLUMN):
-    CommentAttribute(objname, objproperty, comment);
-    break;
-  case (DATABASE):
-    CommentDatabase(objname, comment);
-    break;
-  case (RULE):
-    CommentRewrite(objname, comment);
-    break;
-  case (TYPE_P):
-    CommentType(objname, comment);
-    break;
-  case (AGGREGATE):
-    CommentAggregate(objname, objproperty, comment);
-    break;
-  case (FUNCTION):
-    CommentProc(objname, objlist, comment);
-    break;
-  case (OPERATOR):
-    CommentOperator(objname, objlist, comment);
-    break;
-  case (TRIGGER):
-    CommentTrigger(objname, objproperty, comment);
-    break;
-  default:
-    elog(ERROR, "An attempt was made to comment on a unknown type: %i",
-	 objtype);
-  }
+void
+CommentObject(int objtype, char *objname, char *objproperty,
+			  List *objlist, char *comment)
+{
+
+	switch (objtype)
+	{
+			case (INDEX):
+			case (SEQUENCE):
+			case (TABLE):
+			case (VIEW):
+			CommentRelation(objtype, objname, comment);
+			break;
+		case (COLUMN):
+			CommentAttribute(objname, objproperty, comment);
+			break;
+		case (DATABASE):
+			CommentDatabase(objname, comment);
+			break;
+		case (RULE):
+			CommentRewrite(objname, comment);
+			break;
+		case (TYPE_P):
+			CommentType(objname, comment);
+			break;
+		case (AGGREGATE):
+			CommentAggregate(objname, objproperty, comment);
+			break;
+		case (FUNCTION):
+			CommentProc(objname, objlist, comment);
+			break;
+		case (OPERATOR):
+			CommentOperator(objname, objlist, comment);
+			break;
+		case (TRIGGER):
+			CommentTrigger(objname, objproperty, comment);
+			break;
+		default:
+			elog(ERROR, "An attempt was made to comment on a unknown type: %i",
+				 objtype);
+	}
 
 
 }
@@ -120,87 +123,99 @@ void CommentObject(int objtype, char *objname, char *objproperty,
  *------------------------------------------------------------------
  */
 
-void CreateComments(Oid oid, char *comment) {
-
-  Relation description;
-  TupleDesc tupDesc;
-  HeapScanDesc scan;
-  ScanKeyData entry;
-  HeapTuple desctuple = NULL, searchtuple;
-  Datum values[Natts_pg_description];
-  char nulls[Natts_pg_description];
-  char replaces[Natts_pg_description];
-  bool modified = false;
-  int i;
-
-  /*** Open pg_description, form a new tuple, if necessary ***/
-
-  description = heap_openr(DescriptionRelationName, RowExclusiveLock);
-  tupDesc = description->rd_att;
-  if ((comment != NULL) && (strlen(comment) > 0)) {
-    for (i = 0; i < Natts_pg_description; i++) {
-      nulls[i] = ' ';
-      replaces[i] = 'r';
-      values[i] = (Datum) NULL;
-    }
-    i = 0;
-    values[i++] = ObjectIdGetDatum(oid);
-    values[i++] = (Datum) fmgr(F_TEXTIN, comment);
-  }
-
-  /*** Now, open pg_description and attempt to find the old tuple ***/
-
-  ScanKeyEntryInitialize(&entry, 0x0, Anum_pg_description_objoid, F_OIDEQ,
-			 ObjectIdGetDatum(oid));
-  scan = heap_beginscan(description, false, SnapshotNow, 1, &entry);
-  searchtuple = heap_getnext(scan, 0);
-
-  /*** If a previous tuple exists, either delete or prep replacement ***/
-
-  if (HeapTupleIsValid(searchtuple)) {
-
-    /*** If the comment is blank, call heap_delete, else heap_update ***/
-
-    if ((comment == NULL) || (strlen(comment) == 0)) {
-      heap_delete(description, &searchtuple->t_self, NULL);
-    } else {
-      desctuple = heap_modifytuple(searchtuple, description, values,
-				   nulls, replaces);
-      heap_update(description, &searchtuple->t_self, desctuple, NULL);
-      modified = TRUE;
-    }
-
-  } else {
-
-	/*** Only if comment is non-blank do we form a new tuple ***/
-
-	if ((comment != NULL) && (strlen(comment) > 0)) {
-		desctuple = heap_formtuple(tupDesc, values, nulls);
-		heap_insert(description, desctuple);
-		modified = TRUE;
+void
+CreateComments(Oid oid, char *comment)
+{
+
+	Relation	description;
+	TupleDesc	tupDesc;
+	HeapScanDesc scan;
+	ScanKeyData entry;
+	HeapTuple	desctuple = NULL,
+				searchtuple;
+	Datum		values[Natts_pg_description];
+	char		nulls[Natts_pg_description];
+	char		replaces[Natts_pg_description];
+	bool		modified = false;
+	int			i;
+
+	/*** Open pg_description, form a new tuple, if necessary ***/
+
+	description = heap_openr(DescriptionRelationName, RowExclusiveLock);
+	tupDesc = description->rd_att;
+	if ((comment != NULL) && (strlen(comment) > 0))
+	{
+		for (i = 0; i < Natts_pg_description; i++)
+		{
+			nulls[i] = ' ';
+			replaces[i] = 'r';
+			values[i] = (Datum) NULL;
+		}
+		i = 0;
+		values[i++] = ObjectIdGetDatum(oid);
+		values[i++] = (Datum) fmgr(F_TEXTIN, comment);
+	}
+
+	/*** Now, open pg_description and attempt to find the old tuple ***/
+
+	ScanKeyEntryInitialize(&entry, 0x0, Anum_pg_description_objoid, F_OIDEQ,
+						   ObjectIdGetDatum(oid));
+	scan = heap_beginscan(description, false, SnapshotNow, 1, &entry);
+	searchtuple = heap_getnext(scan, 0);
+
+	/*** If a previous tuple exists, either delete or prep replacement ***/
+
+	if (HeapTupleIsValid(searchtuple))
+	{
+
+		/*** If the comment is blank, call heap_delete, else heap_update ***/
+
+		if ((comment == NULL) || (strlen(comment) == 0))
+			heap_delete(description, &searchtuple->t_self, NULL);
+		else
+		{
+			desctuple = heap_modifytuple(searchtuple, description, values,
+										 nulls, replaces);
+			heap_update(description, &searchtuple->t_self, desctuple, NULL);
+			modified = TRUE;
+		}
+
 	}
+	else
+	{
+
+		/*** Only if comment is non-blank do we form a new tuple ***/
+
+		if ((comment != NULL) && (strlen(comment) > 0))
+		{
+			desctuple = heap_formtuple(tupDesc, values, nulls);
+			heap_insert(description, desctuple);
+			modified = TRUE;
+		}
 
-  }
+	}
 
-  /*** Complete the scan, update indices, if necessary ***/
+	/*** Complete the scan, update indices, if necessary ***/
 
-  heap_endscan(scan);
+	heap_endscan(scan);
 
-  if (modified) {
-    if (RelationGetForm(description)->relhasindex) {
-      Relation idescs[Num_pg_description_indices];
+	if (modified)
+	{
+		if (RelationGetForm(description)->relhasindex)
+		{
+			Relation	idescs[Num_pg_description_indices];
 
-      CatalogOpenIndices(Num_pg_description_indices,
-			 Name_pg_description_indices, idescs);
-      CatalogIndexInsert(idescs, Num_pg_description_indices, description,
-			 desctuple);
-      CatalogCloseIndices(Num_pg_description_indices, idescs);
-    }
-    heap_freetuple(desctuple);
+			CatalogOpenIndices(Num_pg_description_indices,
+							   Name_pg_description_indices, idescs);
+			CatalogIndexInsert(idescs, Num_pg_description_indices, description,
+							   desctuple);
+			CatalogCloseIndices(Num_pg_description_indices, idescs);
+		}
+		heap_freetuple(desctuple);
 
-  }
+	}
 
-  heap_close(description, RowExclusiveLock);
+	heap_close(description, RowExclusiveLock);
 
 }
 
@@ -214,34 +229,35 @@ void CreateComments(Oid oid, char *comment) {
  *------------------------------------------------------------------
  */
 
-void DeleteComments(Oid oid) {
+void
+DeleteComments(Oid oid)
+{
 
-  Relation description;
-  TupleDesc tupDesc;
-  ScanKeyData entry;
-  HeapScanDesc scan;
-  HeapTuple searchtuple;
+	Relation	description;
+	TupleDesc	tupDesc;
+	ScanKeyData entry;
+	HeapScanDesc scan;
+	HeapTuple	searchtuple;
 
-  description = heap_openr(DescriptionRelationName, RowExclusiveLock);
-  tupDesc = description->rd_att;
+	description = heap_openr(DescriptionRelationName, RowExclusiveLock);
+	tupDesc = description->rd_att;
 
-  /*** Now, open pg_description and attempt to find the old tuple ***/
+	/*** Now, open pg_description and attempt to find the old tuple ***/
 
-  ScanKeyEntryInitialize(&entry, 0x0, Anum_pg_description_objoid, F_OIDEQ,
-			 ObjectIdGetDatum(oid));
-  scan = heap_beginscan(description, false, SnapshotNow, 1, &entry);
-  searchtuple = heap_getnext(scan, 0);
+	ScanKeyEntryInitialize(&entry, 0x0, Anum_pg_description_objoid, F_OIDEQ,
+						   ObjectIdGetDatum(oid));
+	scan = heap_beginscan(description, false, SnapshotNow, 1, &entry);
+	searchtuple = heap_getnext(scan, 0);
 
-  /*** If a previous tuple exists, delete it ***/
+	/*** If a previous tuple exists, delete it ***/
 
-  if (HeapTupleIsValid(searchtuple)) {
-    heap_delete(description, &searchtuple->t_self, NULL);
-  }
+	if (HeapTupleIsValid(searchtuple))
+		heap_delete(description, &searchtuple->t_self, NULL);
 
-  /*** Complete the scan, update indices, if necessary ***/
+	/*** Complete the scan, update indices, if necessary ***/
 
-  heap_endscan(scan);
-  heap_close(description, RowExclusiveLock);
+	heap_endscan(scan);
+	heap_close(description, RowExclusiveLock);
 
 }
 
@@ -256,60 +272,57 @@ void DeleteComments(Oid oid) {
  *------------------------------------------------------------------
 */
 
-static void CommentRelation(int reltype, char *relname, char *comment) {
-
-  HeapTuple reltuple;
-  Oid oid;
-  char relkind;
-
-  /*** First, check object security ***/
-
-  #ifndef NO_SECURITY
-  if (!pg_ownercheck(GetPgUserName(), relname, RELNAME)) {
-    elog(ERROR, "you are not permitted to comment on class '%s'", relname);
-  }
-  #endif
-
-  /*** Now, attempt to find the oid in the cached version of pg_class ***/
-
-  reltuple = SearchSysCacheTuple(RELNAME, PointerGetDatum(relname),
-				 0, 0, 0);
-  if (!HeapTupleIsValid(reltuple)) {
-    elog(ERROR, "relation '%s' does not exist", relname);
-  }
-
-  oid = reltuple->t_data->t_oid;
-
-  /*** Next, verify that the relation type matches the intent ***/
-
-  relkind = ((Form_pg_class) GETSTRUCT(reltuple))->relkind;
-
-  switch (reltype) {
-  case (INDEX):
-    if (relkind != 'i') {
-      elog(ERROR, "relation '%s' is not an index", relname);
-    }
-    break;
-  case (TABLE):
-    if (relkind != 'r') {
-      elog(ERROR, "relation '%s' is not a table", relname);
-    }
-    break;
-  case (VIEW):
-    if (relkind != 'r') {
-      elog(ERROR, "relation '%s' is not a view", relname);
-    }
-    break;
-  case (SEQUENCE):
-    if (relkind != 'S') {
-      elog(ERROR, "relation '%s' is not a sequence", relname);
-    }
-    break;
-  }
-
-  /*** Create the comments using the tuple's oid ***/
-
-  CreateComments(oid, comment);
+static void
+CommentRelation(int reltype, char *relname, char *comment)
+{
+
+	HeapTuple	reltuple;
+	Oid			oid;
+	char		relkind;
+
+	/*** First, check object security ***/
+
+#ifndef NO_SECURITY
+	if (!pg_ownercheck(GetPgUserName(), relname, RELNAME))
+		elog(ERROR, "you are not permitted to comment on class '%s'", relname);
+#endif
+
+	/*** Now, attempt to find the oid in the cached version of pg_class ***/
+
+	reltuple = SearchSysCacheTuple(RELNAME, PointerGetDatum(relname),
+								   0, 0, 0);
+	if (!HeapTupleIsValid(reltuple))
+		elog(ERROR, "relation '%s' does not exist", relname);
+
+	oid = reltuple->t_data->t_oid;
+
+	/*** Next, verify that the relation type matches the intent ***/
+
+	relkind = ((Form_pg_class) GETSTRUCT(reltuple))->relkind;
+
+	switch (reltype)
+	{
+		case (INDEX):
+			if (relkind != 'i')
+				elog(ERROR, "relation '%s' is not an index", relname);
+			break;
+		case (TABLE):
+			if (relkind != 'r')
+				elog(ERROR, "relation '%s' is not a table", relname);
+			break;
+		case (VIEW):
+			if (relkind != 'r')
+				elog(ERROR, "relation '%s' is not a view", relname);
+			break;
+		case (SEQUENCE):
+			if (relkind != 'S')
+				elog(ERROR, "relation '%s' is not a sequence", relname);
+			break;
+	}
+
+	/*** Create the comments using the tuple's oid ***/
+
+	CreateComments(oid, comment);
 
 }
 
@@ -320,43 +333,45 @@ static void CommentRelation(int reltype, char *relname, char *comment) {
  * such as a table's column. The routine will check security
  * restrictions and then attempt to fetch the oid of the associated
  * attribute. If successful, a comment is added/dropped, else an
- * elog() exception is thrown.  The parameters are the relation
+ * elog() exception is thrown.	The parameters are the relation
  * and attribute names, and the comments
  *------------------------------------------------------------------
 */
 
-static void CommentAttribute(char *relname, char *attrname, char *comment) {
+static void
+CommentAttribute(char *relname, char *attrname, char *comment)
+{
 
-  Relation relation;
-  HeapTuple attrtuple;
-  Oid oid;
+	Relation	relation;
+	HeapTuple	attrtuple;
+	Oid			oid;
 
-  /*** First, check object security ***/
+	/*** First, check object security ***/
 
-  #ifndef NO_SECURITY
-  if (!pg_ownercheck(GetPgUserName(), relname, RELNAME)) {
-    elog(ERROR, "you are not permitted to comment on class '%s\'", relname);
-  }
-  #endif
+#ifndef NO_SECURITY
+	if (!pg_ownercheck(GetPgUserName(), relname, RELNAME))
+		elog(ERROR, "you are not permitted to comment on class '%s\'", relname);
+#endif
 
-  /*** Now, fetch the attribute oid from the system cache ***/
+	/*** Now, fetch the attribute oid from the system cache ***/
 
-  relation = heap_openr(relname, AccessShareLock);
-  attrtuple = SearchSysCacheTuple(ATTNAME, ObjectIdGetDatum(relation->rd_id),
-				  PointerGetDatum(attrname), 0, 0);
-  if (!HeapTupleIsValid(attrtuple)) {
-    elog(ERROR, "'%s' is not an attribute of class '%s'",
-	 attrname, relname);
-  }
-  oid = attrtuple->t_data->t_oid;
+	relation = heap_openr(relname, AccessShareLock);
+	attrtuple = SearchSysCacheTuple(ATTNAME, ObjectIdGetDatum(relation->rd_id),
+									PointerGetDatum(attrname), 0, 0);
+	if (!HeapTupleIsValid(attrtuple))
+	{
+		elog(ERROR, "'%s' is not an attribute of class '%s'",
+			 attrname, relname);
+	}
+	oid = attrtuple->t_data->t_oid;
 
-  /*** Call CreateComments() to create/drop the comments ***/
+	/*** Call CreateComments() to create/drop the comments ***/
 
-  CreateComments(oid, comment);
+	CreateComments(oid, comment);
 
-  /*** Now, close the heap relation and return ***/
+	/*** Now, close the heap relation and return ***/
 
-  heap_close(relation, AccessShareLock);
+	heap_close(relation, AccessShareLock);
 
 }
 
@@ -371,61 +386,64 @@ static void CommentAttribute(char *relname, char *attrname, char *comment) {
  *------------------------------------------------------------------
 */
 
-static void CommentDatabase(char *database, char *comment) {
+static void
+CommentDatabase(char *database, char *comment)
+{
 
-  Relation pg_database;
-  HeapTuple dbtuple, usertuple;
-  ScanKeyData entry;
-  HeapScanDesc scan;
-  Oid oid;
-  bool superuser;
-  int4 dba, userid;
-  char *username;
+	Relation	pg_database;
+	HeapTuple	dbtuple,
+				usertuple;
+	ScanKeyData entry;
+	HeapScanDesc scan;
+	Oid			oid;
+	bool		superuser;
+	int4		dba,
+				userid;
+	char	   *username;
 
-  /*** First find the tuple in pg_database for the database ***/
+	/*** First find the tuple in pg_database for the database ***/
 
-  pg_database = heap_openr(DatabaseRelationName, AccessShareLock);
-  ScanKeyEntryInitialize(&entry, 0, Anum_pg_database_datname,
-			 F_NAMEEQ, NameGetDatum(database));
-  scan = heap_beginscan(pg_database, 0, SnapshotNow, 1, &entry);
-  dbtuple = heap_getnext(scan, 0);
+	pg_database = heap_openr(DatabaseRelationName, AccessShareLock);
+	ScanKeyEntryInitialize(&entry, 0, Anum_pg_database_datname,
+						   F_NAMEEQ, NameGetDatum(database));
+	scan = heap_beginscan(pg_database, 0, SnapshotNow, 1, &entry);
+	dbtuple = heap_getnext(scan, 0);
 
-  /*** Validate database exists, and fetch the dba id and oid ***/
+	/*** Validate database exists, and fetch the dba id and oid ***/
 
-  if (!HeapTupleIsValid(dbtuple)) {
-    elog(ERROR, "database '%s' does not exist", database);
-  }
-  dba = ((Form_pg_database) GETSTRUCT(dbtuple))->datdba;
-  oid = dbtuple->t_data->t_oid;
+	if (!HeapTupleIsValid(dbtuple))
+		elog(ERROR, "database '%s' does not exist", database);
+	dba = ((Form_pg_database) GETSTRUCT(dbtuple))->datdba;
+	oid = dbtuple->t_data->t_oid;
 
-  /*** Now, fetch user information ***/
+	/*** Now, fetch user information ***/
 
-  username = GetPgUserName();
-  usertuple = SearchSysCacheTuple(SHADOWNAME, PointerGetDatum(username),
-				  0, 0, 0);
-  if (!HeapTupleIsValid(usertuple)) {
-    elog(ERROR, "current user '%s' does not exist", username);
-  }
-  userid = ((Form_pg_shadow) GETSTRUCT(usertuple))->usesysid;
-  superuser = ((Form_pg_shadow) GETSTRUCT(usertuple))->usesuper;
+	username = GetPgUserName();
+	usertuple = SearchSysCacheTuple(SHADOWNAME, PointerGetDatum(username),
+									0, 0, 0);
+	if (!HeapTupleIsValid(usertuple))
+		elog(ERROR, "current user '%s' does not exist", username);
+	userid = ((Form_pg_shadow) GETSTRUCT(usertuple))->usesysid;
+	superuser = ((Form_pg_shadow) GETSTRUCT(usertuple))->usesuper;
 
-  /*** Allow if the userid matches the database dba or is a superuser ***/
+	/*** Allow if the userid matches the database dba or is a superuser ***/
 
-  #ifndef NO_SECURITY
-  if (!(superuser || (userid == dba))) {
-    elog(ERROR, "you are not permitted to comment on database '%s'",
-	 database);
-  }
-  #endif
+#ifndef NO_SECURITY
+	if (!(superuser || (userid == dba)))
+	{
+		elog(ERROR, "you are not permitted to comment on database '%s'",
+			 database);
+	}
+#endif
 
-  /*** Create the comments with the pg_database oid ***/
+	/*** Create the comments with the pg_database oid ***/
 
-  CreateComments(oid, comment);
+	CreateComments(oid, comment);
 
-  /*** Complete the scan and close any opened relations ***/
+	/*** Complete the scan and close any opened relations ***/
 
-  heap_endscan(scan);
-  heap_close(pg_database, AccessShareLock);
+	heap_endscan(scan);
+	heap_close(pg_database, AccessShareLock);
 
 }
 
@@ -439,38 +457,41 @@ static void CommentDatabase(char *database, char *comment) {
  *------------------------------------------------------------------
 */
 
-static void CommentRewrite(char *rule, char *comment) {
+static void
+CommentRewrite(char *rule, char *comment)
+{
 
-  HeapTuple rewritetuple;
-  Oid oid;
-  char *user, *relation;
-  int aclcheck;
+	HeapTuple	rewritetuple;
+	Oid			oid;
+	char	   *user,
+			   *relation;
+	int			aclcheck;
 
-  /*** First, validate user ***/
+	/*** First, validate user ***/
 
-  #ifndef NO_SECURITY
-  user = GetPgUserName();
-  relation = RewriteGetRuleEventRel(rule);
-  aclcheck = pg_aclcheck(relation, user, ACL_RU);
-  if (aclcheck != ACLCHECK_OK) {
-    elog(ERROR, "you are not permitted to comment on rule '%s'",
-	 rule);
-  }
-  #endif
+#ifndef NO_SECURITY
+	user = GetPgUserName();
+	relation = RewriteGetRuleEventRel(rule);
+	aclcheck = pg_aclcheck(relation, user, ACL_RU);
+	if (aclcheck != ACLCHECK_OK)
+	{
+		elog(ERROR, "you are not permitted to comment on rule '%s'",
+			 rule);
+	}
+#endif
 
-  /*** Next, find the rule's oid ***/
+	/*** Next, find the rule's oid ***/
 
-  rewritetuple = SearchSysCacheTuple(RULENAME, PointerGetDatum(rule),
-				     0, 0, 0);
-  if (!HeapTupleIsValid(rewritetuple)) {
-    elog(ERROR, "rule '%s' does not exist", rule);
-  }
+	rewritetuple = SearchSysCacheTuple(RULENAME, PointerGetDatum(rule),
+									   0, 0, 0);
+	if (!HeapTupleIsValid(rewritetuple))
+		elog(ERROR, "rule '%s' does not exist", rule);
 
-  oid = rewritetuple->t_data->t_oid;
+	oid = rewritetuple->t_data->t_oid;
 
-  /*** Call CreateComments() to create/drop the comments ***/
+	/*** Call CreateComments() to create/drop the comments ***/
 
-  CreateComments(oid, comment);
+	CreateComments(oid, comment);
 
 }
 
@@ -485,35 +506,37 @@ static void CommentRewrite(char *rule, char *comment) {
  *------------------------------------------------------------------
 */
 
-static void CommentType(char *type, char *comment) {
+static void
+CommentType(char *type, char *comment)
+{
 
-  HeapTuple typetuple;
-  Oid oid;
-  char *user;
+	HeapTuple	typetuple;
+	Oid			oid;
+	char	   *user;
 
-  /*** First, validate user ***/
+	/*** First, validate user ***/
 
-  #ifndef NO_SECURITY
-  user = GetPgUserName();
-  if (!pg_ownercheck(user, type, TYPENAME)) {
-    elog(ERROR, "you are not permitted to comment on type '%s'",
-	 type);
-  }
-  #endif
+#ifndef NO_SECURITY
+	user = GetPgUserName();
+	if (!pg_ownercheck(user, type, TYPENAME))
+	{
+		elog(ERROR, "you are not permitted to comment on type '%s'",
+			 type);
+	}
+#endif
 
-  /*** Next, find the type's oid ***/
+	/*** Next, find the type's oid ***/
 
-  typetuple = SearchSysCacheTuple(TYPENAME, PointerGetDatum(type),
-				  0, 0, 0);
-  if (!HeapTupleIsValid(typetuple)) {
-    elog(ERROR, "type '%s' does not exist", type);
-  }
+	typetuple = SearchSysCacheTuple(TYPENAME, PointerGetDatum(type),
+									0, 0, 0);
+	if (!HeapTupleIsValid(typetuple))
+		elog(ERROR, "type '%s' does not exist", type);
 
-  oid = typetuple->t_data->t_oid;
+	oid = typetuple->t_data->t_oid;
 
-  /*** Call CreateComments() to create/drop the comments ***/
+	/*** Call CreateComments() to create/drop the comments ***/
 
-  CreateComments(oid, comment);
+	CreateComments(oid, comment);
 
 }
 
@@ -527,57 +550,66 @@ static void CommentType(char *type, char *comment) {
  *------------------------------------------------------------------
 */
 
-static void CommentAggregate(char *aggregate, char *argument, char *comment) {
-
-  HeapTuple aggtuple;
-  Oid baseoid, oid;
-  bool defined;
-  char *user;
-
-  /*** First, attempt to determine the base aggregate oid ***/
-
-  if (argument) {
-    baseoid = TypeGet(argument, &defined);
-    if (!OidIsValid(baseoid)) {
-      elog(ERROR, "aggregate type '%s' does not exist", argument);
-    }
-  } else {
-    baseoid = 0;
-  }
-
-  /*** Next, validate the user's attempt to comment ***/
-
-  #ifndef NO_SECURITY
-  user = GetPgUserName();
-  if (!pg_aggr_ownercheck(user, aggregate, baseoid)) {
-    if (argument) {
-      elog(ERROR, "you are not permitted to comment on aggregate '%s' %s '%s'",
-	   aggregate, "with type", argument);
-    } else {
-      elog(ERROR, "you are not permitted to comment on aggregate '%s'",
-	   aggregate);
-    }
-  }
-  #endif
-
-  /*** Now, attempt to find the actual tuple in pg_aggregate ***/
-
-  aggtuple = SearchSysCacheTuple(AGGNAME, PointerGetDatum(aggregate),
-				 ObjectIdGetDatum(baseoid), 0, 0);
-  if (!HeapTupleIsValid(aggtuple)) {
-    if (argument) {
-      elog(ERROR, "aggregate type '%s' does not exist for aggregate '%s'",
-	   argument, aggregate);
-    } else {
-      elog(ERROR, "aggregate '%s' does not exist", aggregate);
-    }
-  }
-
-  oid = aggtuple->t_data->t_oid;
-
-  /*** Call CreateComments() to create/drop the comments ***/
-
-  CreateComments(oid, comment);
+static void
+CommentAggregate(char *aggregate, char *argument, char *comment)
+{
+
+	HeapTuple	aggtuple;
+	Oid			baseoid,
+				oid;
+	bool		defined;
+	char	   *user;
+
+	/*** First, attempt to determine the base aggregate oid ***/
+
+	if (argument)
+	{
+		baseoid = TypeGet(argument, &defined);
+		if (!OidIsValid(baseoid))
+			elog(ERROR, "aggregate type '%s' does not exist", argument);
+	}
+	else
+		baseoid = 0;
+
+	/*** Next, validate the user's attempt to comment ***/
+
+#ifndef NO_SECURITY
+	user = GetPgUserName();
+	if (!pg_aggr_ownercheck(user, aggregate, baseoid))
+	{
+		if (argument)
+		{
+			elog(ERROR, "you are not permitted to comment on aggregate '%s' %s '%s'",
+				 aggregate, "with type", argument);
+		}
+		else
+		{
+			elog(ERROR, "you are not permitted to comment on aggregate '%s'",
+				 aggregate);
+		}
+	}
+#endif
+
+	/*** Now, attempt to find the actual tuple in pg_aggregate ***/
+
+	aggtuple = SearchSysCacheTuple(AGGNAME, PointerGetDatum(aggregate),
+								   ObjectIdGetDatum(baseoid), 0, 0);
+	if (!HeapTupleIsValid(aggtuple))
+	{
+		if (argument)
+		{
+			elog(ERROR, "aggregate type '%s' does not exist for aggregate '%s'",
+				 argument, aggregate);
+		}
+		else
+			elog(ERROR, "aggregate '%s' does not exist", aggregate);
+	}
+
+	oid = aggtuple->t_data->t_oid;
+
+	/*** Call CreateComments() to create/drop the comments ***/
+
+	CreateComments(oid, comment);
 
 }
 
@@ -592,12 +624,17 @@ static void CommentAggregate(char *aggregate, char *argument, char *comment) {
  *------------------------------------------------------------------
 */
 
-static void CommentProc(char *function, List *arguments, char *comment)
+static void
+CommentProc(char *function, List *arguments, char *comment)
 {
-	HeapTuple argtuple, functuple;
-	Oid oid, argoids[FUNC_MAX_ARGS];
-	char *user, *argument;
-	int i, argcount;
+	HeapTuple	argtuple,
+				functuple;
+	Oid			oid,
+				argoids[FUNC_MAX_ARGS];
+	char	   *user,
+			   *argument;
+	int			i,
+				argcount;
 
 	/*** First, initialize function's argument list with their type oids ***/
 
@@ -606,13 +643,12 @@ static void CommentProc(char *function, List *arguments, char *comment)
 	if (argcount > FUNC_MAX_ARGS)
 		elog(ERROR, "functions cannot have more than %d arguments",
 			 FUNC_MAX_ARGS);
-	for (i = 0; i < argcount; i++) {
+	for (i = 0; i < argcount; i++)
+	{
 		argument = strVal(lfirst(arguments));
 		arguments = lnext(arguments);
 		if (strcmp(argument, "opaque") == 0)
-		{
 			argoids[i] = 0;
-		}
 		else
 		{
 			argtuple = SearchSysCacheTuple(TYPENAME,
@@ -623,7 +659,7 @@ static void CommentProc(char *function, List *arguments, char *comment)
 					 argument);
 			argoids[i] = argtuple->t_data->t_oid;
 		}
-    }
+	}
 
 	/*** Now, validate the user's ability to comment on this function ***/
 
@@ -663,81 +699,89 @@ static void CommentProc(char *function, List *arguments, char *comment)
  *------------------------------------------------------------------
 */
 
-static void CommentOperator(char *opername, List *arguments, char *comment) {
-
-  Form_pg_operator data;
-  HeapTuple optuple;
-  Oid oid, leftoid = InvalidOid, rightoid = InvalidOid;
-  bool defined;
-  char oprtype = 0, *user, *lefttype = NULL, *righttype = NULL;
-
-  /*** Initialize our left and right argument types ***/
-
-  if (lfirst(arguments) != NULL) {
-    lefttype = strVal(lfirst(arguments));
-  }
-  if (lsecond(arguments) != NULL) {
-    righttype = strVal(lsecond(arguments));
-  }
+static void
+CommentOperator(char *opername, List *arguments, char *comment)
+{
 
-  /*** Attempt to fetch the left oid, if specified ***/
+	Form_pg_operator data;
+	HeapTuple	optuple;
+	Oid			oid,
+				leftoid = InvalidOid,
+				rightoid = InvalidOid;
+	bool		defined;
+	char		oprtype = 0,
+			   *user,
+			   *lefttype = NULL,
+			   *righttype = NULL;
+
+	/*** Initialize our left and right argument types ***/
+
+	if (lfirst(arguments) != NULL)
+		lefttype = strVal(lfirst(arguments));
+	if (lsecond(arguments) != NULL)
+		righttype = strVal(lsecond(arguments));
+
+	/*** Attempt to fetch the left oid, if specified ***/
+
+	if (lefttype != NULL)
+	{
+		leftoid = TypeGet(lefttype, &defined);
+		if (!OidIsValid(leftoid))
+			elog(ERROR, "left type '%s' does not exist", lefttype);
+	}
 
-  if (lefttype != NULL) {
-    leftoid = TypeGet(lefttype, &defined);
-    if (!OidIsValid(leftoid)) {
-      elog(ERROR, "left type '%s' does not exist", lefttype);
-    }
-  }
+	/*** Attempt to fetch the right oid, if specified ***/
 
-  /*** Attempt to fetch the right oid, if specified ***/
+	if (righttype != NULL)
+	{
+		rightoid = TypeGet(righttype, &defined);
+		if (!OidIsValid(rightoid))
+			elog(ERROR, "right type '%s' does not exist", righttype);
+	}
 
-  if (righttype != NULL) {
-    rightoid = TypeGet(righttype, &defined);
-    if (!OidIsValid(rightoid)) {
-      elog(ERROR, "right type '%s' does not exist", righttype);
-    }
-  }
+	/*** Determine operator type ***/
 
-  /*** Determine operator type ***/
+	if (OidIsValid(leftoid) && (OidIsValid(rightoid)))
+		oprtype = 'b';
+	else if (OidIsValid(leftoid))
+		oprtype = 'l';
+	else if (OidIsValid(rightoid))
+		oprtype = 'r';
+	else
+		elog(ERROR, "operator '%s' is of an illegal type'", opername);
 
-  if (OidIsValid(leftoid) && (OidIsValid(rightoid))) oprtype = 'b';
-  else if (OidIsValid(leftoid)) oprtype = 'l';
-  else if (OidIsValid(rightoid)) oprtype = 'r';
-  else elog(ERROR, "operator '%s' is of an illegal type'", opername);
+	/*** Attempt to fetch the operator oid ***/
 
-  /*** Attempt to fetch the operator oid ***/
+	optuple = SearchSysCacheTupleCopy(OPERNAME, PointerGetDatum(opername),
+									  ObjectIdGetDatum(leftoid),
+									  ObjectIdGetDatum(rightoid),
+									  CharGetDatum(oprtype));
+	if (!HeapTupleIsValid(optuple))
+		elog(ERROR, "operator '%s' does not exist", opername);
 
-  optuple = SearchSysCacheTupleCopy(OPERNAME, PointerGetDatum(opername),
-				    ObjectIdGetDatum(leftoid),
-				    ObjectIdGetDatum(rightoid),
-				    CharGetDatum(oprtype));
-  if (!HeapTupleIsValid(optuple)) {
-    elog(ERROR, "operator '%s' does not exist", opername);
-  }
+	oid = optuple->t_data->t_oid;
 
-  oid = optuple->t_data->t_oid;
+	/*** Valid user's ability to comment on this operator ***/
 
-  /*** Valid user's ability to comment on this operator ***/
+#ifndef NO_SECURITY
+	user = GetPgUserName();
+	if (!pg_ownercheck(user, (char *) ObjectIdGetDatum(oid), OPEROID))
+	{
+		elog(ERROR, "you are not permitted to comment on operator '%s'",
+			 opername);
+	}
+#endif
 
-  #ifndef NO_SECURITY
-  user = GetPgUserName();
-  if (!pg_ownercheck(user, (char *) ObjectIdGetDatum(oid), OPEROID)) {
-    elog(ERROR, "you are not permitted to comment on operator '%s'",
-	 opername);
-  }
-  #endif
+	/*** Get the procedure associated with the operator ***/
 
-  /*** Get the procedure associated with the operator ***/
+	data = (Form_pg_operator) GETSTRUCT(optuple);
+	oid = regproctooid(data->oprcode);
+	if (oid == InvalidOid)
+		elog(ERROR, "operator '%s' does not have an underlying function", opername);
 
-  data = (Form_pg_operator) GETSTRUCT(optuple);
-  oid = regproctooid(data->oprcode);
-  if (oid == InvalidOid) {
-	  elog(ERROR, "operator '%s' does not have an underlying function", opername);
-  }
-  
-  /*** Call CreateComments() to create/drop the comments ***/
+	/*** Call CreateComments() to create/drop the comments ***/
 
-  CreateComments(oid, comment);
+	CreateComments(oid, comment);
 
 }
 
@@ -752,58 +796,65 @@ static void CommentOperator(char *opername, List *arguments, char *comment) {
  *------------------------------------------------------------------
 */
 
-static void CommentTrigger(char *trigger, char *relname, char *comment) {
-
-  Form_pg_trigger data;
-  Relation pg_trigger, relation;
-  HeapTuple triggertuple;
-  HeapScanDesc scan;
-  ScanKeyData entry;
-  Oid oid = InvalidOid;
-  char *user;
-
-  /*** First, validate the user's action ***/
-
-  #ifndef NO_SECURITY
-  user = GetPgUserName();
-  if (!pg_ownercheck(user, relname, RELNAME)) {
-    elog(ERROR, "you are not permitted to comment on trigger '%s' %s '%s'",
-	 trigger, "defined for relation", relname);
-  }
-  #endif
-
-  /*** Now, fetch the trigger oid from pg_trigger  ***/
-
-  relation = heap_openr(relname, AccessShareLock);
-  pg_trigger = heap_openr(TriggerRelationName, AccessShareLock);
-  ScanKeyEntryInitialize(&entry, 0, Anum_pg_trigger_tgrelid,
-			 F_OIDEQ, RelationGetRelid(relation));
-  scan = heap_beginscan(pg_trigger, 0, SnapshotNow, 1, &entry);
-  triggertuple = heap_getnext(scan, 0);
-  while (HeapTupleIsValid(triggertuple)) {
-    data = (Form_pg_trigger) GETSTRUCT(triggertuple);
-    if (namestrcmp(&(data->tgname), trigger) == 0) {
-      oid = triggertuple->t_data->t_oid;
-      break;
-    }
-    triggertuple = heap_getnext(scan, 0);
-  }
-
-  /*** If no trigger exists for the relation specified, notify user ***/
-
-  if (oid == InvalidOid) {
-    elog(ERROR, "trigger '%s' defined for relation '%s' does not exist",
-	 trigger, relname);
-  }
-
-  /*** Create the comments with the pg_trigger oid ***/
-
-  CreateComments(oid, comment);
-
-  /*** Complete the scan and close any opened relations ***/
-
-  heap_endscan(scan);
-  heap_close(pg_trigger, AccessShareLock);
-  heap_close(relation, AccessShareLock);
+static void
+CommentTrigger(char *trigger, char *relname, char *comment)
+{
+
+	Form_pg_trigger data;
+	Relation	pg_trigger,
+				relation;
+	HeapTuple	triggertuple;
+	HeapScanDesc scan;
+	ScanKeyData entry;
+	Oid			oid = InvalidOid;
+	char	   *user;
+
+	/*** First, validate the user's action ***/
+
+#ifndef NO_SECURITY
+	user = GetPgUserName();
+	if (!pg_ownercheck(user, relname, RELNAME))
+	{
+		elog(ERROR, "you are not permitted to comment on trigger '%s' %s '%s'",
+			 trigger, "defined for relation", relname);
+	}
+#endif
+
+	/*** Now, fetch the trigger oid from pg_trigger  ***/
+
+	relation = heap_openr(relname, AccessShareLock);
+	pg_trigger = heap_openr(TriggerRelationName, AccessShareLock);
+	ScanKeyEntryInitialize(&entry, 0, Anum_pg_trigger_tgrelid,
+						   F_OIDEQ, RelationGetRelid(relation));
+	scan = heap_beginscan(pg_trigger, 0, SnapshotNow, 1, &entry);
+	triggertuple = heap_getnext(scan, 0);
+	while (HeapTupleIsValid(triggertuple))
+	{
+		data = (Form_pg_trigger) GETSTRUCT(triggertuple);
+		if (namestrcmp(&(data->tgname), trigger) == 0)
+		{
+			oid = triggertuple->t_data->t_oid;
+			break;
+		}
+		triggertuple = heap_getnext(scan, 0);
+	}
+
+	/*** If no trigger exists for the relation specified, notify user ***/
+
+	if (oid == InvalidOid)
+	{
+		elog(ERROR, "trigger '%s' defined for relation '%s' does not exist",
+			 trigger, relname);
+	}
+
+	/*** Create the comments with the pg_trigger oid ***/
+
+	CreateComments(oid, comment);
+
+	/*** Complete the scan and close any opened relations ***/
+
+	heap_endscan(scan);
+	heap_close(pg_trigger, AccessShareLock);
+	heap_close(relation, AccessShareLock);
 
 }
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 8634ab11dd5913cea5a521fc4aa2e175f86c69b5..7662b9dc28a87ff1399aa65e4a44a66ead6d7323 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.103 2000/03/23 21:38:58 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.104 2000/04/12 17:14:58 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -64,8 +64,8 @@ static int	CountTuples(Relation relation);
  * Static communication variables ... pretty grotty, but COPY has
  * never been reentrant...
  */
-int		lineno = 0;		/* used by elog() -- dz */
-static bool	fe_eof;
+int			lineno = 0;			/* used by elog() -- dz */
+static bool fe_eof;
 
 /*
  * These static variables are used to avoid incurring overhead for each
@@ -76,9 +76,11 @@ static bool	fe_eof;
  * to attribute_buf's data buffer!
  * encoding, if needed, can be set once at the start of the copy operation.
  */
-static StringInfoData	attribute_buf;
+static StringInfoData attribute_buf;
+
 #ifdef MULTIBYTE
-static int				encoding;
+static int	encoding;
+
 #endif
 
 
@@ -113,11 +115,11 @@ CopySendData(void *databuf, int datasize, FILE *fp)
 			fe_eof = true;
 	}
 	else
-    {
+	{
 		fwrite(databuf, datasize, 1, fp);
-        if (ferror(fp))
-            elog(ERROR, "CopySendData: %s", strerror(errno));
-    }
+		if (ferror(fp))
+			elog(ERROR, "CopySendData: %s", strerror(errno));
+	}
 }
 
 static void
@@ -194,7 +196,8 @@ CopyPeekChar(FILE *fp)
 {
 	if (!fp)
 	{
-		int ch = pq_peekbyte();
+		int			ch = pq_peekbyte();
+
 		if (ch == EOF)
 			fe_eof = true;
 		return ch;
@@ -280,15 +283,15 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
 	 * Open and lock the relation, using the appropriate lock type.
 	 *
 	 * Note: AccessExclusive is probably overkill for copying to a relation,
-	 * but that's what the code grabs on the rel's indices.  If this lock is
-	 * relaxed then I think the index locks need relaxed also.
+	 * but that's what the code grabs on the rel's indices.  If this lock
+	 * is relaxed then I think the index locks need relaxed also.
 	 */
 	rel = heap_openr(relname, (from ? AccessExclusiveLock : AccessShareLock));
 
 	result = pg_aclcheck(relname, UserName, required_access);
 	if (result != ACLCHECK_OK)
 		elog(ERROR, "%s: %s", relname, aclcheck_error_strings[result]);
-    if (!pipe && !superuser())
+	if (!pipe && !superuser())
 		elog(ERROR, "You must have Postgres superuser privilege to do a COPY "
 			 "directly to or from a file.  Anyone can COPY to stdout or "
 			 "from stdin.  Psql's \\copy command also works for anyone.");
@@ -345,13 +348,13 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
 		}
 		else
 		{
-			mode_t		oumask;		/* Pre-existing umask value */
+			mode_t		oumask; /* Pre-existing umask value */
 
-            oumask = umask((mode_t) 022);
+			oumask = umask((mode_t) 022);
 
 			if (*filename != '/')
 				elog(ERROR, "Relative path not allowed for server side"
-							" COPY command.");
+					 " COPY command.");
 
 #ifndef __CYGWIN32__
 			fp = AllocateFile(filename, "w");
@@ -369,9 +372,7 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
 	}
 
 	if (!pipe)
-	{
 		FreeFile(fp);
-	}
 	else if (!from)
 	{
 		if (!binary)
@@ -382,9 +383,10 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
 	pfree(attribute_buf.data);
 
 	/*
-	 * Close the relation.  If reading, we can release the AccessShareLock
-	 * we got; if writing, we should hold the lock until end of transaction
-	 * to ensure that updates will be committed before lock is released.
+	 * Close the relation.	If reading, we can release the AccessShareLock
+	 * we got; if writing, we should hold the lock until end of
+	 * transaction to ensure that updates will be committed before lock is
+	 * released.
 	 */
 	heap_close(rel, (from ? NoLock : AccessShareLock));
 }
@@ -399,9 +401,11 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null_p
 
 	int32		attr_count,
 				i;
+
 #ifdef	_DROP_COLUMN_HACK__
-	bool		*valid;
-#endif /* _DROP_COLUMN_HACK__ */
+	bool	   *valid;
+
+#endif	 /* _DROP_COLUMN_HACK__ */
 	Form_pg_attribute *attr;
 	FmgrInfo   *out_functions;
 	Oid			out_func_oid;
@@ -435,7 +439,7 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null_p
 		typmod = (int32 *) palloc(attr_count * sizeof(int32));
 #ifdef	_DROP_COLUMN_HACK__
 		valid = (bool *) palloc(attr_count * sizeof(bool));
-#endif /* _DROP_COLUMN_HACK__ */
+#endif	 /* _DROP_COLUMN_HACK__ */
 		for (i = 0; i < attr_count; i++)
 		{
 #ifdef	_DROP_COLUMN_HACK__
@@ -446,7 +450,7 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null_p
 			}
 			else
 				valid[i] = true;
-#endif /* _DROP_COLUMN_HACK__ */
+#endif	 /* _DROP_COLUMN_HACK__ */
 			out_func_oid = (Oid) GetOutputFunction(attr[i]->atttypid);
 			fmgr_info(out_func_oid, &out_functions[i]);
 			elements[i] = GetTypeElement(attr[i]->atttypid);
@@ -493,7 +497,7 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null_p
 						CopySendChar('\n', fp);
 					continue;
 				}
-#endif /* _DROP_COLUMN_HACK__ */
+#endif	 /* _DROP_COLUMN_HACK__ */
 				if (!isnull)
 				{
 					string = (char *) (*fmgr_faddr(&out_functions[i]))
@@ -502,7 +506,7 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null_p
 					pfree(string);
 				}
 				else
-					CopySendString(null_print, fp);	/* null indicator */
+					CopySendString(null_print, fp);		/* null indicator */
 
 				if (i == attr_count - 1)
 					CopySendChar('\n', fp);
@@ -723,7 +727,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null
 #ifdef	_DROP_COLUMN_HACK__
 			if (COLUMN_IS_DROPPED(attr[i]))
 				continue;
-#endif /* _DROP_COLUMN_HACK__ */
+#endif	 /* _DROP_COLUMN_HACK__ */
 			in_func_oid = (Oid) GetInputFunction(attr[i]->atttypid);
 			fmgr_info(in_func_oid, &in_functions[i]);
 			elements[i] = GetTypeElement(attr[i]->atttypid);
@@ -756,7 +760,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null
 			byval[i] = 'n';
 			continue;
 		}
-#endif /* _DROP_COLUMN_HACK__ */
+#endif	 /* _DROP_COLUMN_HACK__ */
 		byval[i] = (bool) IsTypeByVal(attr[i]->atttypid);
 	}
 
@@ -765,7 +769,8 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null
 
 	while (!done)
 	{
-		if (QueryCancel) {
+		if (QueryCancel)
+		{
 			lineno = 0;
 			CancelQuery();
 		}
@@ -796,7 +801,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null
 					nulls[i] = 'n';
 					continue;
 				}
-#endif /* _DROP_COLUMN_HACK__ */
+#endif	 /* _DROP_COLUMN_HACK__ */
 				string = CopyReadAttribute(fp, &isnull, delim, &newline, null_print);
 				if (isnull)
 				{
@@ -937,7 +942,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null
 						 */
 						slot->val = tuple;
 						/* SetSlotContents(slot, tuple); */
-						if (! ExecQual((List *) indexPred[i], econtext, false))
+						if (!ExecQual((List *) indexPred[i], econtext, false))
 							continue;
 #endif	 /* OMIT_PARTIAL_INDEX */
 					}
@@ -1189,6 +1194,7 @@ static char *
 CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_print)
 {
 	int			c;
+
 #ifdef MULTIBYTE
 	int			mblen;
 	unsigned char s[2];
@@ -1222,9 +1228,7 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
 			break;
 		}
 		if (strchr(delim, c))
-		{
 			break;
-		}
 		if (c == '\\')
 		{
 			c = CopyGetChar(fp);
@@ -1272,13 +1276,16 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
 						c = val & 0377;
 					}
 					break;
-                    /* This is a special hack to parse `\N' as <backslash-N>
-                       rather then just 'N' to provide compatibility with
-                       the default NULL output. -- pe */
-                case 'N':
-                    appendStringInfoCharMacro(&attribute_buf, '\\');
-                    c = 'N';
-                    break;
+
+					/*
+					 * This is a special hack to parse `\N' as
+					 * <backslash-N> rather then just 'N' to provide
+					 * compatibility with the default NULL output. -- pe
+					 */
+				case 'N':
+					appendStringInfoCharMacro(&attribute_buf, '\\');
+					c = 'N';
+					break;
 				case 'b':
 					c = '\b';
 					break;
@@ -1332,8 +1339,8 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
 	}
 #endif
 
-    if (strcmp(attribute_buf.data, null_print)==0)
-        *isnull = true;
+	if (strcmp(attribute_buf.data, null_print) == 0)
+		*isnull = true;
 
 	return attribute_buf.data;
 
@@ -1346,10 +1353,12 @@ CopyAttributeOut(FILE *fp, char *server_string, char *delim)
 {
 	char	   *string;
 	char		c;
+
 #ifdef MULTIBYTE
 	char	   *string_start;
 	int			mblen;
 	int			i;
+
 #endif
 
 #ifdef MULTIBYTE
diff --git a/src/backend/commands/creatinh.c b/src/backend/commands/creatinh.c
index da0fcd479ede24f661009907d95a1f75808704e1..17dbe2cbdffdde66628b74d680de8d54dd01d288 100644
--- a/src/backend/commands/creatinh.c
+++ b/src/backend/commands/creatinh.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.56 2000/01/29 16:58:34 petere Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.57 2000/04/12 17:14:58 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -32,7 +32,7 @@
  */
 
 static bool checkAttrExists(const char *attributeName,
-                            const char *attributeType, List *schema);
+				const char *attributeType, List *schema);
 static List *MergeAttributes(List *schema, List *supers, List **supconstr);
 static void StoreCatalogInheritance(Oid relationId, List *supers);
 
@@ -145,14 +145,14 @@ DefineRelation(CreateStmt *stmt, char relkind)
 	StoreCatalogInheritance(relationId, inheritList);
 
 	/*
-	 * Now add any newly specified column default values
-	 * and CHECK constraints to the new relation.  These are passed
-	 * to us in the form of raw parsetrees; we need to transform
-	 * them to executable expression trees before they can be added.
-	 * The most convenient way to do that is to apply the parser's
-	 * transformExpr routine, but transformExpr doesn't work unless
-	 * we have a pre-existing relation.  So, the transformation has
-	 * to be postponed to this final step of CREATE TABLE.
+	 * Now add any newly specified column default values and CHECK
+	 * constraints to the new relation.  These are passed to us in the
+	 * form of raw parsetrees; we need to transform them to executable
+	 * expression trees before they can be added. The most convenient way
+	 * to do that is to apply the parser's transformExpr routine, but
+	 * transformExpr doesn't work unless we have a pre-existing relation.
+	 * So, the transformation has to be postponed to this final step of
+	 * CREATE TABLE.
 	 *
 	 * First, scan schema to find new column defaults.
 	 */
@@ -181,21 +181,24 @@ DefineRelation(CreateStmt *stmt, char relkind)
 		return;
 
 	/*
-	 * We must bump the command counter to make the newly-created
-	 * relation tuple visible for opening.
+	 * We must bump the command counter to make the newly-created relation
+	 * tuple visible for opening.
 	 */
 	CommandCounterIncrement();
+
 	/*
 	 * Open the new relation.
 	 */
 	rel = heap_openr(relname, AccessExclusiveLock);
+
 	/*
 	 * Parse and add the defaults/constraints.
 	 */
 	AddRelationRawConstraints(rel, rawDefaults, stmt->constraints);
+
 	/*
-	 * Clean up.  We keep lock on new relation (although it shouldn't
-	 * be visible to anyone else anyway, until commit).
+	 * Clean up.  We keep lock on new relation (although it shouldn't be
+	 * visible to anyone else anyway, until commit).
 	 */
 	heap_close(rel, NoLock);
 }
@@ -220,13 +223,13 @@ RemoveRelation(char *name)
 
 /*
  * TruncateRelation --
- *                Removes all the rows from a relation
+ *				  Removes all the rows from a relation
  *
  * Exceptions:
- *                BadArg if name is invalid
+ *				  BadArg if name is invalid
  *
  * Note:
- *                Rows are removed, indices are truncated and reconstructed.
+ *				  Rows are removed, indices are truncated and reconstructed.
  */
 void
 TruncateRelation(char *name)
@@ -284,6 +287,7 @@ MergeAttributes(List *schema, List *supers, List **supconstr)
 
 		foreach(rest, lnext(entry))
 		{
+
 			/*
 			 * check for duplicated names within the new relation
 			 */
@@ -352,11 +356,12 @@ MergeAttributes(List *schema, List *supers, List **supconstr)
 			 * check validity
 			 *
 			 */
-            if (checkAttrExists(attributeName, attributeType, schema))
-                elog(ERROR, "CREATE TABLE: attribute \"%s\" already exists in inherited schema",
-                     attributeName);
+			if (checkAttrExists(attributeName, attributeType, schema))
+				elog(ERROR, "CREATE TABLE: attribute \"%s\" already exists in inherited schema",
+					 attributeName);
 
 			if (checkAttrExists(attributeName, attributeType, inhSchema))
+
 				/*
 				 * this entry already exists
 				 */
@@ -499,7 +504,7 @@ StoreCatalogInheritance(Oid relationId, List *supers)
 		if (RelationGetForm(relation)->relhasindex)
 		{
 			Relation	idescs[Num_pg_inherits_indices];
-	
+
 			CatalogOpenIndices(Num_pg_inherits_indices, Name_pg_inherits_indices, idescs);
 			CatalogIndexInsert(idescs, Num_pg_inherits_indices, relation, tuple);
 			CatalogCloseIndices(Num_pg_inherits_indices, idescs);
@@ -642,8 +647,9 @@ checkAttrExists(const char *attributeName, const char *attributeType, List *sche
 	{
 		ColumnDef  *def = lfirst(s);
 
-		if (strcmp(attributeName, def->colname)==0)
+		if (strcmp(attributeName, def->colname) == 0)
 		{
+
 			/*
 			 * attribute exists. Make sure the types are the same.
 			 */
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index d4e88ec2dde4d237b3fc03fa07c0d7c57793b668..d09973f5402f09f909e948df3793824b14a982d4 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.52 2000/03/26 18:32:28 petere Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.53 2000/04/12 17:14:58 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -33,9 +33,9 @@
 #include "catalog/pg_shadow.h"
 #include "commands/comment.h"
 #include "miscadmin.h"
-#include "storage/bufmgr.h"        /* for DropBuffers */
-#include "storage/fd.h"            /* for closeAllVfds */
-#include "storage/sinval.h"        /* for DatabaseHasActiveBackends */
+#include "storage/bufmgr.h"		/* for DropBuffers */
+#include "storage/fd.h"			/* for closeAllVfds */
+#include "storage/sinval.h"		/* for DatabaseHasActiveBackends */
 #include "utils/builtins.h"
 #include "utils/elog.h"
 #include "utils/palloc.h"
@@ -45,10 +45,10 @@
 
 /* non-export function prototypes */
 static bool
-get_user_info(const char *name, int4 *use_sysid, bool *use_super, bool *use_createdb);
+			get_user_info(const char *name, int4 *use_sysid, bool *use_super, bool *use_createdb);
 
 static bool
-get_db_info(const char *name, char *dbpath, Oid *dbIdP, int4 *ownerIdP);
+			get_db_info(const char *name, char *dbpath, Oid *dbIdP, int4 *ownerIdP);
 
 
 
@@ -61,99 +61,104 @@ createdb(const char *dbname, const char *dbpath, int encoding)
 {
 	char		buf[2 * MAXPGPATH + 100];
 	char	   *loc;
-    char        locbuf[512];
+	char		locbuf[512];
 	int4		user_id;
-    bool        use_super, use_createdb;
+	bool		use_super,
+				use_createdb;
 	Relation	pg_database_rel;
 	HeapTuple	tuple;
-    TupleDesc   pg_database_dsc;
-    Datum       new_record[Natts_pg_database];
-    char        new_record_nulls[Natts_pg_database] = { ' ', ' ', ' ', ' ' };
+	TupleDesc	pg_database_dsc;
+	Datum		new_record[Natts_pg_database];
+	char		new_record_nulls[Natts_pg_database] = {' ', ' ', ' ', ' '};
 
-    if (!get_user_info(GetPgUserName(), &user_id, &use_super, &use_createdb))
-        elog(ERROR, "current user name is invalid");
+	if (!get_user_info(GetPgUserName(), &user_id, &use_super, &use_createdb))
+		elog(ERROR, "current user name is invalid");
 
-    if (!use_createdb && !use_super)
-        elog(ERROR, "CREATE DATABASE: permission denied");
+	if (!use_createdb && !use_super)
+		elog(ERROR, "CREATE DATABASE: permission denied");
 
-    if (get_db_info(dbname, NULL, NULL, NULL))
-        elog(ERROR, "CREATE DATABASE: database \"%s\" already exists", dbname);
+	if (get_db_info(dbname, NULL, NULL, NULL))
+		elog(ERROR, "CREATE DATABASE: database \"%s\" already exists", dbname);
 
-    /* don't call this in a transaction block */
+	/* don't call this in a transaction block */
 	if (IsTransactionBlock())
-        elog(ERROR, "CREATE DATABASE: may not be called in a transaction block");
+		elog(ERROR, "CREATE DATABASE: may not be called in a transaction block");
 
 	/* Generate directory name for the new database */
-    if (dbpath == NULL || strcmp(dbpath, dbname)==0)
-        strcpy(locbuf, dbname);
-    else
-        snprintf(locbuf, sizeof(locbuf), "%s/%s", dbpath, dbname);
+	if (dbpath == NULL || strcmp(dbpath, dbname) == 0)
+		strcpy(locbuf, dbname);
+	else
+		snprintf(locbuf, sizeof(locbuf), "%s/%s", dbpath, dbname);
 
-    loc = ExpandDatabasePath(locbuf);
+	loc = ExpandDatabasePath(locbuf);
 
 	if (loc == NULL)
 		elog(ERROR,
-             "The database path '%s' is invalid. "
+			 "The database path '%s' is invalid. "
 			 "This may be due to a character that is not allowed or because the chosen "
-             "path isn't permitted for databases", dbpath);
+			 "path isn't permitted for databases", dbpath);
 
-	/* close virtual file descriptors so the kernel has more available for
-       the system() calls */
+	/*
+	 * close virtual file descriptors so the kernel has more available for
+	 * the system() calls
+	 */
 	closeAllVfds();
 
-    /*
-     * Insert a new tuple into pg_database
-     */
+	/*
+	 * Insert a new tuple into pg_database
+	 */
 	pg_database_rel = heap_openr(DatabaseRelationName, AccessExclusiveLock);
 	pg_database_dsc = RelationGetDescr(pg_database_rel);
 
-    /* Form tuple */
-    new_record[Anum_pg_database_datname-1] = NameGetDatum(namein(dbname));
-    new_record[Anum_pg_database_datdba-1] = Int32GetDatum(user_id);
-    new_record[Anum_pg_database_encoding-1] = Int32GetDatum(encoding);
-    new_record[Anum_pg_database_datpath-1] = PointerGetDatum(textin(locbuf));
+	/* Form tuple */
+	new_record[Anum_pg_database_datname - 1] = NameGetDatum(namein(dbname));
+	new_record[Anum_pg_database_datdba - 1] = Int32GetDatum(user_id);
+	new_record[Anum_pg_database_encoding - 1] = Int32GetDatum(encoding);
+	new_record[Anum_pg_database_datpath - 1] = PointerGetDatum(textin(locbuf));
 
-    tuple = heap_formtuple(pg_database_dsc, new_record, new_record_nulls);
+	tuple = heap_formtuple(pg_database_dsc, new_record, new_record_nulls);
 
-    /*
-     * Update table
-     */
-    heap_insert(pg_database_rel, tuple);
+	/*
+	 * Update table
+	 */
+	heap_insert(pg_database_rel, tuple);
 
-    /*
-     * Update indexes (there aren't any currently)
-     */
+	/*
+	 * Update indexes (there aren't any currently)
+	 */
 #ifdef Num_pg_database_indices
-    if (RelationGetForm(pg_database_rel)->relhasindex) {
-        Relation idescs[Num_pg_database_indices];
-      
-        CatalogOpenIndices(Num_pg_database_indices, 
-                           Name_pg_database_indices, idescs);
-        CatalogIndexInsert(idescs, Num_pg_database_indices, pg_database_rel, 
-                           tuple);
-        CatalogCloseIndices(Num_pg_database_indices, idescs);
-    }
+	if (RelationGetForm(pg_database_rel)->relhasindex)
+	{
+		Relation	idescs[Num_pg_database_indices];
+
+		CatalogOpenIndices(Num_pg_database_indices,
+						   Name_pg_database_indices, idescs);
+		CatalogIndexInsert(idescs, Num_pg_database_indices, pg_database_rel,
+						   tuple);
+		CatalogCloseIndices(Num_pg_database_indices, idescs);
+	}
 #endif
 
 	heap_close(pg_database_rel, NoLock);
 
-    /* Copy the template database to the new location */
+	/* Copy the template database to the new location */
 
-	if (mkdir(loc, S_IRWXU) != 0) {
+	if (mkdir(loc, S_IRWXU) != 0)
 		elog(ERROR, "CREATE DATABASE: unable to create database directory '%s': %s", loc, strerror(errno));
-    }
 
 	snprintf(buf, sizeof(buf), "cp %s%cbase%ctemplate1%c* '%s'",
 			 DataDir, SEP_CHAR, SEP_CHAR, SEP_CHAR, loc);
-	if (system(buf) != 0) {
-        int ret;
-        snprintf(buf, sizeof(buf), "rm -rf '%s'", loc);
-        ret = system(buf);
-        if (ret == 0)
-            elog(ERROR, "CREATE DATABASE: could not initialize database directory");
-        else
-            elog(ERROR, "CREATE DATABASE: Could not initialize database directory. Delete failed as well");
-    }
+	if (system(buf) != 0)
+	{
+		int			ret;
+
+		snprintf(buf, sizeof(buf), "rm -rf '%s'", loc);
+		ret = system(buf);
+		if (ret == 0)
+			elog(ERROR, "CREATE DATABASE: could not initialize database directory");
+		else
+			elog(ERROR, "CREATE DATABASE: Could not initialize database directory. Delete failed as well");
+	}
 }
 
 
@@ -165,18 +170,19 @@ createdb(const char *dbname, const char *dbpath, int encoding)
 void
 dropdb(const char *dbname)
 {
-	int4		user_id, db_owner;
-    bool        use_super;
+	int4		user_id,
+				db_owner;
+	bool		use_super;
 	Oid			db_id;
 	char	   *path,
 				dbpath[MAXPGPATH],
 				buf[MAXPGPATH + 100];
 	Relation	pgdbrel;
 	HeapScanDesc pgdbscan;
-	ScanKeyData	key;
+	ScanKeyData key;
 	HeapTuple	tup;
 
-    AssertArg(dbname);
+	AssertArg(dbname);
 
 	if (strcmp(dbname, "template1") == 0)
 		elog(ERROR, "DROP DATABASE: May not be executed on the template1 database");
@@ -185,46 +191,49 @@ dropdb(const char *dbname)
 		elog(ERROR, "DROP DATABASE: Cannot be executed on the currently open database");
 
 	if (IsTransactionBlock())
-        elog(ERROR, "DROP DATABASE: May not be called in a transaction block");
+		elog(ERROR, "DROP DATABASE: May not be called in a transaction block");
 
-    if (!get_user_info(GetPgUserName(), &user_id, &use_super, NULL))
-        elog(ERROR, "Current user name is invalid");
+	if (!get_user_info(GetPgUserName(), &user_id, &use_super, NULL))
+		elog(ERROR, "Current user name is invalid");
 
-    if (!get_db_info(dbname, dbpath, &db_id, &db_owner))
-        elog(ERROR, "DROP DATABASE: Database \"%s\" does not exist", dbname);
+	if (!get_db_info(dbname, dbpath, &db_id, &db_owner))
+		elog(ERROR, "DROP DATABASE: Database \"%s\" does not exist", dbname);
 
-    if (user_id != db_owner && !use_super)
-        elog(ERROR, "DROP DATABASE: Permission denied");
+	if (user_id != db_owner && !use_super)
+		elog(ERROR, "DROP DATABASE: Permission denied");
 
 	path = ExpandDatabasePath(dbpath);
 	if (path == NULL)
 		elog(ERROR,
-             "The database path '%s' is invalid. "
+			 "The database path '%s' is invalid. "
 			 "This may be due to a character that is not allowed or because the chosen "
-             "path isn't permitted for databases", path);
+			 "path isn't permitted for databases", path);
 
-	/* close virtual file descriptors so the kernel has more available for
-       the system() calls */
+	/*
+	 * close virtual file descriptors so the kernel has more available for
+	 * the system() calls
+	 */
 	closeAllVfds();
 
 	/*
-	 * Obtain exclusive lock on pg_database.  We need this to ensure
-	 * that no new backend starts up in the target database while we
-	 * are deleting it.  (Actually, a new backend might still manage to
-	 * start up, because it will read pg_database without any locking
-	 * to discover the database's OID.  But it will detect its error
-	 * in ReverifyMyDatabase and shut down before any serious damage
-	 * is done.  See postinit.c.)
+	 * Obtain exclusive lock on pg_database.  We need this to ensure that
+	 * no new backend starts up in the target database while we are
+	 * deleting it.  (Actually, a new backend might still manage to start
+	 * up, because it will read pg_database without any locking to
+	 * discover the database's OID.  But it will detect its error in
+	 * ReverifyMyDatabase and shut down before any serious damage is done.
+	 * See postinit.c.)
 	 */
 	pgdbrel = heap_openr(DatabaseRelationName, AccessExclusiveLock);
 
 	/*
 	 * Check for active backends in the target database.
 	 */
-	if (DatabaseHasActiveBackends(db_id)) {
+	if (DatabaseHasActiveBackends(db_id))
+	{
 		heap_close(pgdbrel, AccessExclusiveLock);
 		elog(ERROR, "DROP DATABASE: Database \"%s\" is being accessed by other users", dbname);
-    }
+	}
 
 	/*
 	 * Find the database's tuple by OID (should be unique, we trust).
@@ -238,8 +247,11 @@ dropdb(const char *dbname)
 	if (!HeapTupleIsValid(tup))
 	{
 		heap_close(pgdbrel, AccessExclusiveLock);
-        /* This error should never come up since the existence of the
-           database is checked earlier */
+
+		/*
+		 * This error should never come up since the existence of the
+		 * database is checked earlier
+		 */
 		elog(ERROR, "DROP DATABASE: Database \"%s\" doesn't exist despite earlier reports to the contrary",
 			 dbname);
 	}
@@ -270,7 +282,7 @@ dropdb(const char *dbname)
 	 */
 	snprintf(buf, sizeof(buf), "rm -rf '%s'", path);
 	if (system(buf) != 0)
-        elog(NOTICE, "DROP DATABASE: The database directory '%s' could not be removed", path);
+		elog(NOTICE, "DROP DATABASE: The database directory '%s' could not be removed", path);
 }
 
 
@@ -285,11 +297,11 @@ get_db_info(const char *name, char *dbpath, Oid *dbIdP, int4 *ownerIdP)
 	Relation	relation;
 	HeapTuple	tuple;
 	ScanKeyData scanKey;
-    HeapScanDesc scan;
+	HeapScanDesc scan;
 
-    AssertArg(name);
+	AssertArg(name);
 
-	relation = heap_openr(DatabaseRelationName, AccessExclusiveLock/*???*/);
+	relation = heap_openr(DatabaseRelationName, AccessExclusiveLock /* ??? */ );
 
 	ScanKeyEntryInitialize(&scanKey, 0, Anum_pg_database_datname,
 						   F_NAMEEQ, NameGetDatum(name));
@@ -302,76 +314,76 @@ get_db_info(const char *name, char *dbpath, Oid *dbIdP, int4 *ownerIdP)
 
 	if (HeapTupleIsValid(tuple))
 	{
-        text	   *tmptext;
-        bool        isnull;
-    
-        /* oid of the database */
-        if (dbIdP)
-            *dbIdP = tuple->t_data->t_oid;
-        /* uid of the owner */
-        if (ownerIdP)
-        {
-            *ownerIdP = (int4) heap_getattr(tuple,
-                                            Anum_pg_database_datdba,
-                                            RelationGetDescr(relation),
-                                            &isnull);
-            if (isnull)
-                *ownerIdP = -1; /* hopefully no one has that id already ;) */
-        }
-        /* database path (as registered in pg_database) */
-        if (dbpath)
-        {
-            tmptext = (text *) heap_getattr(tuple,
-                                            Anum_pg_database_datpath,
-                                            RelationGetDescr(relation),
-                                            &isnull);
-
-            if (!isnull)
-            {
-                Assert(VARSIZE(tmptext) - VARHDRSZ < MAXPGPATH);
-
-                strncpy(dbpath, VARDATA(tmptext), VARSIZE(tmptext) - VARHDRSZ);
-                *(dbpath + VARSIZE(tmptext) - VARHDRSZ) = '\0';
-            }
-            else
-                strcpy(dbpath, "");
-        }
+		text	   *tmptext;
+		bool		isnull;
+
+		/* oid of the database */
+		if (dbIdP)
+			*dbIdP = tuple->t_data->t_oid;
+		/* uid of the owner */
+		if (ownerIdP)
+		{
+			*ownerIdP = (int4) heap_getattr(tuple,
+											Anum_pg_database_datdba,
+											RelationGetDescr(relation),
+											&isnull);
+			if (isnull)
+				*ownerIdP = -1; /* hopefully no one has that id already ;) */
+		}
+		/* database path (as registered in pg_database) */
+		if (dbpath)
+		{
+			tmptext = (text *) heap_getattr(tuple,
+											Anum_pg_database_datpath,
+											RelationGetDescr(relation),
+											&isnull);
+
+			if (!isnull)
+			{
+				Assert(VARSIZE(tmptext) - VARHDRSZ < MAXPGPATH);
+
+				strncpy(dbpath, VARDATA(tmptext), VARSIZE(tmptext) - VARHDRSZ);
+				*(dbpath + VARSIZE(tmptext) - VARHDRSZ) = '\0';
+			}
+			else
+				strcpy(dbpath, "");
+		}
 	}
 	else
-    {
-        if (dbIdP)
-            *dbIdP = InvalidOid;
-    }
+	{
+		if (dbIdP)
+			*dbIdP = InvalidOid;
+	}
 
 	heap_endscan(scan);
 
 	/* We will keep the lock on the relation until end of transaction. */
 	heap_close(relation, NoLock);
 
-    return HeapTupleIsValid(tuple);
+	return HeapTupleIsValid(tuple);
 }
 
 
 
 static bool
-get_user_info(const char * name, int4 *use_sysid, bool *use_super, bool *use_createdb)
+get_user_info(const char *name, int4 *use_sysid, bool *use_super, bool *use_createdb)
 {
-    HeapTuple   utup;
+	HeapTuple	utup;
 
 	AssertArg(name);
 	utup = SearchSysCacheTuple(SHADOWNAME,
 							   PointerGetDatum(name),
 							   0, 0, 0);
 
-    if (!HeapTupleIsValid(utup))
-        return false;
+	if (!HeapTupleIsValid(utup))
+		return false;
 
-    if (use_sysid)
-        *use_sysid =    ((Form_pg_shadow) GETSTRUCT(utup))->usesysid;
-    if (use_super)
-        *use_super =    ((Form_pg_shadow) GETSTRUCT(utup))->usesuper;
-    if (use_createdb)
-        *use_createdb = ((Form_pg_shadow) GETSTRUCT(utup))->usecreatedb;
+	if (use_sysid)
+		*use_sysid = ((Form_pg_shadow) GETSTRUCT(utup))->usesysid;
+	if (use_super)
+		*use_super = ((Form_pg_shadow) GETSTRUCT(utup))->usesuper;
+	if (use_createdb)
+		*use_createdb = ((Form_pg_shadow) GETSTRUCT(utup))->usecreatedb;
 
-    return true;
+	return true;
 }
diff --git a/src/backend/commands/define.c b/src/backend/commands/define.c
index 2090076f2e410812f4a7238f56d973801407b06f..c77b467089b3619edcb158e3a08140c6bdd9bb59 100644
--- a/src/backend/commands/define.c
+++ b/src/backend/commands/define.c
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.39 2000/04/07 13:39:24 thomas Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.40 2000/04/12 17:14:58 momjian Exp $
  *
  * DESCRIPTION
  *	  The "DefineFoo" routines take the parse tree and pick out the
@@ -137,12 +137,13 @@ compute_full_attributes(List *parameters, int32 *byte_pct_p,
 
 	foreach(pl, parameters)
 	{
-		DefElem *param = (DefElem *) lfirst(pl);
+		DefElem    *param = (DefElem *) lfirst(pl);
 
 		if (strcasecmp(param->defname, "iscachable") == 0)
 			*canCache_p = true;
 		else if (strcasecmp(param->defname, "trusted") == 0)
 		{
+
 			/*
 			 * we don't have untrusted functions any more. The 4.2
 			 * implementation is lousy anyway so I took it out. -ay 10/94
@@ -233,12 +234,14 @@ CreateFunction(ProcedureStmt *stmt, CommandDest dest)
 	 */
 
 	bool		returnsSet;
+
 	/* The function returns a set of values, as opposed to a singleton. */
 
 	bool		lanisPL = false;
 
 	/*
-	 * The following are optional user-supplied attributes of the function.
+	 * The following are optional user-supplied attributes of the
+	 * function.
 	 */
 	int32		byte_pct,
 				perbyte_cpu,
@@ -256,7 +259,7 @@ CreateFunction(ProcedureStmt *stmt, CommandDest dest)
 			elog(ERROR,
 				 "Only users with Postgres superuser privilege are "
 				 "permitted to create a function "
-				 "in the '%s' language.  Others may use the 'sql' language "
+			  "in the '%s' language.  Others may use the 'sql' language "
 				 "or the created procedural languages.",
 				 languageName);
 	}
@@ -316,17 +319,17 @@ CreateFunction(ProcedureStmt *stmt, CommandDest dest)
 	interpret_AS_clause(languageName, stmt->as, &prosrc_str, &probin_str);
 
 	/*
-	 * And now that we have all the parameters, and know we're
-	 * permitted to do so, go ahead and create the function.
+	 * And now that we have all the parameters, and know we're permitted
+	 * to do so, go ahead and create the function.
 	 */
 	ProcedureCreate(stmt->funcname,
 					returnsSet,
 					prorettype,
 					languageName,
-					prosrc_str,		/* converted to text later */
-					probin_str,		/* converted to text later */
+					prosrc_str, /* converted to text later */
+					probin_str, /* converted to text later */
 					canCache,
-					true,			/* (obsolete "trusted") */
+					true,		/* (obsolete "trusted") */
 					byte_pct,
 					perbyte_cpu,
 					percall_cpu,
@@ -378,7 +381,7 @@ DefineOperator(char *oprName,
 		if (!strcasecmp(defel->defname, "leftarg"))
 		{
 			if ((nodeTag(defel->arg) == T_TypeName)
-				&& (((TypeName *)defel->arg)->setof))
+				&& (((TypeName *) defel->arg)->setof))
 				elog(ERROR, "setof type not implemented for leftarg");
 
 			typeName1 = defGetString(defel);
@@ -388,7 +391,7 @@ DefineOperator(char *oprName,
 		else if (!strcasecmp(defel->defname, "rightarg"))
 		{
 			if ((nodeTag(defel->arg) == T_TypeName)
-				&& (((TypeName *)defel->arg)->setof))
+				&& (((TypeName *) defel->arg)->setof))
 				elog(ERROR, "setof type not implemented for rightarg");
 
 			typeName2 = defGetString(defel);
@@ -698,16 +701,16 @@ DefineType(char *typeName, List *parameters)
 static char *
 defGetString(DefElem *def)
 {
-	char *string;
+	char	   *string;
 
 	if (nodeTag(def->arg) == T_String)
 		string = strVal(def->arg);
 	else if (nodeTag(def->arg) == T_TypeName)
-		string = ((TypeName *)def->arg)->name;
+		string = ((TypeName *) def->arg)->name;
 	else
 		string = NULL;
 #if 0
-		elog(ERROR, "Define: \"%s\" = what?", def->defname);
+	elog(ERROR, "Define: \"%s\" = what?", def->defname);
 #endif
 
 	return string;
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index 64dc164a0d590446b2c99eb170422691f163fd07..d51053c20a17724169acfccb5c07b1d0b0316ab8 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -5,7 +5,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994-5, Regents of the University of California
  *
- * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.55 2000/03/14 23:06:12 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.56 2000/04/12 17:14:58 momjian Exp $
  *
  */
 
@@ -209,7 +209,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
 	switch (nodeTag(plan))
 	{
 		case T_IndexScan:
-			if (ScanDirectionIsBackward(((IndexScan *)plan)->indxorderdir))
+			if (ScanDirectionIsBackward(((IndexScan *) plan)->indxorderdir))
 				appendStringInfo(str, " Backward");
 			appendStringInfo(str, " using ");
 			i = 0;
@@ -219,7 +219,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
 				Assert(relation);
 				appendStringInfo(str, "%s%s",
 								 (++i > 1) ? ", " : "",
-								 stringStringInfo(RelationGetRelationName(relation)));
+					stringStringInfo(RelationGetRelationName(relation)));
 				/* drop relcache refcount from RelationIdGetRelation */
 				RelationDecrementReferenceCount(relation);
 			}
@@ -238,17 +238,17 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
 						|| (length(rte->ref->attrs) > 0))
 					{
 						appendStringInfo(str, " %s",
-										 stringStringInfo(rte->ref->relname));
+									stringStringInfo(rte->ref->relname));
 
 						if (length(rte->ref->attrs) > 0)
 						{
-							List *c;
-							int firstEntry = true;
+							List	   *c;
+							int			firstEntry = true;
 
 							appendStringInfo(str, " (");
-							foreach (c, rte->ref->attrs)
+							foreach(c, rte->ref->attrs)
 							{
-								if (! firstEntry)
+								if (!firstEntry)
 								{
 									appendStringInfo(str, ", ");
 									firstEntry = false;
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 93ad0eb63b47fdd601112ab075a1617ec64c9ba5..2577e4741b1f9a2a69daaa32ba8b863d81392f87 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.22 2000/02/25 02:58:48 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.23 2000/04/12 17:14:58 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -34,9 +34,9 @@
 #include "parser/parse_func.h"
 #include "utils/builtins.h"
 #include "utils/syscache.h"
-#include "miscadmin.h"	/* ReindexDatabase() */
-#include "utils/portal.h" /* ReindexDatabase() */
-#include "catalog/catalog.h" /* ReindexDatabase() */
+#include "miscadmin.h"			/* ReindexDatabase() */
+#include "utils/portal.h"		/* ReindexDatabase() */
+#include "catalog/catalog.h"	/* ReindexDatabase() */
 
 #define IsFuncIndex(ATTR_LIST) (((IndexElem*)lfirst(ATTR_LIST))->args != NIL)
 
@@ -45,11 +45,11 @@ static void CheckPredicate(List *predList, List *rangeTable, Oid baseRelOid);
 static void CheckPredExpr(Node *predicate, List *rangeTable, Oid baseRelOid);
 static void CheckPredClause(Expr *predicate, List *rangeTable, Oid baseRelOid);
 static void FuncIndexArgs(IndexElem *funcIndex, FuncIndexInfo *funcInfo,
-						  AttrNumber *attNumP, Oid *opOidP, Oid relId);
+			  AttrNumber *attNumP, Oid *opOidP, Oid relId);
 static void NormIndexAttrs(List *attList, AttrNumber *attNumP,
-						   Oid *opOidP, Oid relId);
+			   Oid *opOidP, Oid relId);
 static void ProcessAttrTypename(IndexElem *attribute,
-								Oid defType, int32 defTypmod);
+					Oid defType, int32 defTypmod);
 static Oid	GetAttrOpClass(IndexElem *attribute, Oid attrType);
 static char *GetDefaultOpClass(Oid atttypid);
 
@@ -133,7 +133,7 @@ DefineIndex(char *heapRelationName,
 	 */
 	foreach(pl, parameterList)
 	{
-		DefElem *param = (DefElem *) lfirst(pl);
+		DefElem    *param = (DefElem *) lfirst(pl);
 
 		if (!strcasecmp(param->defname, "islossy"))
 			lossy = TRUE;
@@ -174,7 +174,7 @@ DefineIndex(char *heapRelationName,
 		namestrcpy(&fInfo.funcName, funcIndex->name);
 
 		attributeNumberA = (AttrNumber *) palloc(nargs *
-												 sizeof attributeNumberA[0]);
+											 sizeof attributeNumberA[0]);
 
 		classObjectId = (Oid *) palloc(sizeof(Oid));
 
@@ -192,7 +192,7 @@ DefineIndex(char *heapRelationName,
 	else
 	{
 		attributeNumberA = (AttrNumber *) palloc(numberOfAttributes *
-												 sizeof attributeNumberA[0]);
+											 sizeof attributeNumberA[0]);
 
 		classObjectId = (Oid *) palloc(numberOfAttributes * sizeof(Oid));
 
@@ -490,7 +490,7 @@ NormIndexAttrs(List *attList,	/* list of IndexElem's */
 
 		atttuple = SearchSysCacheTupleCopy(ATTNAME,
 										   ObjectIdGetDatum(relId),
-										   PointerGetDatum(attribute->name),
+										PointerGetDatum(attribute->name),
 										   0, 0);
 		if (!HeapTupleIsValid(atttuple))
 			elog(ERROR, "DefineIndex: attribute \"%s\" not found",
@@ -608,7 +608,7 @@ RemoveIndex(char *name)
  *		...
  */
 void
-ReindexIndex(const char *name, bool force /* currently unused */)
+ReindexIndex(const char *name, bool force /* currently unused */ )
 {
 	HeapTuple	tuple;
 
@@ -667,28 +667,35 @@ ReindexTable(const char *name, bool force)
  *		"ERROR" if table nonexistent.
  *		...
  */
-extern Oid MyDatabaseId;
+extern Oid	MyDatabaseId;
 void
 ReindexDatabase(const char *dbname, bool force, bool all)
 {
-	Relation	relation, relationRelation;
-	HeapTuple	usertuple, dbtuple, tuple;
-	HeapScanDesc	scan;
-	int4		user_id, db_owner;
+	Relation	relation,
+				relationRelation;
+	HeapTuple	usertuple,
+				dbtuple,
+				tuple;
+	HeapScanDesc scan;
+	int4		user_id,
+				db_owner;
 	bool		superuser;
-	Oid		db_id;
-	char		*username;
-	ScanKeyData	scankey;
-	PortalVariableMemory	pmem;
-	MemoryContext	old;
-	int		relcnt, relalc, i, oncealc = 200;
-	Oid		*relids = (Oid *) NULL;
+	Oid			db_id;
+	char	   *username;
+	ScanKeyData scankey;
+	PortalVariableMemory pmem;
+	MemoryContext old;
+	int			relcnt,
+				relalc,
+				i,
+				oncealc = 200;
+	Oid		   *relids = (Oid *) NULL;
 
 	AssertArg(dbname);
 
 	username = GetPgUserName();
 	usertuple = SearchSysCacheTuple(SHADOWNAME, PointerGetDatum(username),
-				0, 0, 0);
+									0, 0, 0);
 	if (!HeapTupleIsValid(usertuple))
 		elog(ERROR, "Current user '%s' is invalid.", username);
 	user_id = ((Form_pg_shadow) GETSTRUCT(usertuple))->usesysid;
@@ -696,7 +703,7 @@ ReindexDatabase(const char *dbname, bool force, bool all)
 
 	relation = heap_openr(DatabaseRelationName, AccessShareLock);
 	ScanKeyEntryInitialize(&scankey, 0, Anum_pg_database_datname,
-			F_NAMEEQ, NameGetDatum(dbname));
+						   F_NAMEEQ, NameGetDatum(dbname));
 	scan = heap_beginscan(relation, 0, SnapshotNow, 1, &scankey);
 	dbtuple = heap_getnext(scan, 0);
 	if (!HeapTupleIsValid(dbtuple))
diff --git a/src/backend/commands/remove.c b/src/backend/commands/remove.c
index dfcad83c3a8f8850b6a27d23367f56025b833db0..45d1d310e78d6fd61642f06d9bec9b2eda99805c 100644
--- a/src/backend/commands/remove.c
+++ b/src/backend/commands/remove.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.45 2000/01/26 05:56:13 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.46 2000/04/12 17:14:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -156,14 +156,15 @@ SingleOpOperatorRemove(Oid typeOid)
 	{
 		key[0].sk_attno = attnums[i];
 		scan = heap_beginscan(rel, 0, SnapshotNow, 1, key);
-		while (HeapTupleIsValid(tup = heap_getnext(scan, 0))) {
+		while (HeapTupleIsValid(tup = heap_getnext(scan, 0)))
+		{
 
-		  /*** This is apparently a routine not in use, but remove ***/
-		  /*** any comments anyways ***/
+			/*** This is apparently a routine not in use, but remove ***/
+			/*** any comments anyways ***/
 
-		  DeleteComments(tup->t_data->t_oid);
+			DeleteComments(tup->t_data->t_oid);
 
-		  heap_delete(rel, &tup->t_self, NULL);
+			heap_delete(rel, &tup->t_self, NULL);
 
 		}
 
diff --git a/src/backend/commands/rename.c b/src/backend/commands/rename.c
index 454b2d0d93da4d151d353be16ea8396b0d596451..6a9c92b1e63ec752226ac0bf9c7882355ceb338c 100644
--- a/src/backend/commands/rename.c
+++ b/src/backend/commands/rename.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.41 2000/01/26 05:56:13 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.42 2000/04/12 17:14:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -76,12 +76,12 @@ renameatt(char *relname,
 #endif
 
 	/*
-	 * Grab an exclusive lock on the target table, which we will NOT release
-	 * until end of transaction.
+	 * Grab an exclusive lock on the target table, which we will NOT
+	 * release until end of transaction.
 	 */
 	targetrelation = heap_openr(relname, AccessExclusiveLock);
 	relid = RelationGetRelid(targetrelation);
-	heap_close(targetrelation, NoLock);	/* close rel but keep lock! */
+	heap_close(targetrelation, NoLock); /* close rel but keep lock! */
 
 	/*
 	 * if the 'recurse' flag is set then we are supposed to rename this
@@ -160,11 +160,12 @@ renameatt(char *relname,
 	/* keep system catalog indices current */
 	{
 		Relation	irelations[Num_pg_attr_indices];
+
 		CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, irelations);
 		CatalogIndexInsert(irelations, Num_pg_attr_indices, attrelation, oldatttup);
 		CatalogCloseIndices(Num_pg_attr_indices, irelations);
 	}
-	
+
 	heap_freetuple(oldatttup);
 	heap_close(attrelation, RowExclusiveLock);
 }
@@ -194,8 +195,8 @@ renamerel(const char *oldrelname, const char *newrelname)
 			 newrelname);
 
 	/*
-	 * Grab an exclusive lock on the target table, which we will NOT release
-	 * until end of transaction.
+	 * Grab an exclusive lock on the target table, which we will NOT
+	 * release until end of transaction.
 	 */
 	targetrelation = heap_openr(oldrelname, AccessExclusiveLock);
 
@@ -211,14 +212,15 @@ renamerel(const char *oldrelname, const char *newrelname)
 	 *	they don't exist anyway.  So, no warning in that case.
 	 * ----------------
 	 */
-	if (IsTransactionBlock() && ! targetrelation->rd_myxactonly)
+	if (IsTransactionBlock() && !targetrelation->rd_myxactonly)
 		elog(NOTICE, "Caution: RENAME TABLE cannot be rolled back, so don't abort now");
 
 	/*
-	 * Flush all blocks of the relation out of the buffer pool.  We need this
-	 * because the blocks are marked with the relation's name as well as OID.
-	 * If some backend tries to write a dirty buffer with mdblindwrt after
-	 * we've renamed the physical file, we'll be in big trouble.
+	 * Flush all blocks of the relation out of the buffer pool.  We need
+	 * this because the blocks are marked with the relation's name as well
+	 * as OID. If some backend tries to write a dirty buffer with
+	 * mdblindwrt after we've renamed the physical file, we'll be in big
+	 * trouble.
 	 *
 	 * Since we hold the exclusive lock on the relation, we don't have to
 	 * worry about more blocks being read in while we finish the rename.
@@ -227,8 +229,8 @@ renamerel(const char *oldrelname, const char *newrelname)
 		elog(ERROR, "renamerel: unable to flush relation from buffer pool");
 
 	/*
-	 * Make sure smgr and lower levels close the relation's files.
-	 * (Next access to rel will reopen them.)
+	 * Make sure smgr and lower levels close the relation's files. (Next
+	 * access to rel will reopen them.)
 	 *
 	 * Note: we rely on shared cache invalidation message to make other
 	 * backends close and re-open the files.
@@ -238,14 +240,15 @@ renamerel(const char *oldrelname, const char *newrelname)
 	/*
 	 * Close rel, but keep exclusive lock!
 	 *
-	 * Note: we don't do anything about updating the relcache entry;
-	 * we assume it will be flushed by shared cache invalidate.
-	 * XXX is this good enough?  What if relation is myxactonly?
+	 * Note: we don't do anything about updating the relcache entry; we
+	 * assume it will be flushed by shared cache invalidate. XXX is this
+	 * good enough?  What if relation is myxactonly?
 	 */
 	heap_close(targetrelation, NoLock);
 
 	/*
-	 * Find relation's pg_class tuple, and make sure newrelname isn't in use.
+	 * Find relation's pg_class tuple, and make sure newrelname isn't in
+	 * use.
 	 */
 	relrelation = heap_openr(RelationRelationName, RowExclusiveLock);
 
@@ -262,8 +265,8 @@ renamerel(const char *oldrelname, const char *newrelname)
 	 * Perform physical rename of files.  If this fails, we haven't yet
 	 * done anything irreversible.
 	 *
-	 * XXX smgr.c ought to provide an interface for this; doing it
-	 * directly is bletcherous.
+	 * XXX smgr.c ought to provide an interface for this; doing it directly
+	 * is bletcherous.
 	 */
 	strcpy(oldpath, relpath(oldrelname));
 	strcpy(newpath, relpath(newrelname));
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index 23280ec5673a21602003aef43c70efc6e8107abb..0667297d7636dbfe3f86c42f1217482693d82db1 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -410,7 +410,9 @@ init_sequence(char *caller, char *name)
 
 	if (elm != (SeqTable) NULL)
 	{
-		/* We are using a seqtable entry left over from a previous xact;
+
+		/*
+		 * We are using a seqtable entry left over from a previous xact;
 		 * must check for relid change.
 		 */
 		elm->rel = seqrel;
@@ -424,7 +426,9 @@ init_sequence(char *caller, char *name)
 	}
 	else
 	{
-		/* Time to make a new seqtable entry.  These entries live as long
+
+		/*
+		 * Time to make a new seqtable entry.  These entries live as long
 		 * as the backend does, so we use plain malloc for them.
 		 */
 		elm = (SeqTable) malloc(sizeof(SeqTableData));
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index 78df4fd5e8ebdb7711817c1c5d6f0ad2a6687c09..9961ce6ff15085a4e99f32459e5dd1548e079e5f 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.62 2000/02/29 12:28:24 wieck Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.63 2000/04/12 17:14:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -89,7 +89,7 @@ CreateTrigger(CreateTrigStmt *stmt)
 			rel = heap_openr(stmt->constrrelname, NoLock);
 			if (rel == NULL)
 				elog(ERROR, "table \"%s\" does not exist",
-							stmt->constrrelname);
+					 stmt->constrrelname);
 			constrrelid = rel->rd_id;
 			heap_close(rel, NoLock);
 		}
@@ -182,12 +182,12 @@ CreateTrigger(CreateTrigStmt *stmt)
 	values[Anum_pg_trigger_tgfoid - 1] = ObjectIdGetDatum(tuple->t_data->t_oid);
 	values[Anum_pg_trigger_tgtype - 1] = Int16GetDatum(tgtype);
 
-	values[Anum_pg_trigger_tgenabled - 1]		= true;
-	values[Anum_pg_trigger_tgisconstraint - 1]	= stmt->isconstraint;
-	values[Anum_pg_trigger_tgconstrname - 1]	= PointerGetDatum(constrname);;
-	values[Anum_pg_trigger_tgconstrrelid - 1]	= constrrelid;
-	values[Anum_pg_trigger_tgdeferrable - 1]	= stmt->deferrable;
-	values[Anum_pg_trigger_tginitdeferred - 1]	= stmt->initdeferred;
+	values[Anum_pg_trigger_tgenabled - 1] = true;
+	values[Anum_pg_trigger_tgisconstraint - 1] = stmt->isconstraint;
+	values[Anum_pg_trigger_tgconstrname - 1] = PointerGetDatum(constrname);;
+	values[Anum_pg_trigger_tgconstrrelid - 1] = constrrelid;
+	values[Anum_pg_trigger_tgdeferrable - 1] = stmt->deferrable;
+	values[Anum_pg_trigger_tginitdeferred - 1] = stmt->initdeferred;
 
 	if (stmt->args)
 	{
@@ -261,10 +261,11 @@ CreateTrigger(CreateTrigStmt *stmt)
 	CatalogCloseIndices(Num_pg_class_indices, ridescs);
 	heap_freetuple(tuple);
 	heap_close(pgrel, RowExclusiveLock);
+
 	/*
 	 * We used to try to update the rel's relcache entry here, but that's
-	 * fairly pointless since it will happen as a byproduct of the upcoming
-	 * CommandCounterIncrement...
+	 * fairly pointless since it will happen as a byproduct of the
+	 * upcoming CommandCounterIncrement...
 	 */
 	/* Keep lock on target rel until end of xact */
 	heap_close(rel, NoLock);
@@ -301,12 +302,12 @@ DropTrigger(DropTrigStmt *stmt)
 		if (namestrcmp(&(pg_trigger->tgname), stmt->trigname) == 0)
 		{
 
-		  /*** Delete any comments associated with this trigger ***/
+			/*** Delete any comments associated with this trigger ***/
 
-		  DeleteComments(tuple->t_data->t_oid);
+			DeleteComments(tuple->t_data->t_oid);
 
-		  heap_delete(tgrel, &tuple->t_self, NULL);
-		  tgfound++;
+			heap_delete(tgrel, &tuple->t_self, NULL);
+			tgfound++;
 
 		}
 		else
@@ -337,10 +338,11 @@ DropTrigger(DropTrigStmt *stmt)
 	CatalogCloseIndices(Num_pg_class_indices, ridescs);
 	heap_freetuple(tuple);
 	heap_close(pgrel, RowExclusiveLock);
+
 	/*
 	 * We used to try to update the rel's relcache entry here, but that's
-	 * fairly pointless since it will happen as a byproduct of the upcoming
-	 * CommandCounterIncrement...
+	 * fairly pointless since it will happen as a byproduct of the
+	 * upcoming CommandCounterIncrement...
 	 */
 	/* Keep lock on target rel until end of xact */
 	heap_close(rel, NoLock);
@@ -360,13 +362,14 @@ RelationRemoveTriggers(Relation rel)
 
 	tgscan = heap_beginscan(tgrel, 0, SnapshotNow, 1, &key);
 
-	while (HeapTupleIsValid(tup = heap_getnext(tgscan, 0))) {
+	while (HeapTupleIsValid(tup = heap_getnext(tgscan, 0)))
+	{
 
-	  /*** Delete any comments associated with this trigger ***/
+		/*** Delete any comments associated with this trigger ***/
 
-	  DeleteComments(tup->t_data->t_oid);
+		DeleteComments(tup->t_data->t_oid);
 
-	  heap_delete(tgrel, &tup->t_self, NULL);
+		heap_delete(tgrel, &tup->t_self, NULL);
 
 	}
 
@@ -385,14 +388,14 @@ RelationRemoveTriggers(Relation rel)
 	 * ----------
 	 */
 	ScanKeyEntryInitialize(&key, 0, Anum_pg_trigger_tgconstrrelid,
-							F_OIDEQ, RelationGetRelid(rel));
+						   F_OIDEQ, RelationGetRelid(rel));
 
 	tgscan = heap_beginscan(tgrel, 0, SnapshotNow, 1, &key);
 	while (HeapTupleIsValid(tup = heap_getnext(tgscan, 0)))
 	{
-		Form_pg_trigger	pg_trigger;
-		Relation		refrel;
-		DropTrigStmt	stmt;
+		Form_pg_trigger pg_trigger;
+		Relation	refrel;
+		DropTrigStmt stmt;
 
 		pg_trigger = (Form_pg_trigger) GETSTRUCT(tup);
 
@@ -436,8 +439,8 @@ RelationBuildTriggers(Relation relation)
 	Relation	irel = (Relation) NULL;
 	ScanKeyData skey;
 	HeapTupleData tuple;
-	IndexScanDesc	sd = (IndexScanDesc) NULL;
-	HeapScanDesc	tgscan = (HeapScanDesc) NULL;
+	IndexScanDesc sd = (IndexScanDesc) NULL;
+	HeapScanDesc tgscan = (HeapScanDesc) NULL;
 	HeapTuple	htup;
 	RetrieveIndexResult indexRes;
 	Buffer		buffer;
@@ -684,13 +687,13 @@ FreeTriggerDesc(TriggerDesc *trigdesc)
 bool
 equalTriggerDescs(TriggerDesc *trigdesc1, TriggerDesc *trigdesc2)
 {
-	int		i,
-			j;
+	int			i,
+				j;
 
 	/*
-	 * We need not examine the "index" data, just the trigger array itself;
-	 * if we have the same triggers with the same types, the derived index
-	 * data should match.
+	 * We need not examine the "index" data, just the trigger array
+	 * itself; if we have the same triggers with the same types, the
+	 * derived index data should match.
 	 *
 	 * XXX It seems possible that the same triggers could appear in different
 	 * orders in the two trigger arrays; do we need to handle that?
@@ -703,8 +706,8 @@ equalTriggerDescs(TriggerDesc *trigdesc1, TriggerDesc *trigdesc2)
 			return false;
 		for (i = 0; i < trigdesc1->numtriggers; i++)
 		{
-			Trigger	   *trig1 = trigdesc1->triggers + i;
-			Trigger	   *trig2 = NULL;
+			Trigger    *trig1 = trigdesc1->triggers + i;
+			Trigger    *trig2 = NULL;
 
 			/*
 			 * We can't assume that the triggers are always read from
@@ -1014,31 +1017,31 @@ ltrmark:;
  * end.
  * ----------
  */
-static GlobalMemory		deftrig_gcxt = NULL;
-static GlobalMemory		deftrig_cxt = NULL;
+static GlobalMemory deftrig_gcxt = NULL;
+static GlobalMemory deftrig_cxt = NULL;
 
 /* ----------
  * Global data that tells which triggers are actually in
  * state IMMEDIATE or DEFERRED.
  * ----------
  */
-static bool				deftrig_dfl_all_isset = false;
-static bool				deftrig_dfl_all_isdeferred = false;
-static List			   *deftrig_dfl_trigstates = NIL;
+static bool deftrig_dfl_all_isset = false;
+static bool deftrig_dfl_all_isdeferred = false;
+static List *deftrig_dfl_trigstates = NIL;
 
-static bool				deftrig_all_isset;
-static bool				deftrig_all_isdeferred;
-static List			   *deftrig_trigstates;
+static bool deftrig_all_isset;
+static bool deftrig_all_isdeferred;
+static List *deftrig_trigstates;
 
 /* ----------
  * The list of events during the entire transaction.
  *
  * XXX This must finally be held in a file because of the huge
- *     number of events that could occur in the real world.
+ *	   number of events that could occur in the real world.
  * ----------
  */
-static int				deftrig_n_events;
-static List			   *deftrig_events;
+static int	deftrig_n_events;
+static List *deftrig_events;
 
 
 /* ----------
@@ -1051,9 +1054,9 @@ static List			   *deftrig_events;
 static bool
 deferredTriggerCheckState(Oid tgoid, int32 itemstate)
 {
-	MemoryContext			oldcxt;
-	List				   *sl;
-	DeferredTriggerStatus	trigstate;
+	MemoryContext oldcxt;
+	List	   *sl;
+	DeferredTriggerStatus trigstate;
 
 	/* ----------
 	 * Not deferrable triggers (i.e. normal AFTER ROW triggers
@@ -1068,7 +1071,7 @@ deferredTriggerCheckState(Oid tgoid, int32 itemstate)
 	 * Lookup if we know an individual state for this trigger
 	 * ----------
 	 */
-	foreach (sl, deftrig_trigstates)
+	foreach(sl, deftrig_trigstates)
 	{
 		trigstate = (DeferredTriggerStatus) lfirst(sl);
 		if (trigstate->dts_tgoid == tgoid)
@@ -1092,10 +1095,10 @@ deferredTriggerCheckState(Oid tgoid, int32 itemstate)
 	oldcxt = MemoryContextSwitchTo((MemoryContext) deftrig_cxt);
 
 	trigstate = (DeferredTriggerStatus)
-			palloc(sizeof(DeferredTriggerStatusData));
-	trigstate->dts_tgoid		= tgoid;
-	trigstate->dts_tgisdeferred	=
-			((itemstate & TRIGGER_DEFERRED_INITDEFERRED) != 0);
+		palloc(sizeof(DeferredTriggerStatusData));
+	trigstate->dts_tgoid = tgoid;
+	trigstate->dts_tgisdeferred =
+		((itemstate & TRIGGER_DEFERRED_INITDEFERRED) != 0);
 	deftrig_trigstates = lappend(deftrig_trigstates, trigstate);
 
 	MemoryContextSwitchTo(oldcxt);
@@ -1130,8 +1133,8 @@ deferredTriggerAddEvent(DeferredTriggerEvent event)
 static DeferredTriggerEvent
 deferredTriggerGetPreviousEvent(Oid relid, ItemPointer ctid)
 {
-	DeferredTriggerEvent	previous;
-	int						n;
+	DeferredTriggerEvent previous;
+	int			n;
 
 	for (n = deftrig_n_events - 1; n >= 0; n--)
 	{
@@ -1143,15 +1146,15 @@ deferredTriggerGetPreviousEvent(Oid relid, ItemPointer ctid)
 			continue;
 
 		if (ItemPointerGetBlockNumber(ctid) ==
-					ItemPointerGetBlockNumber(&(previous->dte_newctid)) &&
-					ItemPointerGetOffsetNumber(ctid) ==
-					ItemPointerGetOffsetNumber(&(previous->dte_newctid)))
+			ItemPointerGetBlockNumber(&(previous->dte_newctid)) &&
+			ItemPointerGetOffsetNumber(ctid) ==
+			ItemPointerGetOffsetNumber(&(previous->dte_newctid)))
 			return previous;
 	}
 
 	elog(ERROR,
-		"deferredTriggerGetPreviousEvent(): event for tuple %s not found",
-		tidout(ctid));
+	   "deferredTriggerGetPreviousEvent(): event for tuple %s not found",
+		 tidout(ctid));
 	return NULL;
 }
 
@@ -1166,13 +1169,13 @@ deferredTriggerGetPreviousEvent(Oid relid, ItemPointer ctid)
 static void
 deferredTriggerExecute(DeferredTriggerEvent event, int itemno)
 {
-	Relation		rel;
-	TriggerData		SaveTriggerData;
-	HeapTupleData	oldtuple;
-	HeapTupleData	newtuple;
-	HeapTuple		rettuple;
-	Buffer			oldbuffer;
-	Buffer			newbuffer;
+	Relation	rel;
+	TriggerData SaveTriggerData;
+	HeapTupleData oldtuple;
+	HeapTupleData newtuple;
+	HeapTuple	rettuple;
+	Buffer		oldbuffer;
+	Buffer		newbuffer;
 
 	/* ----------
 	 * Open the heap and fetch the required OLD and NEW tuples.
@@ -1200,31 +1203,31 @@ deferredTriggerExecute(DeferredTriggerEvent event, int itemno)
 	 * Setup the trigger information
 	 * ----------
 	 */
-	SaveTriggerData.tg_event    = (event->dte_event & TRIGGER_EVENT_OPMASK) |
-														TRIGGER_EVENT_ROW;
+	SaveTriggerData.tg_event = (event->dte_event & TRIGGER_EVENT_OPMASK) |
+		TRIGGER_EVENT_ROW;
 	SaveTriggerData.tg_relation = rel;
 
 	switch (event->dte_event & TRIGGER_EVENT_OPMASK)
 	{
 		case TRIGGER_EVENT_INSERT:
 			SaveTriggerData.tg_trigtuple = &newtuple;
-			SaveTriggerData.tg_newtuple  = NULL;
-			SaveTriggerData.tg_trigger   =
-					rel->trigdesc->tg_after_row[TRIGGER_EVENT_INSERT][itemno];
+			SaveTriggerData.tg_newtuple = NULL;
+			SaveTriggerData.tg_trigger =
+				rel->trigdesc->tg_after_row[TRIGGER_EVENT_INSERT][itemno];
 			break;
 
 		case TRIGGER_EVENT_UPDATE:
 			SaveTriggerData.tg_trigtuple = &oldtuple;
-			SaveTriggerData.tg_newtuple  = &newtuple;
-			SaveTriggerData.tg_trigger   =
-					rel->trigdesc->tg_after_row[TRIGGER_EVENT_UPDATE][itemno];
+			SaveTriggerData.tg_newtuple = &newtuple;
+			SaveTriggerData.tg_trigger =
+				rel->trigdesc->tg_after_row[TRIGGER_EVENT_UPDATE][itemno];
 			break;
 
 		case TRIGGER_EVENT_DELETE:
 			SaveTriggerData.tg_trigtuple = &oldtuple;
-			SaveTriggerData.tg_newtuple  = NULL;
-			SaveTriggerData.tg_trigger   =
-					rel->trigdesc->tg_after_row[TRIGGER_EVENT_DELETE][itemno];
+			SaveTriggerData.tg_newtuple = NULL;
+			SaveTriggerData.tg_trigger =
+				rel->trigdesc->tg_after_row[TRIGGER_EVENT_DELETE][itemno];
 			break;
 	}
 
@@ -1271,11 +1274,11 @@ deferredTriggerExecute(DeferredTriggerEvent event, int itemno)
 static void
 deferredTriggerInvokeEvents(bool immediate_only)
 {
-	List					*el;
-	DeferredTriggerEvent	event;
-	int						still_deferred_ones;
-	int						eventno = -1;
-	int						i;
+	List	   *el;
+	DeferredTriggerEvent event;
+	int			still_deferred_ones;
+	int			eventno = -1;
+	int			i;
 
 	/* ----------
 	 * For now we process all events - to speedup transaction blocks
@@ -1286,7 +1289,7 @@ deferredTriggerInvokeEvents(bool immediate_only)
 	 * SET CONSTRAINTS ... command finishes and calls EndQuery.
 	 * ----------
 	 */
-	foreach (el, deftrig_events)
+	foreach(el, deftrig_events)
 	{
 		eventno++;
 
@@ -1315,8 +1318,8 @@ deferredTriggerInvokeEvents(bool immediate_only)
 			 * ----------
 			 */
 			if (immediate_only && deferredTriggerCheckState(
-								event->dte_item[i].dti_tgoid,
-								event->dte_item[i].dti_state))
+											event->dte_item[i].dti_tgoid,
+										   event->dte_item[i].dti_state))
 			{
 				still_deferred_ones = true;
 				continue;
@@ -1367,34 +1370,34 @@ DeferredTriggerInit(void)
 void
 DeferredTriggerBeginXact(void)
 {
-	MemoryContext			oldcxt;
-	List					*l;
-	DeferredTriggerStatus	dflstat;
-	DeferredTriggerStatus	stat;
+	MemoryContext oldcxt;
+	List	   *l;
+	DeferredTriggerStatus dflstat;
+	DeferredTriggerStatus stat;
 
 	if (deftrig_cxt != NULL)
 		elog(FATAL,
-			"DeferredTriggerBeginXact() called while inside transaction");
+		   "DeferredTriggerBeginXact() called while inside transaction");
 
 	/* ----------
 	 * Create the per transaction memory context and copy all states
 	 * from the per session context to here.
 	 * ----------
 	 */
-	deftrig_cxt				= CreateGlobalMemory("DeferredTriggerXact");
-	oldcxt = MemoryContextSwitchTo((MemoryContext)deftrig_cxt);
+	deftrig_cxt = CreateGlobalMemory("DeferredTriggerXact");
+	oldcxt = MemoryContextSwitchTo((MemoryContext) deftrig_cxt);
 
-	deftrig_all_isset		= deftrig_dfl_all_isset;
-	deftrig_all_isdeferred	= deftrig_dfl_all_isdeferred;
+	deftrig_all_isset = deftrig_dfl_all_isset;
+	deftrig_all_isdeferred = deftrig_dfl_all_isdeferred;
 
-	deftrig_trigstates		= NIL;
-	foreach (l, deftrig_dfl_trigstates)
+	deftrig_trigstates = NIL;
+	foreach(l, deftrig_dfl_trigstates)
 	{
 		dflstat = (DeferredTriggerStatus) lfirst(l);
-		stat    = (DeferredTriggerStatus)
-								palloc(sizeof(DeferredTriggerStatusData));
+		stat = (DeferredTriggerStatus)
+			palloc(sizeof(DeferredTriggerStatusData));
 
-		stat->dts_tgoid        = dflstat->dts_tgoid;
+		stat->dts_tgoid = dflstat->dts_tgoid;
 		stat->dts_tgisdeferred = dflstat->dts_tgisdeferred;
 
 		deftrig_trigstates = lappend(deftrig_trigstates, stat);
@@ -1402,8 +1405,8 @@ DeferredTriggerBeginXact(void)
 
 	MemoryContextSwitchTo(oldcxt);
 
-	deftrig_n_events	= 0;
-	deftrig_events		= NIL;
+	deftrig_n_events = 0;
+	deftrig_events = NIL;
 }
 
 
@@ -1484,22 +1487,23 @@ DeferredTriggerAbortXact(void)
 void
 DeferredTriggerSetState(ConstraintsSetStmt *stmt)
 {
-	Relation				tgrel;
-	Relation				irel = (Relation) NULL;
-	List					*l;
-	List					*ls;
-	List					*lnext;
-	List					*loid = NIL;
-	MemoryContext			oldcxt;
-	bool					found;
-	DeferredTriggerStatus	state;
-	bool			hasindex;
+	Relation	tgrel;
+	Relation	irel = (Relation) NULL;
+	List	   *l;
+	List	   *ls;
+	List	   *lnext;
+	List	   *loid = NIL;
+	MemoryContext oldcxt;
+	bool		found;
+	DeferredTriggerStatus state;
+	bool		hasindex;
 
 	/* ----------
 	 * Handle SET CONSTRAINTS ALL ...
 	 * ----------
 	 */
-	if (stmt->constraints == NIL) {
+	if (stmt->constraints == NIL)
+	{
 		if (!IsTransactionBlock())
 		{
 			/* ----------
@@ -1527,13 +1531,15 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
 			 * Set the session ALL state to known.
 			 * ----------
 			 */
-			deftrig_dfl_all_isset      = true;
+			deftrig_dfl_all_isset = true;
 			deftrig_dfl_all_isdeferred = stmt->deferred;
 
 			MemoryContextSwitchTo(oldcxt);
 
 			return;
-		} else {
+		}
+		else
+		{
 			/* ----------
 			 * ... inside of a transaction block
 			 * ----------
@@ -1559,7 +1565,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
 			 * Set the per transaction ALL state to known.
 			 * ----------
 			 */
-			deftrig_all_isset      = true;
+			deftrig_all_isset = true;
 			deftrig_all_isdeferred = stmt->deferred;
 
 			MemoryContextSwitchTo(oldcxt);
@@ -1578,23 +1584,23 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
 	if (hasindex)
 		irel = index_openr(TriggerConstrNameIndex);
 
-	foreach (l, stmt->constraints)
+	foreach(l, stmt->constraints)
 	{
-		ScanKeyData			skey;
-		HeapTupleData		tuple;
-		IndexScanDesc		sd = (IndexScanDesc) NULL;
-		HeapScanDesc		tgscan = (HeapScanDesc) NULL;
-		HeapTuple		htup;
-		RetrieveIndexResult	indexRes;
-		Buffer				buffer;
-		Form_pg_trigger		pg_trigger;
-		Oid					constr_oid;
+		ScanKeyData skey;
+		HeapTupleData tuple;
+		IndexScanDesc sd = (IndexScanDesc) NULL;
+		HeapScanDesc tgscan = (HeapScanDesc) NULL;
+		HeapTuple	htup;
+		RetrieveIndexResult indexRes;
+		Buffer		buffer;
+		Form_pg_trigger pg_trigger;
+		Oid			constr_oid;
 
 		/* ----------
 		 * Check that only named constraints are set explicitly
 		 * ----------
 		 */
-		if (strcmp((char *)lfirst(l), "") == 0)
+		if (strcmp((char *) lfirst(l), "") == 0)
 			elog(ERROR, "unnamed constraints cannot be set explicitly");
 
 		/* ----------
@@ -1605,7 +1611,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
 							   (bits16) 0x0,
 							   (AttrNumber) 1,
 							   (RegProcedure) F_NAMEEQ,
-							   PointerGetDatum((char *)lfirst(l)));
+							   PointerGetDatum((char *) lfirst(l)));
 
 		if (hasindex)
 			sd = index_beginscan(irel, false, 1, &skey);
@@ -1629,9 +1635,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
 				heap_fetch(tgrel, SnapshotNow, &tuple, &buffer);
 				pfree(indexRes);
 				if (!tuple.t_data)
-				{
 					continue;
-				}
 				htup = &tuple;
 			}
 			else
@@ -1649,13 +1653,13 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
 			 */
 			pg_trigger = (Form_pg_trigger) GETSTRUCT(htup);
 			if (stmt->deferred && !pg_trigger->tgdeferrable &&
-					pg_trigger->tgfoid != F_RI_FKEY_RESTRICT_UPD &&
-					pg_trigger->tgfoid != F_RI_FKEY_RESTRICT_DEL)
+				pg_trigger->tgfoid != F_RI_FKEY_RESTRICT_UPD &&
+				pg_trigger->tgfoid != F_RI_FKEY_RESTRICT_DEL)
 				elog(ERROR, "Constraint '%s' is not deferrable",
-									(char *)lfirst(l));
+					 (char *) lfirst(l));
 
 			constr_oid = htup->t_data->t_oid;
-			loid = lappend(loid, (Node *)constr_oid);
+			loid = lappend(loid, (Node *) constr_oid);
 			found = true;
 
 			if (hasindex)
@@ -1667,11 +1671,11 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
 		 * ----------
 		 */
 		if (!found)
-			elog(ERROR, "Constraint '%s' does not exist", (char *)lfirst(l));
+			elog(ERROR, "Constraint '%s' does not exist", (char *) lfirst(l));
 
 		if (hasindex)
 			index_endscan(sd);
-		else	
+		else
 			heap_endscan(tgscan);
 	}
 	if (hasindex)
@@ -1688,10 +1692,10 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
 		 */
 		oldcxt = MemoryContextSwitchTo((MemoryContext) deftrig_gcxt);
 
-		foreach (l, loid)
+		foreach(l, loid)
 		{
 			found = false;
-			foreach (ls, deftrig_dfl_trigstates)
+			foreach(ls, deftrig_dfl_trigstates)
 			{
 				state = (DeferredTriggerStatus) lfirst(ls);
 				if (state->dts_tgoid == (Oid) lfirst(l))
@@ -1704,19 +1708,21 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
 			if (!found)
 			{
 				state = (DeferredTriggerStatus)
-									palloc(sizeof(DeferredTriggerStatusData));
-				state->dts_tgoid        = (Oid) lfirst(l);
+					palloc(sizeof(DeferredTriggerStatusData));
+				state->dts_tgoid = (Oid) lfirst(l);
 				state->dts_tgisdeferred = stmt->deferred;
 
 				deftrig_dfl_trigstates =
-									lappend(deftrig_dfl_trigstates, state);
+					lappend(deftrig_dfl_trigstates, state);
 			}
 		}
 
 		MemoryContextSwitchTo(oldcxt);
 
 		return;
-	} else {
+	}
+	else
+	{
 		/* ----------
 		 * Inside of a transaction block set the trigger
 		 * states of individual triggers on transaction level.
@@ -1724,10 +1730,10 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
 		 */
 		oldcxt = MemoryContextSwitchTo((MemoryContext) deftrig_cxt);
 
-		foreach (l, loid)
+		foreach(l, loid)
 		{
 			found = false;
-			foreach (ls, deftrig_trigstates)
+			foreach(ls, deftrig_trigstates)
 			{
 				state = (DeferredTriggerStatus) lfirst(ls);
 				if (state->dts_tgoid == (Oid) lfirst(l))
@@ -1740,12 +1746,12 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
 			if (!found)
 			{
 				state = (DeferredTriggerStatus)
-									palloc(sizeof(DeferredTriggerStatusData));
-				state->dts_tgoid        = (Oid) lfirst(l);
+					palloc(sizeof(DeferredTriggerStatusData));
+				state->dts_tgoid = (Oid) lfirst(l);
 				state->dts_tgisdeferred = stmt->deferred;
 
 				deftrig_trigstates =
-									lappend(deftrig_trigstates, state);
+					lappend(deftrig_trigstates, state);
 			}
 		}
 
@@ -1764,33 +1770,33 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
  */
 void
 DeferredTriggerSaveEvent(Relation rel, int event,
-					HeapTuple oldtup, HeapTuple newtup)
+						 HeapTuple oldtup, HeapTuple newtup)
 {
-	MemoryContext			oldcxt;
-	DeferredTriggerEvent	new_event;
-	DeferredTriggerEvent	prev_event;
-	int						new_size;
-	int						i;
-	int						ntriggers;
-	Trigger				  **triggers;
-	ItemPointerData			oldctid;
-	ItemPointerData			newctid;
-	TriggerData				SaveTriggerData;
+	MemoryContext oldcxt;
+	DeferredTriggerEvent new_event;
+	DeferredTriggerEvent prev_event;
+	int			new_size;
+	int			i;
+	int			ntriggers;
+	Trigger   **triggers;
+	ItemPointerData oldctid;
+	ItemPointerData newctid;
+	TriggerData SaveTriggerData;
 
 	if (deftrig_cxt == NULL)
 		elog(ERROR,
-			"DeferredTriggerSaveEvent() called outside of transaction");
+			 "DeferredTriggerSaveEvent() called outside of transaction");
 
 	/* ----------
 	 * Check if we're interested in this row at all
 	 * ----------
 	 */
 	if (rel->trigdesc->n_after_row[TRIGGER_EVENT_INSERT] == 0 &&
-				rel->trigdesc->n_after_row[TRIGGER_EVENT_UPDATE] == 0 &&
-				rel->trigdesc->n_after_row[TRIGGER_EVENT_DELETE] == 0 &&
-				rel->trigdesc->n_before_row[TRIGGER_EVENT_INSERT] == 0 &&
-				rel->trigdesc->n_before_row[TRIGGER_EVENT_UPDATE] == 0 &&
-				rel->trigdesc->n_before_row[TRIGGER_EVENT_DELETE] == 0)
+		rel->trigdesc->n_after_row[TRIGGER_EVENT_UPDATE] == 0 &&
+		rel->trigdesc->n_after_row[TRIGGER_EVENT_DELETE] == 0 &&
+		rel->trigdesc->n_before_row[TRIGGER_EVENT_INSERT] == 0 &&
+		rel->trigdesc->n_before_row[TRIGGER_EVENT_UPDATE] == 0 &&
+		rel->trigdesc->n_before_row[TRIGGER_EVENT_DELETE] == 0)
 		return;
 
 	/* ----------
@@ -1813,14 +1819,14 @@ DeferredTriggerSaveEvent(Relation rel, int event,
 	oldcxt = MemoryContextSwitchTo((MemoryContext) deftrig_cxt);
 
 	ntriggers = rel->trigdesc->n_after_row[event];
-	triggers  = rel->trigdesc->tg_after_row[event];
+	triggers = rel->trigdesc->tg_after_row[event];
 
-	new_size  = sizeof(DeferredTriggerEventData) +
-				ntriggers * sizeof(DeferredTriggerEventItem);
+	new_size = sizeof(DeferredTriggerEventData) +
+		ntriggers * sizeof(DeferredTriggerEventItem);
 
 	new_event = (DeferredTriggerEvent) palloc(new_size);
-	new_event->dte_event	= event & TRIGGER_EVENT_OPMASK;
-	new_event->dte_relid	= rel->rd_id;
+	new_event->dte_event = event & TRIGGER_EVENT_OPMASK;
+	new_event->dte_relid = rel->rd_id;
 	ItemPointerCopy(&oldctid, &(new_event->dte_oldctid));
 	ItemPointerCopy(&newctid, &(new_event->dte_newctid));
 	new_event->dte_n_items = ntriggers;
@@ -1830,11 +1836,11 @@ DeferredTriggerSaveEvent(Relation rel, int event,
 		new_event->dte_item[i].dti_tgoid = triggers[i]->tgoid;
 		new_event->dte_item[i].dti_state =
 			((triggers[i]->tgdeferrable) ?
-						TRIGGER_DEFERRED_DEFERRABLE : 0)	|
+			 TRIGGER_DEFERRED_DEFERRABLE : 0) |
 			((triggers[i]->tginitdeferred) ?
-						TRIGGER_DEFERRED_INITDEFERRED : 0)	|
+			 TRIGGER_DEFERRED_INITDEFERRED : 0) |
 			((rel->trigdesc->n_before_row[event] > 0) ?
-						TRIGGER_DEFERRED_HAS_BEFORE : 0);
+			 TRIGGER_DEFERRED_HAS_BEFORE : 0);
 	}
 	MemoryContextSwitchTo(oldcxt);
 
@@ -1864,8 +1870,8 @@ DeferredTriggerSaveEvent(Relation rel, int event,
 			 */
 			for (i = 0; i < ntriggers; i++)
 			{
-				bool	is_ri_trigger;
-				bool	key_unchanged;
+				bool		is_ri_trigger;
+				bool		key_unchanged;
 
 				/* ----------
 				 * We are interested in RI_FKEY triggers only.
@@ -1888,11 +1894,11 @@ DeferredTriggerSaveEvent(Relation rel, int event,
 				if (!is_ri_trigger)
 					continue;
 
-				SaveTriggerData.tg_event     = TRIGGER_EVENT_UPDATE;
-				SaveTriggerData.tg_relation  = rel;
+				SaveTriggerData.tg_event = TRIGGER_EVENT_UPDATE;
+				SaveTriggerData.tg_relation = rel;
 				SaveTriggerData.tg_trigtuple = oldtup;
-				SaveTriggerData.tg_newtuple  = newtup;
-				SaveTriggerData.tg_trigger   = triggers[i];
+				SaveTriggerData.tg_newtuple = newtup;
+				SaveTriggerData.tg_trigger = triggers[i];
 
 				CurrentTriggerData = &SaveTriggerData;
 				key_unchanged = RI_FKey_keyequal_upd();
@@ -1911,7 +1917,7 @@ DeferredTriggerSaveEvent(Relation rel, int event,
 					if (prev_event)
 					{
 						if (prev_event->dte_event &
-									TRIGGER_DEFERRED_ROW_INSERTED)
+							TRIGGER_DEFERRED_ROW_INSERTED)
 						{
 							/* ----------
 							 * This is a row inserted during our transaction.
@@ -1919,11 +1925,11 @@ DeferredTriggerSaveEvent(Relation rel, int event,
 							 * ----------
 							 */
 							new_event->dte_event |=
-											TRIGGER_DEFERRED_ROW_INSERTED;
+								TRIGGER_DEFERRED_ROW_INSERTED;
 							new_event->dte_event |=
-											TRIGGER_DEFERRED_KEY_CHANGED;
+								TRIGGER_DEFERRED_KEY_CHANGED;
 							new_event->dte_item[i].dti_state |=
-											TRIGGER_DEFERRED_KEY_CHANGED;
+								TRIGGER_DEFERRED_KEY_CHANGED;
 						}
 						else
 						{
@@ -1934,12 +1940,12 @@ DeferredTriggerSaveEvent(Relation rel, int event,
 							 * ----------
 							 */
 							if (prev_event->dte_item[i].dti_state &
-											TRIGGER_DEFERRED_KEY_CHANGED)
+								TRIGGER_DEFERRED_KEY_CHANGED)
 							{
 								new_event->dte_item[i].dti_state |=
-											TRIGGER_DEFERRED_KEY_CHANGED;
+									TRIGGER_DEFERRED_KEY_CHANGED;
 								new_event->dte_event |=
-											TRIGGER_DEFERRED_KEY_CHANGED;
+									TRIGGER_DEFERRED_KEY_CHANGED;
 							}
 						}
 					}
@@ -1954,16 +1960,16 @@ DeferredTriggerSaveEvent(Relation rel, int event,
 					if (prev_event)
 					{
 						if (prev_event->dte_event &
-											TRIGGER_DEFERRED_ROW_INSERTED)
+							TRIGGER_DEFERRED_ROW_INSERTED)
 							elog(ERROR, "triggered data change violation "
-									"on relation \"%s\"",
-									nameout(&(rel->rd_rel->relname)));
+								 "on relation \"%s\"",
+								 nameout(&(rel->rd_rel->relname)));
 
 						if (prev_event->dte_item[i].dti_state &
-											TRIGGER_DEFERRED_KEY_CHANGED)
+							TRIGGER_DEFERRED_KEY_CHANGED)
 							elog(ERROR, "triggered data change violation "
-									"on relation \"%s\"",
-									nameout(&(rel->rd_rel->relname)));
+								 "on relation \"%s\"",
+								 nameout(&(rel->rd_rel->relname)));
 					}
 
 					/* ----------
@@ -1972,7 +1978,7 @@ DeferredTriggerSaveEvent(Relation rel, int event,
 					 * ----------
 					 */
 					new_event->dte_item[i].dti_state |=
-											TRIGGER_DEFERRED_KEY_CHANGED;
+						TRIGGER_DEFERRED_KEY_CHANGED;
 					new_event->dte_event |= TRIGGER_DEFERRED_KEY_CHANGED;
 				}
 			}
@@ -1996,8 +2002,8 @@ DeferredTriggerSaveEvent(Relation rel, int event,
 			prev_event = deferredTriggerGetPreviousEvent(rel->rd_id, &oldctid);
 			if (prev_event->dte_event & TRIGGER_DEFERRED_KEY_CHANGED)
 				elog(ERROR, "triggered data change violation "
-						"on relation \"%s\"",
-						nameout(&(rel->rd_rel->relname)));
+					 "on relation \"%s\"",
+					 nameout(&(rel->rd_rel->relname)));
 
 			break;
 	}
@@ -2012,5 +2018,3 @@ DeferredTriggerSaveEvent(Relation rel, int event,
 
 	return;
 }
-
-
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index 63676e14e48906c765333127f69b70a5f2477a5d..fe24e15b1fd1ca3b394ea856604716806308760d 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: user.c,v 1.51 2000/03/15 07:02:56 tgl Exp $
+ * $Id: user.c,v 1.52 2000/04/12 17:14:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -55,11 +55,11 @@ write_password_file(Relation rel)
 	char	   *filename,
 			   *tempname;
 	int			bufsize;
-    FILE       *fp;
-    mode_t      oumask;
-    HeapScanDesc scan;
-    HeapTuple   tuple;
-	TupleDesc dsc = RelationGetDescr(rel);
+	FILE	   *fp;
+	mode_t		oumask;
+	HeapScanDesc scan;
+	HeapTuple	tuple;
+	TupleDesc	dsc = RelationGetDescr(rel);
 
 	/*
 	 * Create a temporary filename to be renamed later.  This prevents the
@@ -71,74 +71,85 @@ write_password_file(Relation rel)
 	tempname = (char *) palloc(bufsize);
 
 	snprintf(tempname, bufsize, "%s.%d", filename, MyProcPid);
-    oumask = umask((mode_t) 077);
-    fp = AllocateFile(tempname, "w");
-    umask(oumask);
-    if (fp == NULL)
-        elog(ERROR, "%s: %s", tempname, strerror(errno));
-
-    /* read table */
-    scan = heap_beginscan(rel, false, SnapshotSelf, 0, NULL);
-    while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
-    {
-        Datum		datum_n, datum_p, datum_v;
-        bool        null_n, null_p, null_v;
+	oumask = umask((mode_t) 077);
+	fp = AllocateFile(tempname, "w");
+	umask(oumask);
+	if (fp == NULL)
+		elog(ERROR, "%s: %s", tempname, strerror(errno));
+
+	/* read table */
+	scan = heap_beginscan(rel, false, SnapshotSelf, 0, NULL);
+	while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
+	{
+		Datum		datum_n,
+					datum_p,
+					datum_v;
+		bool		null_n,
+					null_p,
+					null_v;
 
 		datum_n = heap_getattr(tuple, Anum_pg_shadow_usename, dsc, &null_n);
-        if (null_n)
-            continue; /* don't allow empty users */
+		if (null_n)
+			continue;			/* don't allow empty users */
 		datum_p = heap_getattr(tuple, Anum_pg_shadow_passwd, dsc, &null_p);
-        /* It could be argued that people having a null password
-           shouldn't be allowed to connect, because they need
-           to have a password set up first. If you think assuming
-           an empty password in that case is better, erase the following line. */
-        if (null_p)
-            continue;
+
+		/*
+		 * It could be argued that people having a null password shouldn't
+		 * be allowed to connect, because they need to have a password set
+		 * up first. If you think assuming an empty password in that case
+		 * is better, erase the following line.
+		 */
+		if (null_p)
+			continue;
 		datum_v = heap_getattr(tuple, Anum_pg_shadow_valuntil, dsc, &null_v);
 
-        /* These fake entries are not really necessary. To remove them, the parser
-           in backend/libpq/crypt.c would need to be adjusted. Initdb might also
-           need adjustments. */
-        fprintf(fp, 
-                "%s"
-                CRYPT_PWD_FILE_SEPSTR
-                "0"
-                CRYPT_PWD_FILE_SEPSTR
-                "x"
-                CRYPT_PWD_FILE_SEPSTR
-                "x"
-                CRYPT_PWD_FILE_SEPSTR
-                "x"
-                CRYPT_PWD_FILE_SEPSTR
-                "x"
-                CRYPT_PWD_FILE_SEPSTR
-                "%s"
-                CRYPT_PWD_FILE_SEPSTR
-                "%s\n",
-                nameout(DatumGetName(datum_n)),
-                null_p ? "" : textout((text*)datum_p),
-                null_v ? "\\N" : nabstimeout((AbsoluteTime)datum_v) /* this is how the parser wants it */
-                );
-        if (ferror(fp))
-            elog(ERROR, "%s: %s", tempname, strerror(errno));
-        fflush(fp);
-    }
-    heap_endscan(scan);
-    FreeFile(fp);
-
-    /*
-     * And rename the temp file to its final name, deleting the old pg_pwd.
-     */
-    rename(tempname, filename);
-
-    /*
+		/*
+		 * These fake entries are not really necessary. To remove them,
+		 * the parser in backend/libpq/crypt.c would need to be adjusted.
+		 * Initdb might also need adjustments.
+		 */
+		fprintf(fp,
+				"%s"
+				CRYPT_PWD_FILE_SEPSTR
+				"0"
+				CRYPT_PWD_FILE_SEPSTR
+				"x"
+				CRYPT_PWD_FILE_SEPSTR
+				"x"
+				CRYPT_PWD_FILE_SEPSTR
+				"x"
+				CRYPT_PWD_FILE_SEPSTR
+				"x"
+				CRYPT_PWD_FILE_SEPSTR
+				"%s"
+				CRYPT_PWD_FILE_SEPSTR
+				"%s\n",
+				nameout(DatumGetName(datum_n)),
+				null_p ? "" : textout((text *) datum_p),
+				null_v ? "\\N" : nabstimeout((AbsoluteTime) datum_v)	/* this is how the
+																		 * parser wants it */
+			);
+		if (ferror(fp))
+			elog(ERROR, "%s: %s", tempname, strerror(errno));
+		fflush(fp);
+	}
+	heap_endscan(scan);
+	FreeFile(fp);
+
+	/*
+	 * And rename the temp file to its final name, deleting the old
+	 * pg_pwd.
+	 */
+	rename(tempname, filename);
+
+	/*
 	 * Create a flag file the postmaster will detect the next time it
 	 * tries to authenticate a user.  The postmaster will know to reload
 	 * the pg_pwd file contents.
 	 */
 	filename = crypt_getpwdreloadfilename();
 	if (creat(filename, S_IRUSR | S_IWUSR) == -1)
-        elog(ERROR, "%s: %s", filename, strerror(errno));
+		elog(ERROR, "%s: %s", filename, strerror(errno));
 
 	pfree((void *) tempname);
 }
@@ -149,16 +160,17 @@ write_password_file(Relation rel)
 HeapTuple
 update_pg_pwd(void)
 {
-    Relation rel = heap_openr(ShadowRelationName,  AccessExclusiveLock);
-    write_password_file(rel);
-    heap_close(rel,  AccessExclusiveLock);
+	Relation	rel = heap_openr(ShadowRelationName, AccessExclusiveLock);
+
+	write_password_file(rel);
+	heap_close(rel, AccessExclusiveLock);
 
 	/*
-	 * This is a trigger, so clean out the information provided by
-	 * the trigger manager.
+	 * This is a trigger, so clean out the information provided by the
+	 * trigger manager.
 	 */
 	CurrentTriggerData = NULL;
-    return NULL;
+	return NULL;
 }
 
 
@@ -173,36 +185,37 @@ CreateUser(CreateUserStmt *stmt)
 	TupleDesc	pg_shadow_dsc;
 	HeapScanDesc scan;
 	HeapTuple	tuple;
-    Datum       new_record[Natts_pg_shadow];
-    char        new_record_nulls[Natts_pg_shadow];
+	Datum		new_record[Natts_pg_shadow];
+	char		new_record_nulls[Natts_pg_shadow];
 	bool		user_exists = false,
-                sysid_exists = false,
-                havesysid;
+				sysid_exists = false,
+				havesysid;
 	int			max_id = -1;
-    List       *item;
+	List	   *item;
 
-    havesysid    = stmt->sysid > 0;
+	havesysid = stmt->sysid > 0;
 
-    /* Check some permissions first */
+	/* Check some permissions first */
 	if (stmt->password)
 		CheckPgUserAclNotNull();
 
-    if (!superuser())
-        elog(ERROR, "CREATE USER: permission denied");
+	if (!superuser())
+		elog(ERROR, "CREATE USER: permission denied");
 
-    /* The reason for the following is this:
-     * If you start a transaction block, create a user, then roll back the
-     * transaction, the pg_pwd won't get rolled back due to a bug in the
-     * Unix file system ( :}). Hence this is in the interest of security.
-     */
+	/*
+	 * The reason for the following is this: If you start a transaction
+	 * block, create a user, then roll back the transaction, the pg_pwd
+	 * won't get rolled back due to a bug in the Unix file system ( :}).
+	 * Hence this is in the interest of security.
+	 */
 	if (IsTransactionBlock())
-        elog(ERROR, "CREATE USER: may not be called in a transaction block");
+		elog(ERROR, "CREATE USER: may not be called in a transaction block");
 
 	/*
-	 * Scan the pg_shadow relation to be certain the user or id doesn't already
-	 * exist.  Note we secure exclusive lock, because we also need to be
-	 * sure of what the next usesysid should be, and we need to protect
-	 * our update of the flat password file.
+	 * Scan the pg_shadow relation to be certain the user or id doesn't
+	 * already exist.  Note we secure exclusive lock, because we also need
+	 * to be sure of what the next usesysid should be, and we need to
+	 * protect our update of the flat password file.
 	 */
 	pg_shadow_rel = heap_openr(ShadowRelationName, AccessExclusiveLock);
 	pg_shadow_dsc = RelationGetDescr(pg_shadow_rel);
@@ -210,103 +223,108 @@ CreateUser(CreateUserStmt *stmt)
 	scan = heap_beginscan(pg_shadow_rel, false, SnapshotNow, 0, NULL);
 	while (!user_exists && !sysid_exists && HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
 	{
-        Datum		datum;
-        bool        null;
+		Datum		datum;
+		bool		null;
 
 		datum = heap_getattr(tuple, Anum_pg_shadow_usename, pg_shadow_dsc, &null);
 		user_exists = datum && !null && (strcmp((char *) datum, stmt->user) == 0);
 
 		datum = heap_getattr(tuple, Anum_pg_shadow_usesysid, pg_shadow_dsc, &null);
-        if (havesysid) /* customized id wanted */
-            sysid_exists = datum && !null && ((int)datum == stmt->sysid);
-        else /* pick 1 + max */
-        {
-            if ((int) datum > max_id)
-                max_id = (int) datum;
-        }
+		if (havesysid)			/* customized id wanted */
+			sysid_exists = datum && !null && ((int) datum == stmt->sysid);
+		else
+/* pick 1 + max */
+		{
+			if ((int) datum > max_id)
+				max_id = (int) datum;
+		}
 	}
 	heap_endscan(scan);
 
 	if (user_exists || sysid_exists)
 	{
 		heap_close(pg_shadow_rel, AccessExclusiveLock);
-        if (user_exists)
-            elog(ERROR, "CREATE USER: user name \"%s\" already exists", stmt->user);
-        else
-            elog(ERROR, "CREATE USER: sysid %d is already assigned", stmt->sysid);
+		if (user_exists)
+			elog(ERROR, "CREATE USER: user name \"%s\" already exists", stmt->user);
+		else
+			elog(ERROR, "CREATE USER: sysid %d is already assigned", stmt->sysid);
 		return;
 	}
 
-    /*
-     * Build a tuple to insert
-     */
-    new_record[Anum_pg_shadow_usename-1] = PointerGetDatum(namein(stmt->user)); /* this truncated properly */
-    new_record[Anum_pg_shadow_usesysid-1] = Int32GetDatum(havesysid ? stmt->sysid : max_id + 1);
-
-    AssertState(BoolIsValid(stmt->createdb));
-    new_record[Anum_pg_shadow_usecreatedb-1] = (Datum)(stmt->createdb);
-    new_record[Anum_pg_shadow_usetrace-1] = (Datum)(false);
-    AssertState(BoolIsValid(stmt->createuser));
-    new_record[Anum_pg_shadow_usesuper-1] = (Datum)(stmt->createuser);
-    /* superuser gets catupd right by default */
-    new_record[Anum_pg_shadow_usecatupd-1] = (Datum)(stmt->createuser);
-
-    if (stmt->password)
-        new_record[Anum_pg_shadow_passwd-1] = PointerGetDatum(textin(stmt->password));
-    if (stmt->validUntil)
-        new_record[Anum_pg_shadow_valuntil-1] = PointerGetDatum(nabstimein(stmt->validUntil));
-
-    new_record_nulls[Anum_pg_shadow_usename-1] = ' ';
-    new_record_nulls[Anum_pg_shadow_usesysid-1] = ' ';
-
-    new_record_nulls[Anum_pg_shadow_usecreatedb-1] = ' ';
-    new_record_nulls[Anum_pg_shadow_usetrace-1] = ' ';
-    new_record_nulls[Anum_pg_shadow_usesuper-1] = ' ';
-    new_record_nulls[Anum_pg_shadow_usecatupd-1] = ' ';
-
-    new_record_nulls[Anum_pg_shadow_passwd-1] = stmt->password ? ' ' : 'n';
-    new_record_nulls[Anum_pg_shadow_valuntil-1] = stmt->validUntil ? ' ' : 'n';
-
-    tuple = heap_formtuple(pg_shadow_dsc, new_record, new_record_nulls);
-    Assert(tuple);
-
-    /*
-     * Insert a new record in the pg_shadow table
-     */
-    if (heap_insert(pg_shadow_rel, tuple) == InvalidOid)
-        elog(ERROR, "CREATE USER: heap_insert failed");
-
-    /*
-     * Update indexes
-     */
-    if (RelationGetForm(pg_shadow_rel)->relhasindex) {
-        Relation idescs[Num_pg_shadow_indices];
-      
-        CatalogOpenIndices(Num_pg_shadow_indices, 
-                           Name_pg_shadow_indices, idescs);
-        CatalogIndexInsert(idescs, Num_pg_shadow_indices, pg_shadow_rel, 
-                           tuple);
-        CatalogCloseIndices(Num_pg_shadow_indices, idescs);
-    }
+	/*
+	 * Build a tuple to insert
+	 */
+	new_record[Anum_pg_shadow_usename - 1] = PointerGetDatum(namein(stmt->user));		/* this truncated
+																						 * properly */
+	new_record[Anum_pg_shadow_usesysid - 1] = Int32GetDatum(havesysid ? stmt->sysid : max_id + 1);
+
+	AssertState(BoolIsValid(stmt->createdb));
+	new_record[Anum_pg_shadow_usecreatedb - 1] = (Datum) (stmt->createdb);
+	new_record[Anum_pg_shadow_usetrace - 1] = (Datum) (false);
+	AssertState(BoolIsValid(stmt->createuser));
+	new_record[Anum_pg_shadow_usesuper - 1] = (Datum) (stmt->createuser);
+	/* superuser gets catupd right by default */
+	new_record[Anum_pg_shadow_usecatupd - 1] = (Datum) (stmt->createuser);
+
+	if (stmt->password)
+		new_record[Anum_pg_shadow_passwd - 1] = PointerGetDatum(textin(stmt->password));
+	if (stmt->validUntil)
+		new_record[Anum_pg_shadow_valuntil - 1] = PointerGetDatum(nabstimein(stmt->validUntil));
+
+	new_record_nulls[Anum_pg_shadow_usename - 1] = ' ';
+	new_record_nulls[Anum_pg_shadow_usesysid - 1] = ' ';
+
+	new_record_nulls[Anum_pg_shadow_usecreatedb - 1] = ' ';
+	new_record_nulls[Anum_pg_shadow_usetrace - 1] = ' ';
+	new_record_nulls[Anum_pg_shadow_usesuper - 1] = ' ';
+	new_record_nulls[Anum_pg_shadow_usecatupd - 1] = ' ';
+
+	new_record_nulls[Anum_pg_shadow_passwd - 1] = stmt->password ? ' ' : 'n';
+	new_record_nulls[Anum_pg_shadow_valuntil - 1] = stmt->validUntil ? ' ' : 'n';
+
+	tuple = heap_formtuple(pg_shadow_dsc, new_record, new_record_nulls);
+	Assert(tuple);
+
+	/*
+	 * Insert a new record in the pg_shadow table
+	 */
+	if (heap_insert(pg_shadow_rel, tuple) == InvalidOid)
+		elog(ERROR, "CREATE USER: heap_insert failed");
+
+	/*
+	 * Update indexes
+	 */
+	if (RelationGetForm(pg_shadow_rel)->relhasindex)
+	{
+		Relation	idescs[Num_pg_shadow_indices];
+
+		CatalogOpenIndices(Num_pg_shadow_indices,
+						   Name_pg_shadow_indices, idescs);
+		CatalogIndexInsert(idescs, Num_pg_shadow_indices, pg_shadow_rel,
+						   tuple);
+		CatalogCloseIndices(Num_pg_shadow_indices, idescs);
+	}
 
 	/*
 	 * Add the user to the groups specified. We'll just call the below
-     * AlterGroup for this.
+	 * AlterGroup for this.
 	 */
-    foreach(item, stmt->groupElts)
-    {
-        AlterGroupStmt ags;
+	foreach(item, stmt->groupElts)
+	{
+		AlterGroupStmt ags;
 
-        ags.name = strVal(lfirst(item)); /* the group name to add this in */
-        ags.action = +1;
-        ags.listUsers = lcons((void*)makeInteger(havesysid ? stmt->sysid : max_id + 1), NIL);
-        AlterGroup(&ags, "CREATE USER");
-    }
+		ags.name = strVal(lfirst(item));		/* the group name to add
+												 * this in */
+		ags.action = +1;
+		ags.listUsers = lcons((void *) makeInteger(havesysid ? stmt->sysid : max_id + 1), NIL);
+		AlterGroup(&ags, "CREATE USER");
+	}
 
 	/*
 	 * Write the updated pg_shadow data to the flat password file.
 	 */
-    write_password_file(pg_shadow_rel);
+	write_password_file(pg_shadow_rel);
+
 	/*
 	 * Now we can clean up.
 	 */
@@ -321,30 +339,31 @@ CreateUser(CreateUserStmt *stmt)
 extern void
 AlterUser(AlterUserStmt *stmt)
 {
-    Datum       new_record[Natts_pg_shadow];
-    char        new_record_nulls[Natts_pg_shadow];
+	Datum		new_record[Natts_pg_shadow];
+	char		new_record_nulls[Natts_pg_shadow];
 	Relation	pg_shadow_rel;
 	TupleDesc	pg_shadow_dsc;
-	HeapTuple	tuple, new_tuple;
-    bool        null;
+	HeapTuple	tuple,
+				new_tuple;
+	bool		null;
 
 	if (stmt->password)
 		CheckPgUserAclNotNull();
 
-    /* must be superuser or just want to change your own password */
-    if (!superuser() &&
-        !(stmt->createdb==0 && stmt->createuser==0 && !stmt->validUntil
-          && stmt->password && strcmp(GetPgUserName(), stmt->user)==0))
-        elog(ERROR, "ALTER USER: permission denied");
+	/* must be superuser or just want to change your own password */
+	if (!superuser() &&
+	  !(stmt->createdb == 0 && stmt->createuser == 0 && !stmt->validUntil
+		&& stmt->password && strcmp(GetPgUserName(), stmt->user) == 0))
+		elog(ERROR, "ALTER USER: permission denied");
 
-    /* see comments in create user */
+	/* see comments in create user */
 	if (IsTransactionBlock())
-        elog(ERROR, "ALTER USER: may not be called in a transaction block");
+		elog(ERROR, "ALTER USER: may not be called in a transaction block");
 
 	/*
-	 * Scan the pg_shadow relation to be certain the user exists.
-	 * Note we secure exclusive lock to protect our update of the
-	 * flat password file.
+	 * Scan the pg_shadow relation to be certain the user exists. Note we
+	 * secure exclusive lock to protect our update of the flat password
+	 * file.
 	 */
 	pg_shadow_rel = heap_openr(ShadowRelationName, AccessExclusiveLock);
 	pg_shadow_dsc = RelationGetDescr(pg_shadow_rel);
@@ -358,107 +377,107 @@ AlterUser(AlterUserStmt *stmt)
 		elog(ERROR, "ALTER USER: user \"%s\" does not exist", stmt->user);
 	}
 
-    /*
-     * Build a tuple to update, perusing the information just obtained
-     */
-    new_record[Anum_pg_shadow_usename-1] = PointerGetDatum(namein(stmt->user));
-    new_record_nulls[Anum_pg_shadow_usename-1] = ' ';
-
-    /* sysid - leave as is */
-    new_record[Anum_pg_shadow_usesysid-1] = heap_getattr(tuple, Anum_pg_shadow_usesysid, pg_shadow_dsc, &null);
-    new_record_nulls[Anum_pg_shadow_usesysid-1] = null ? 'n' : ' ';
-
-    /* createdb */
-    if (stmt->createdb == 0)
-    {
-        /* don't change */
-        new_record[Anum_pg_shadow_usecreatedb-1] = heap_getattr(tuple, Anum_pg_shadow_usecreatedb, pg_shadow_dsc, &null);
-        new_record_nulls[Anum_pg_shadow_usecreatedb-1] = null ? 'n' : ' ';
-    }
-    else
-    {
-        new_record[Anum_pg_shadow_usecreatedb-1] = (Datum)(stmt->createdb > 0 ? true : false);
-        new_record_nulls[Anum_pg_shadow_usecreatedb-1] = ' ';
-    }
-
-    /* trace - leave as is */
-    new_record[Anum_pg_shadow_usetrace-1] = heap_getattr(tuple, Anum_pg_shadow_usetrace, pg_shadow_dsc, &null);
-    new_record_nulls[Anum_pg_shadow_usetrace-1] = null ? 'n' : ' ';
-
-    /* createuser (superuser) */
-    if (stmt->createuser == 0)
-    {
-        /* don't change */
-        new_record[Anum_pg_shadow_usesuper-1] = heap_getattr(tuple, Anum_pg_shadow_usesuper, pg_shadow_dsc, &null);
-        new_record_nulls[Anum_pg_shadow_usesuper-1] = null ? 'n' : ' ';
-    }
-    else
-    {
-        new_record[Anum_pg_shadow_usesuper-1] = (Datum)(stmt->createuser > 0 ? true : false);
-        new_record_nulls[Anum_pg_shadow_usesuper-1] = ' ';
-    }
-
-    /* catupd - set to false if someone's superuser priv is being yanked */
-    if (stmt->createuser < 0)
-    {
-        new_record[Anum_pg_shadow_usecatupd-1] = (Datum)(false);
-        new_record_nulls[Anum_pg_shadow_usecatupd-1] = ' ';
-    }
-    else
-    {
-        /* leave alone */
-        new_record[Anum_pg_shadow_usecatupd-1] = heap_getattr(tuple, Anum_pg_shadow_usecatupd, pg_shadow_dsc, &null);
-        new_record_nulls[Anum_pg_shadow_usecatupd-1] = null ? 'n' : ' ';
-    }
-
-    /* password */
-    if (stmt->password)
-    {
-        new_record[Anum_pg_shadow_passwd-1] = PointerGetDatum(textin(stmt->password));
-        new_record_nulls[Anum_pg_shadow_passwd-1] = ' ';
-    }
-    else
-    {
-        /* leave as is */
-        new_record[Anum_pg_shadow_passwd-1] = heap_getattr(tuple, Anum_pg_shadow_passwd, pg_shadow_dsc, &null);
-        new_record_nulls[Anum_pg_shadow_passwd-1] = null ? 'n' : ' ';
-    }
-
-    /* valid until */
-    if (stmt->validUntil)
-    {    
-        new_record[Anum_pg_shadow_valuntil-1] = PointerGetDatum(nabstimein(stmt->validUntil));
-        new_record_nulls[Anum_pg_shadow_valuntil-1] = ' ';
-    }
-    else
-    {
-        /* leave as is */
-        new_record[Anum_pg_shadow_valuntil-1] = heap_getattr(tuple, Anum_pg_shadow_valuntil, pg_shadow_dsc, &null);
-        new_record_nulls[Anum_pg_shadow_valuntil-1] = null ? 'n' : ' ';
-    }
-
-    new_tuple = heap_formtuple(pg_shadow_dsc, new_record, new_record_nulls);
-    Assert(new_tuple);
-    /* XXX check return value of this? */
-    heap_update(pg_shadow_rel, &tuple->t_self, new_tuple, NULL);
-
-
-    /* Update indexes */
-    if (RelationGetForm(pg_shadow_rel)->relhasindex)
-    {
-        Relation idescs[Num_pg_shadow_indices];
-      
-        CatalogOpenIndices(Num_pg_shadow_indices, 
-                           Name_pg_shadow_indices, idescs);
-        CatalogIndexInsert(idescs, Num_pg_shadow_indices, pg_shadow_rel, 
-                           tuple);
-        CatalogCloseIndices(Num_pg_shadow_indices, idescs);
-    }
+	/*
+	 * Build a tuple to update, perusing the information just obtained
+	 */
+	new_record[Anum_pg_shadow_usename - 1] = PointerGetDatum(namein(stmt->user));
+	new_record_nulls[Anum_pg_shadow_usename - 1] = ' ';
+
+	/* sysid - leave as is */
+	new_record[Anum_pg_shadow_usesysid - 1] = heap_getattr(tuple, Anum_pg_shadow_usesysid, pg_shadow_dsc, &null);
+	new_record_nulls[Anum_pg_shadow_usesysid - 1] = null ? 'n' : ' ';
+
+	/* createdb */
+	if (stmt->createdb == 0)
+	{
+		/* don't change */
+		new_record[Anum_pg_shadow_usecreatedb - 1] = heap_getattr(tuple, Anum_pg_shadow_usecreatedb, pg_shadow_dsc, &null);
+		new_record_nulls[Anum_pg_shadow_usecreatedb - 1] = null ? 'n' : ' ';
+	}
+	else
+	{
+		new_record[Anum_pg_shadow_usecreatedb - 1] = (Datum) (stmt->createdb > 0 ? true : false);
+		new_record_nulls[Anum_pg_shadow_usecreatedb - 1] = ' ';
+	}
+
+	/* trace - leave as is */
+	new_record[Anum_pg_shadow_usetrace - 1] = heap_getattr(tuple, Anum_pg_shadow_usetrace, pg_shadow_dsc, &null);
+	new_record_nulls[Anum_pg_shadow_usetrace - 1] = null ? 'n' : ' ';
+
+	/* createuser (superuser) */
+	if (stmt->createuser == 0)
+	{
+		/* don't change */
+		new_record[Anum_pg_shadow_usesuper - 1] = heap_getattr(tuple, Anum_pg_shadow_usesuper, pg_shadow_dsc, &null);
+		new_record_nulls[Anum_pg_shadow_usesuper - 1] = null ? 'n' : ' ';
+	}
+	else
+	{
+		new_record[Anum_pg_shadow_usesuper - 1] = (Datum) (stmt->createuser > 0 ? true : false);
+		new_record_nulls[Anum_pg_shadow_usesuper - 1] = ' ';
+	}
+
+	/* catupd - set to false if someone's superuser priv is being yanked */
+	if (stmt->createuser < 0)
+	{
+		new_record[Anum_pg_shadow_usecatupd - 1] = (Datum) (false);
+		new_record_nulls[Anum_pg_shadow_usecatupd - 1] = ' ';
+	}
+	else
+	{
+		/* leave alone */
+		new_record[Anum_pg_shadow_usecatupd - 1] = heap_getattr(tuple, Anum_pg_shadow_usecatupd, pg_shadow_dsc, &null);
+		new_record_nulls[Anum_pg_shadow_usecatupd - 1] = null ? 'n' : ' ';
+	}
+
+	/* password */
+	if (stmt->password)
+	{
+		new_record[Anum_pg_shadow_passwd - 1] = PointerGetDatum(textin(stmt->password));
+		new_record_nulls[Anum_pg_shadow_passwd - 1] = ' ';
+	}
+	else
+	{
+		/* leave as is */
+		new_record[Anum_pg_shadow_passwd - 1] = heap_getattr(tuple, Anum_pg_shadow_passwd, pg_shadow_dsc, &null);
+		new_record_nulls[Anum_pg_shadow_passwd - 1] = null ? 'n' : ' ';
+	}
+
+	/* valid until */
+	if (stmt->validUntil)
+	{
+		new_record[Anum_pg_shadow_valuntil - 1] = PointerGetDatum(nabstimein(stmt->validUntil));
+		new_record_nulls[Anum_pg_shadow_valuntil - 1] = ' ';
+	}
+	else
+	{
+		/* leave as is */
+		new_record[Anum_pg_shadow_valuntil - 1] = heap_getattr(tuple, Anum_pg_shadow_valuntil, pg_shadow_dsc, &null);
+		new_record_nulls[Anum_pg_shadow_valuntil - 1] = null ? 'n' : ' ';
+	}
+
+	new_tuple = heap_formtuple(pg_shadow_dsc, new_record, new_record_nulls);
+	Assert(new_tuple);
+	/* XXX check return value of this? */
+	heap_update(pg_shadow_rel, &tuple->t_self, new_tuple, NULL);
+
+
+	/* Update indexes */
+	if (RelationGetForm(pg_shadow_rel)->relhasindex)
+	{
+		Relation	idescs[Num_pg_shadow_indices];
+
+		CatalogOpenIndices(Num_pg_shadow_indices,
+						   Name_pg_shadow_indices, idescs);
+		CatalogIndexInsert(idescs, Num_pg_shadow_indices, pg_shadow_rel,
+						   tuple);
+		CatalogCloseIndices(Num_pg_shadow_indices, idescs);
+	}
 
 	/*
 	 * Write the updated pg_shadow data to the flat password file.
 	 */
-    write_password_file(pg_shadow_rel);
+	write_password_file(pg_shadow_rel);
 
 	/*
 	 * Now we can clean up.
@@ -477,13 +496,13 @@ DropUser(DropUserStmt *stmt)
 {
 	Relation	pg_shadow_rel;
 	TupleDesc	pg_shadow_dsc;
-    List       *item;
+	List	   *item;
 
-    if (!superuser())
-        elog(ERROR, "DROP USER: permission denied");
+	if (!superuser())
+		elog(ERROR, "DROP USER: permission denied");
 
 	if (IsTransactionBlock())
-        elog(ERROR, "DROP USER: may not be called in a transaction block");
+		elog(ERROR, "DROP USER: may not be called in a transaction block");
 
 	/*
 	 * Scan the pg_shadow relation to find the usesysid of the user to be
@@ -493,103 +512,105 @@ DropUser(DropUserStmt *stmt)
 	pg_shadow_rel = heap_openr(ShadowRelationName, AccessExclusiveLock);
 	pg_shadow_dsc = RelationGetDescr(pg_shadow_rel);
 
-    foreach(item, stmt->users)
-    {
-        HeapTuple	tuple,
-            tmp_tuple;
-        Relation    pg_rel;
-        TupleDesc   pg_dsc;
-        ScanKeyData scankey;
-        HeapScanDesc scan;
-        Datum		datum;
-        bool		null;
-        int32		usesysid;
-        const char *user = strVal(lfirst(item));
-
-        tuple = SearchSysCacheTuple(SHADOWNAME,
-                                    PointerGetDatum(user),
-                                    0, 0, 0);
-        if (!HeapTupleIsValid(tuple))
-        {
-            heap_close(pg_shadow_rel, AccessExclusiveLock);
-            elog(ERROR, "DROP USER: user \"%s\" does not exist%s", user,
-                 (length(stmt->users) > 1) ? " (no users removed)" : "");
-        }
-
-        usesysid = DatumGetInt32(heap_getattr(tuple, Anum_pg_shadow_usesysid, pg_shadow_dsc, &null));
-
-        /*-------------------
-         * Check if user still owns a database. If so, error out.
-         *
-         * (It used to be that this function would drop the database automatically.
-         *  This is not only very dangerous for people that don't read the manual,
-         *  it doesn't seem to be the behaviour one would expect either.)
-         *                                                   -- petere 2000/01/14)
-         *-------------------*/
-        pg_rel = heap_openr(DatabaseRelationName, AccessExclusiveLock);
-        pg_dsc = RelationGetDescr(pg_rel);
-
-        ScanKeyEntryInitialize(&scankey, 0x0, Anum_pg_database_datdba, F_INT4EQ,
-                               Int32GetDatum(usesysid));
-
-        scan = heap_beginscan(pg_rel, false, SnapshotNow, 1, &scankey);
-
-        if (HeapTupleIsValid(tmp_tuple = heap_getnext(scan, 0)))
-        {
-            datum = heap_getattr(tmp_tuple, Anum_pg_database_datname, pg_dsc, &null);
-            heap_close(pg_shadow_rel, AccessExclusiveLock);
-            elog(ERROR, "DROP USER: user \"%s\" owns database \"%s\", cannot be removed%s",
-                 user, nameout(DatumGetName(datum)),
-                 (length(stmt->users) > 1) ? " (no users removed)" : ""
-                );
-        }
-            
-        heap_endscan(scan);
-        heap_close(pg_rel, AccessExclusiveLock);
-
-        /*
-         * Somehow we'd have to check for tables, views, etc. owned by the user
-         * as well, but those could be spread out over all sorts of databases
-         * which we don't have access to (easily).
-         */
-
-        /*
-         * Remove the user from the pg_shadow table
-         */
-        heap_delete(pg_shadow_rel, &tuple->t_self, NULL);
-
-        /*
-         * Remove user from groups
-         *
-         * try calling alter group drop user for every group
-         */
-        pg_rel = heap_openr(GroupRelationName, AccessExclusiveLock);
-        pg_dsc = RelationGetDescr(pg_rel);
-        scan = heap_beginscan(pg_rel, false, SnapshotNow, 0, NULL);
-        while (HeapTupleIsValid(tmp_tuple = heap_getnext(scan, 0)))
-        {
-            AlterGroupStmt ags;
-
-            datum = heap_getattr(tmp_tuple, Anum_pg_group_groname, pg_dsc, &null);
-
-            ags.name = nameout(DatumGetName(datum)); /* the group name from which to try to drop the user */
-            ags.action = -1;
-            ags.listUsers = lcons((void*)makeInteger(usesysid), NIL);
-            AlterGroup(&ags, "DROP USER");
-        }
-        heap_endscan(scan);
-        heap_close(pg_rel, AccessExclusiveLock);        
-    }
+	foreach(item, stmt->users)
+	{
+		HeapTuple	tuple,
+					tmp_tuple;
+		Relation	pg_rel;
+		TupleDesc	pg_dsc;
+		ScanKeyData scankey;
+		HeapScanDesc scan;
+		Datum		datum;
+		bool		null;
+		int32		usesysid;
+		const char *user = strVal(lfirst(item));
+
+		tuple = SearchSysCacheTuple(SHADOWNAME,
+									PointerGetDatum(user),
+									0, 0, 0);
+		if (!HeapTupleIsValid(tuple))
+		{
+			heap_close(pg_shadow_rel, AccessExclusiveLock);
+			elog(ERROR, "DROP USER: user \"%s\" does not exist%s", user,
+				 (length(stmt->users) > 1) ? " (no users removed)" : "");
+		}
+
+		usesysid = DatumGetInt32(heap_getattr(tuple, Anum_pg_shadow_usesysid, pg_shadow_dsc, &null));
+
+		/*-------------------
+		 * Check if user still owns a database. If so, error out.
+		 *
+		 * (It used to be that this function would drop the database automatically.
+		 *	This is not only very dangerous for people that don't read the manual,
+		 *	it doesn't seem to be the behaviour one would expect either.)
+		 *													 -- petere 2000/01/14)
+		 *-------------------*/
+		pg_rel = heap_openr(DatabaseRelationName, AccessExclusiveLock);
+		pg_dsc = RelationGetDescr(pg_rel);
+
+		ScanKeyEntryInitialize(&scankey, 0x0, Anum_pg_database_datdba, F_INT4EQ,
+							   Int32GetDatum(usesysid));
+
+		scan = heap_beginscan(pg_rel, false, SnapshotNow, 1, &scankey);
+
+		if (HeapTupleIsValid(tmp_tuple = heap_getnext(scan, 0)))
+		{
+			datum = heap_getattr(tmp_tuple, Anum_pg_database_datname, pg_dsc, &null);
+			heap_close(pg_shadow_rel, AccessExclusiveLock);
+			elog(ERROR, "DROP USER: user \"%s\" owns database \"%s\", cannot be removed%s",
+				 user, nameout(DatumGetName(datum)),
+				 (length(stmt->users) > 1) ? " (no users removed)" : ""
+				);
+		}
+
+		heap_endscan(scan);
+		heap_close(pg_rel, AccessExclusiveLock);
+
+		/*
+		 * Somehow we'd have to check for tables, views, etc. owned by the
+		 * user as well, but those could be spread out over all sorts of
+		 * databases which we don't have access to (easily).
+		 */
+
+		/*
+		 * Remove the user from the pg_shadow table
+		 */
+		heap_delete(pg_shadow_rel, &tuple->t_self, NULL);
+
+		/*
+		 * Remove user from groups
+		 *
+		 * try calling alter group drop user for every group
+		 */
+		pg_rel = heap_openr(GroupRelationName, AccessExclusiveLock);
+		pg_dsc = RelationGetDescr(pg_rel);
+		scan = heap_beginscan(pg_rel, false, SnapshotNow, 0, NULL);
+		while (HeapTupleIsValid(tmp_tuple = heap_getnext(scan, 0)))
+		{
+			AlterGroupStmt ags;
+
+			datum = heap_getattr(tmp_tuple, Anum_pg_group_groname, pg_dsc, &null);
+
+			ags.name = nameout(DatumGetName(datum));	/* the group name from
+														 * which to try to drop
+														 * the user */
+			ags.action = -1;
+			ags.listUsers = lcons((void *) makeInteger(usesysid), NIL);
+			AlterGroup(&ags, "DROP USER");
+		}
+		heap_endscan(scan);
+		heap_close(pg_rel, AccessExclusiveLock);
+	}
 
 	/*
 	 * Write the updated pg_shadow data to the flat password file.
 	 */
-    write_password_file(pg_shadow_rel);
+	write_password_file(pg_shadow_rel);
 
-    /*
-     * Now we can clean up.
-     */
-    heap_close(pg_shadow_rel, AccessExclusiveLock);
+	/*
+	 * Now we can clean up.
+	 */
+	heap_close(pg_shadow_rel, AccessExclusiveLock);
 }
 
 
@@ -609,7 +630,7 @@ CheckPgUserAclNotNull()
 							   0, 0, 0);
 	if (!HeapTupleIsValid(htup))
 	{
-        /* BIG problem */
+		/* BIG problem */
 		elog(ERROR, "IsPgUserAclNull: \"%s\" not found",
 			 ShadowRelationName);
 	}
@@ -617,10 +638,10 @@ CheckPgUserAclNotNull()
 	if (heap_attisnull(htup, Anum_pg_class_relacl))
 	{
 		elog(ERROR,
-             "To use passwords, you have to revoke permissions on %s "
-             "so normal users cannot read the passwords. "
-             "Try 'REVOKE ALL ON \"%s\" FROM PUBLIC'.",
-             ShadowRelationName, ShadowRelationName);
+			 "To use passwords, you have to revoke permissions on %s "
+			 "so normal users cannot read the passwords. "
+			 "Try 'REVOKE ALL ON \"%s\" FROM PUBLIC'.",
+			 ShadowRelationName, ShadowRelationName);
 	}
 
 	return;
@@ -637,14 +658,15 @@ CreateGroup(CreateGroupStmt *stmt)
 	Relation	pg_group_rel;
 	HeapScanDesc scan;
 	HeapTuple	tuple;
-    TupleDesc   pg_group_dsc;
-    bool        group_exists = false,
-                sysid_exists = false;
-    int         max_id = 0;
-    Datum       new_record[Natts_pg_group];
-    char        new_record_nulls[Natts_pg_group];
-    List       *item, *newlist=NULL;
-    ArrayType  *userarray;
+	TupleDesc	pg_group_dsc;
+	bool		group_exists = false,
+				sysid_exists = false;
+	int			max_id = 0;
+	Datum		new_record[Natts_pg_group];
+	char		new_record_nulls[Natts_pg_group];
+	List	   *item,
+			   *newlist = NULL;
+	ArrayType  *userarray;
 
 	/*
 	 * Make sure the user can do this.
@@ -652,12 +674,12 @@ CreateGroup(CreateGroupStmt *stmt)
 	if (!superuser())
 		elog(ERROR, "CREATE GROUP: permission denied");
 
-    /*
-     * There is not real reason for this, but it makes it consistent
-     * with create user, and it seems like a good idea anyway.
-     */
+	/*
+	 * There is not real reason for this, but it makes it consistent with
+	 * create user, and it seems like a good idea anyway.
+	 */
 	if (IsTransactionBlock())
-        elog(ERROR, "CREATE GROUP: may not be called in a transaction block");
+		elog(ERROR, "CREATE GROUP: may not be called in a transaction block");
 
 
 	pg_group_rel = heap_openr(GroupRelationName, AccessExclusiveLock);
@@ -666,111 +688,111 @@ CreateGroup(CreateGroupStmt *stmt)
 	scan = heap_beginscan(pg_group_rel, false, SnapshotNow, 0, NULL);
 	while (!group_exists && !sysid_exists && HeapTupleIsValid(tuple = heap_getnext(scan, false)))
 	{
-        Datum		datum;
-        bool        null;
+		Datum		datum;
+		bool		null;
 
 		datum = heap_getattr(tuple, Anum_pg_group_groname, pg_group_dsc, &null);
 		group_exists = datum && !null && (strcmp((char *) datum, stmt->name) == 0);
 
 		datum = heap_getattr(tuple, Anum_pg_group_grosysid, pg_group_dsc, &null);
-        if (stmt->sysid >= 0) /* customized id wanted */
-            sysid_exists = datum && !null && ((int)datum == stmt->sysid);
-        else /* pick 1 + max */
-        {
-            if ((int) datum > max_id)
-                max_id = (int) datum;
-        }
+		if (stmt->sysid >= 0)	/* customized id wanted */
+			sysid_exists = datum && !null && ((int) datum == stmt->sysid);
+		else
+/* pick 1 + max */
+		{
+			if ((int) datum > max_id)
+				max_id = (int) datum;
+		}
 	}
 	heap_endscan(scan);
 
 	if (group_exists || sysid_exists)
 	{
 		heap_close(pg_group_rel, AccessExclusiveLock);
-        if (group_exists)
-            elog(ERROR, "CREATE GROUP: group name \"%s\" already exists", stmt->name);
-        else
-            elog(ERROR, "CREATE GROUP: group sysid %d is already assigned", stmt->sysid);
+		if (group_exists)
+			elog(ERROR, "CREATE GROUP: group name \"%s\" already exists", stmt->name);
+		else
+			elog(ERROR, "CREATE GROUP: group sysid %d is already assigned", stmt->sysid);
 	}
 
-    /*
-     * Translate the given user names to ids
-     */
-
-    foreach(item, stmt->initUsers)
-    {
-        const char * groupuser = strVal(lfirst(item));
-        Value *v;
-
-        tuple = SearchSysCacheTuple(SHADOWNAME,
-                                    PointerGetDatum(groupuser),
-                                    0, 0, 0);
-        if (!HeapTupleIsValid(tuple))
-        {
-            heap_close(pg_group_rel, AccessExclusiveLock);
-            elog(ERROR, "CREATE GROUP: user \"%s\" does not exist", groupuser);
-        }
-
-        v = makeInteger(((Form_pg_shadow) GETSTRUCT(tuple))->usesysid);
-        if (!member(v, newlist))
-            newlist = lcons(v, newlist);
-    }
-
-    /* build an array to insert */
-    if (newlist)
-    {
-        int i;
-
-        userarray = palloc(ARR_OVERHEAD(1) + length(newlist) * sizeof(int32));
-        ARR_SIZE(userarray) = ARR_OVERHEAD(1) + length(newlist) * sizeof(int32);
-        ARR_FLAGS(userarray) = 0x0;
-        ARR_NDIM(userarray) = 1; /* one dimensional array */
-        ARR_LBOUND(userarray)[0] = 1; /* axis starts at one */
-        ARR_DIMS(userarray)[0] = length(newlist); /* axis is this long */
-        /* fill the array */
-        i = 0;
-        foreach(item, newlist)
-        {
-            ((int*)ARR_DATA_PTR(userarray))[i++] = intVal(lfirst(item));
-        }
-    }
-    else
-        userarray = NULL;
-
-    /*
-     * Form a tuple to insert
-     */
-    if (stmt->sysid >=0)
-        max_id = stmt->sysid;
-    else 
-        max_id++;
-
-    new_record[Anum_pg_group_groname-1] = (Datum)(stmt->name);
-    new_record[Anum_pg_group_grosysid-1] = (Datum)(max_id);
-    new_record[Anum_pg_group_grolist-1] = (Datum)userarray;
-
-    new_record_nulls[Anum_pg_group_groname-1] = ' ';
-    new_record_nulls[Anum_pg_group_grosysid-1] = ' ';
-    new_record_nulls[Anum_pg_group_grolist-1] = userarray ? ' ' : 'n';
-
-    tuple = heap_formtuple(pg_group_dsc, new_record, new_record_nulls);
-
-    /*
-     * Insert a new record in the pg_group_table
-     */
-    heap_insert(pg_group_rel, tuple);
-
-    /*
-     * Update indexes
-     */
-    if (RelationGetForm(pg_group_rel)->relhasindex) {
-        Relation idescs[Num_pg_group_indices];
-      
-        CatalogOpenIndices(Num_pg_group_indices, 
-                           Name_pg_group_indices, idescs);
-        CatalogIndexInsert(idescs, Num_pg_group_indices, pg_group_rel, 
-                           tuple);
-        CatalogCloseIndices(Num_pg_group_indices, idescs);
-    }
+	/*
+	 * Translate the given user names to ids
+	 */
+
+	foreach(item, stmt->initUsers)
+	{
+		const char *groupuser = strVal(lfirst(item));
+		Value	   *v;
+
+		tuple = SearchSysCacheTuple(SHADOWNAME,
+									PointerGetDatum(groupuser),
+									0, 0, 0);
+		if (!HeapTupleIsValid(tuple))
+		{
+			heap_close(pg_group_rel, AccessExclusiveLock);
+			elog(ERROR, "CREATE GROUP: user \"%s\" does not exist", groupuser);
+		}
+
+		v = makeInteger(((Form_pg_shadow) GETSTRUCT(tuple))->usesysid);
+		if (!member(v, newlist))
+			newlist = lcons(v, newlist);
+	}
+
+	/* build an array to insert */
+	if (newlist)
+	{
+		int			i;
+
+		userarray = palloc(ARR_OVERHEAD(1) + length(newlist) * sizeof(int32));
+		ARR_SIZE(userarray) = ARR_OVERHEAD(1) + length(newlist) * sizeof(int32);
+		ARR_FLAGS(userarray) = 0x0;
+		ARR_NDIM(userarray) = 1;/* one dimensional array */
+		ARR_LBOUND(userarray)[0] = 1;	/* axis starts at one */
+		ARR_DIMS(userarray)[0] = length(newlist);		/* axis is this long */
+		/* fill the array */
+		i = 0;
+		foreach(item, newlist)
+			((int *) ARR_DATA_PTR(userarray))[i++] = intVal(lfirst(item));
+	}
+	else
+		userarray = NULL;
+
+	/*
+	 * Form a tuple to insert
+	 */
+	if (stmt->sysid >= 0)
+		max_id = stmt->sysid;
+	else
+		max_id++;
+
+	new_record[Anum_pg_group_groname - 1] = (Datum) (stmt->name);
+	new_record[Anum_pg_group_grosysid - 1] = (Datum) (max_id);
+	new_record[Anum_pg_group_grolist - 1] = (Datum) userarray;
+
+	new_record_nulls[Anum_pg_group_groname - 1] = ' ';
+	new_record_nulls[Anum_pg_group_grosysid - 1] = ' ';
+	new_record_nulls[Anum_pg_group_grolist - 1] = userarray ? ' ' : 'n';
+
+	tuple = heap_formtuple(pg_group_dsc, new_record, new_record_nulls);
+
+	/*
+	 * Insert a new record in the pg_group_table
+	 */
+	heap_insert(pg_group_rel, tuple);
+
+	/*
+	 * Update indexes
+	 */
+	if (RelationGetForm(pg_group_rel)->relhasindex)
+	{
+		Relation	idescs[Num_pg_group_indices];
+
+		CatalogOpenIndices(Num_pg_group_indices,
+						   Name_pg_group_indices, idescs);
+		CatalogIndexInsert(idescs, Num_pg_group_indices, pg_group_rel,
+						   tuple);
+		CatalogCloseIndices(Num_pg_group_indices, idescs);
+	}
 
 	heap_close(pg_group_rel, AccessExclusiveLock);
 }
@@ -781,258 +803,272 @@ CreateGroup(CreateGroupStmt *stmt)
  * ALTER GROUP
  */
 void
-AlterGroup(AlterGroupStmt *stmt, const char * tag)
+AlterGroup(AlterGroupStmt *stmt, const char *tag)
 {
 	Relation	pg_group_rel;
-    TupleDesc   pg_group_dsc;
-    HeapTuple   group_tuple;
+	TupleDesc	pg_group_dsc;
+	HeapTuple	group_tuple;
 
-    /*
+	/*
 	 * Make sure the user can do this.
 	 */
 	if (!superuser())
 		elog(ERROR, "%s: permission denied", tag);
 
-    /*
-     * There is not real reason for this, but it makes it consistent
-     * with alter user, and it seems like a good idea anyway.
-     */
+	/*
+	 * There is not real reason for this, but it makes it consistent with
+	 * alter user, and it seems like a good idea anyway.
+	 */
 	if (IsTransactionBlock())
-        elog(ERROR, "%s: may not be called in a transaction block", tag);
+		elog(ERROR, "%s: may not be called in a transaction block", tag);
 
 
-    pg_group_rel = heap_openr(GroupRelationName, AccessExclusiveLock);
-    pg_group_dsc = RelationGetDescr(pg_group_rel);
+	pg_group_rel = heap_openr(GroupRelationName, AccessExclusiveLock);
+	pg_group_dsc = RelationGetDescr(pg_group_rel);
 
-    /*
-     * Verify that group exists.
-     * If we find a tuple, will take that the rest of the way and make our
-     * modifications on it.
-     */
-    if (!HeapTupleIsValid(group_tuple = SearchSysCacheTupleCopy(GRONAME, PointerGetDatum(stmt->name), 0, 0, 0)))
+	/*
+	 * Verify that group exists. If we find a tuple, will take that the
+	 * rest of the way and make our modifications on it.
+	 */
+	if (!HeapTupleIsValid(group_tuple = SearchSysCacheTupleCopy(GRONAME, PointerGetDatum(stmt->name), 0, 0, 0)))
 	{
-        heap_close(pg_group_rel, AccessExclusiveLock);
+		heap_close(pg_group_rel, AccessExclusiveLock);
 		elog(ERROR, "%s: group \"%s\" does not exist", tag, stmt->name);
 	}
 
-    AssertState(stmt->action == +1 || stmt->action == -1);
-    /*
-     * Now decide what to do.
-     */
-    if (stmt->action == +1) /* add users, might also be invoked by create user */
-    {
-        Datum       new_record[Natts_pg_group];
-        char        new_record_nulls[Natts_pg_group] = { ' ', ' ', ' '};
-        ArrayType *newarray, *oldarray;
-        List * newlist = NULL, *item;
-        HeapTuple tuple;
-        bool null = false;
-        Datum datum = heap_getattr(group_tuple, Anum_pg_group_grolist, pg_group_dsc, &null);
-        int i;
-        
-        oldarray = (ArrayType*)datum;
-        Assert(null || ARR_NDIM(oldarray) == 1);
-        /* first add the old array to the hitherto empty list */
-        if (!null)
-            for (i = ARR_LBOUND(oldarray)[0]; i < ARR_LBOUND(oldarray)[0] + ARR_DIMS(oldarray)[0]; i++)
-            {
-                int index, arrval;
-                Value *v;
-                bool valueNull;
-                index = i;
-                arrval = DatumGetInt32(array_ref(oldarray, 1, &index, true/*by value*/,
-                                                 sizeof(int), 0, &valueNull));
-                v = makeInteger(arrval);
-                /* filter out duplicates */
-                if (!member(v, newlist))
-                    newlist = lcons(v, newlist);
-            }
-
-        /* 
-         * now convert the to be added usernames to sysids and add them
-         * to the list
-         */
-        foreach(item, stmt->listUsers)
-        {
-            Value *v;
-
-            if (strcmp(tag, "ALTER GROUP")==0)
-            {
-                /* Get the uid of the proposed user to add. */
-                tuple = SearchSysCacheTuple(SHADOWNAME,
-                                            PointerGetDatum(strVal(lfirst(item))),
-                                            0, 0, 0);
-                if (!HeapTupleIsValid(tuple))
-                {
-                    heap_close(pg_group_rel, AccessExclusiveLock);
-                    elog(ERROR, "%s: user \"%s\" does not exist", tag, strVal(lfirst(item)));
-                }
-                v = makeInteger(((Form_pg_shadow) GETSTRUCT(tuple))->usesysid);
-            }
-            else if (strcmp(tag, "CREATE USER")==0)
-            {
-                /* in this case we already know the uid and it wouldn't
-                   be in the cache anyway yet */
-                v = lfirst(item);
-            }
-            else
+	AssertState(stmt->action == +1 || stmt->action == -1);
+
+	/*
+	 * Now decide what to do.
+	 */
+	if (stmt->action == +1)		/* add users, might also be invoked by
+								 * create user */
+	{
+		Datum		new_record[Natts_pg_group];
+		char		new_record_nulls[Natts_pg_group] = {' ', ' ', ' '};
+		ArrayType  *newarray,
+				   *oldarray;
+		List	   *newlist = NULL,
+				   *item;
+		HeapTuple	tuple;
+		bool		null = false;
+		Datum		datum = heap_getattr(group_tuple, Anum_pg_group_grolist, pg_group_dsc, &null);
+		int			i;
+
+		oldarray = (ArrayType *) datum;
+		Assert(null || ARR_NDIM(oldarray) == 1);
+		/* first add the old array to the hitherto empty list */
+		if (!null)
+			for (i = ARR_LBOUND(oldarray)[0]; i < ARR_LBOUND(oldarray)[0] + ARR_DIMS(oldarray)[0]; i++)
+			{
+				int			index,
+							arrval;
+				Value	   *v;
+				bool		valueNull;
+
+				index = i;
+				arrval = DatumGetInt32(array_ref(oldarray, 1, &index, true /* by value */ ,
+											sizeof(int), 0, &valueNull));
+				v = makeInteger(arrval);
+				/* filter out duplicates */
+				if (!member(v, newlist))
+					newlist = lcons(v, newlist);
+			}
+
+		/*
+		 * now convert the to be added usernames to sysids and add them to
+		 * the list
+		 */
+		foreach(item, stmt->listUsers)
+		{
+			Value	   *v;
+
+			if (strcmp(tag, "ALTER GROUP") == 0)
+			{
+				/* Get the uid of the proposed user to add. */
+				tuple = SearchSysCacheTuple(SHADOWNAME,
+								   PointerGetDatum(strVal(lfirst(item))),
+											0, 0, 0);
+				if (!HeapTupleIsValid(tuple))
+				{
+					heap_close(pg_group_rel, AccessExclusiveLock);
+					elog(ERROR, "%s: user \"%s\" does not exist", tag, strVal(lfirst(item)));
+				}
+				v = makeInteger(((Form_pg_shadow) GETSTRUCT(tuple))->usesysid);
+			}
+			else if (strcmp(tag, "CREATE USER") == 0)
 			{
-                elog(ERROR, "AlterGroup: unknown tag %s", tag);
+
+				/*
+				 * in this case we already know the uid and it wouldn't be
+				 * in the cache anyway yet
+				 */
+				v = lfirst(item);
+			}
+			else
+			{
+				elog(ERROR, "AlterGroup: unknown tag %s", tag);
 				v = NULL;		/* keep compiler quiet */
 			}
 
-            if (!member(v, newlist))
-                newlist = lcons(v, newlist);
-            else
-                /* we silently assume here that this error will only come up
-                   in a ALTER GROUP statement */
-                elog(NOTICE, "%s: user \"%s\" is already in group \"%s\"", tag, strVal(lfirst(item)), stmt->name);
-        }
-             
-        newarray = palloc(ARR_OVERHEAD(1) + length(newlist) * sizeof(int32));
-        ARR_SIZE(newarray) = ARR_OVERHEAD(1) + length(newlist) * sizeof(int32);
-        ARR_FLAGS(newarray) = 0x0;
-        ARR_NDIM(newarray) = 1; /* one dimensional array */
-        ARR_LBOUND(newarray)[0] = 1; /* axis starts at one */
-        ARR_DIMS(newarray)[0] = length(newlist); /* axis is this long */
-        /* fill the array */
-        i = 0;
-        foreach(item, newlist)
-        {
-            ((int*)ARR_DATA_PTR(newarray))[i++] = intVal(lfirst(item));
-        }
-        
-        /*
-         * Form a tuple with the new array and write it back.
-         */
-        new_record[Anum_pg_group_groname-1] = (Datum)(stmt->name);
-        new_record[Anum_pg_group_grosysid-1] = heap_getattr(group_tuple, Anum_pg_group_grosysid, pg_group_dsc, &null);
-        new_record[Anum_pg_group_grolist-1] = PointerGetDatum(newarray);
-
-        tuple = heap_formtuple(pg_group_dsc, new_record, new_record_nulls);
-        heap_update(pg_group_rel, &group_tuple->t_self, tuple, NULL);
-
-        /* Update indexes */
-        if (RelationGetForm(pg_group_rel)->relhasindex) {
-            Relation idescs[Num_pg_group_indices];
-      
-            CatalogOpenIndices(Num_pg_group_indices, 
-                               Name_pg_group_indices, idescs);
-            CatalogIndexInsert(idescs, Num_pg_group_indices, pg_group_rel, 
-                               tuple);
-            CatalogCloseIndices(Num_pg_group_indices, idescs);
-        }
-    } /* endif alter group add user */
-
-    else if (stmt->action == -1) /*drop users from group */
-    {
-        Datum         datum;
-        bool          null;
-        bool          is_dropuser = strcmp(tag, "DROP USER")==0;
-        
-        datum = heap_getattr(group_tuple, Anum_pg_group_grolist, pg_group_dsc, &null);
-        if (null)
-        {
-            if (!is_dropuser)
-                elog(NOTICE, "ALTER GROUP: group \"%s\" does not have any members", stmt->name);
-        }
-        else
-        {
-            HeapTuple	  tuple;
-            Datum       new_record[Natts_pg_group];
-            char        new_record_nulls[Natts_pg_group] = { ' ', ' ', ' '};
-            ArrayType    *oldarray, *newarray;
-            List * newlist = NULL, *item;
-            int i;
-
-            oldarray = (ArrayType*)datum;
-            Assert(ARR_NDIM(oldarray) == 1);
-            /* first add the old array to the hitherto empty list */
-            for (i = ARR_LBOUND(oldarray)[0]; i < ARR_LBOUND(oldarray)[0] + ARR_DIMS(oldarray)[0]; i++)
-            {
-                int index, arrval;
-                Value *v;
-                bool valueNull;
-                index = i;
-                arrval = DatumGetInt32(array_ref(oldarray, 1, &index, true/*by value*/,
-                                                 sizeof(int), 0, &valueNull));
-                v = makeInteger(arrval);
-                /* filter out duplicates */
-                if (!member(v, newlist))
-                    newlist = lcons(v, newlist);
-            }
-
-            /* 
-             * now convert the to be dropped usernames to sysids and remove
-             * them from the list
-             */
-            foreach(item, stmt->listUsers)
-            {
-                Value *v;
-                if (!is_dropuser)
-                {
-                    /* Get the uid of the proposed user to drop. */
-                    tuple = SearchSysCacheTuple(SHADOWNAME,
-                                                PointerGetDatum(strVal(lfirst(item))),
-                                                0, 0, 0);
-                    if (!HeapTupleIsValid(tuple))
-                    {
-                        heap_close(pg_group_rel, AccessExclusiveLock);
-                        elog(ERROR, "ALTER GROUP: user \"%s\" does not exist", strVal(lfirst(item)));
-                    }
-                    v = makeInteger(((Form_pg_shadow) GETSTRUCT(tuple))->usesysid);
-                }
-                else
-                {
-                    /* for dropuser we already know the uid */
-                    v = lfirst(item);
-                }
-                if (member(v, newlist))
-                    newlist = LispRemove(v, newlist);
-                else if (!is_dropuser)
-                    elog(NOTICE, "ALTER GROUP: user \"%s\" is not in group \"%s\"", strVal(lfirst(item)), stmt->name);
-            }
-
-            newarray = palloc(ARR_OVERHEAD(1) + length(newlist) * sizeof(int32));
-            ARR_SIZE(newarray) = ARR_OVERHEAD(1) + length(newlist) * sizeof(int32);
-            ARR_FLAGS(newarray) = 0x0;
-            ARR_NDIM(newarray) = 1; /* one dimensional array */
-            ARR_LBOUND(newarray)[0] = 1; /* axis starts at one */
-            ARR_DIMS(newarray)[0] = length(newlist); /* axis is this long */
-            /* fill the array */
-            i = 0;
-            foreach(item, newlist)
-            {
-                ((int*)ARR_DATA_PTR(newarray))[i++] = intVal(lfirst(item));
-            }
-        
-            /*
-             * Insert the new tuple with the updated user list
-             */
-            new_record[Anum_pg_group_groname-1] = (Datum)(stmt->name);
-            new_record[Anum_pg_group_grosysid-1] = heap_getattr(group_tuple, Anum_pg_group_grosysid, pg_group_dsc, &null);
-            new_record[Anum_pg_group_grolist-1] = PointerGetDatum(newarray);
-
-            tuple = heap_formtuple(pg_group_dsc, new_record, new_record_nulls);
-            heap_update(pg_group_rel, &group_tuple->t_self, tuple, NULL);
-
-            /* Update indexes */
-            if (RelationGetForm(pg_group_rel)->relhasindex) {
-                Relation idescs[Num_pg_group_indices];
-      
-                CatalogOpenIndices(Num_pg_group_indices, 
-                                   Name_pg_group_indices, idescs);
-                CatalogIndexInsert(idescs, Num_pg_group_indices, pg_group_rel, 
-                                   tuple);
-                CatalogCloseIndices(Num_pg_group_indices, idescs);
-            }
-
-        } /* endif group not null */
-    } /* endif alter group drop user */
-
-    heap_close(pg_group_rel, AccessExclusiveLock);
-
-    pfree(group_tuple);
+			if (!member(v, newlist))
+				newlist = lcons(v, newlist);
+			else
+
+				/*
+				 * we silently assume here that this error will only come
+				 * up in a ALTER GROUP statement
+				 */
+				elog(NOTICE, "%s: user \"%s\" is already in group \"%s\"", tag, strVal(lfirst(item)), stmt->name);
+		}
+
+		newarray = palloc(ARR_OVERHEAD(1) + length(newlist) * sizeof(int32));
+		ARR_SIZE(newarray) = ARR_OVERHEAD(1) + length(newlist) * sizeof(int32);
+		ARR_FLAGS(newarray) = 0x0;
+		ARR_NDIM(newarray) = 1; /* one dimensional array */
+		ARR_LBOUND(newarray)[0] = 1;	/* axis starts at one */
+		ARR_DIMS(newarray)[0] = length(newlist);		/* axis is this long */
+		/* fill the array */
+		i = 0;
+		foreach(item, newlist)
+			((int *) ARR_DATA_PTR(newarray))[i++] = intVal(lfirst(item));
+
+		/*
+		 * Form a tuple with the new array and write it back.
+		 */
+		new_record[Anum_pg_group_groname - 1] = (Datum) (stmt->name);
+		new_record[Anum_pg_group_grosysid - 1] = heap_getattr(group_tuple, Anum_pg_group_grosysid, pg_group_dsc, &null);
+		new_record[Anum_pg_group_grolist - 1] = PointerGetDatum(newarray);
+
+		tuple = heap_formtuple(pg_group_dsc, new_record, new_record_nulls);
+		heap_update(pg_group_rel, &group_tuple->t_self, tuple, NULL);
+
+		/* Update indexes */
+		if (RelationGetForm(pg_group_rel)->relhasindex)
+		{
+			Relation	idescs[Num_pg_group_indices];
+
+			CatalogOpenIndices(Num_pg_group_indices,
+							   Name_pg_group_indices, idescs);
+			CatalogIndexInsert(idescs, Num_pg_group_indices, pg_group_rel,
+							   tuple);
+			CatalogCloseIndices(Num_pg_group_indices, idescs);
+		}
+	}							/* endif alter group add user */
+
+	else if (stmt->action == -1)/* drop users from group */
+	{
+		Datum		datum;
+		bool		null;
+		bool		is_dropuser = strcmp(tag, "DROP USER") == 0;
+
+		datum = heap_getattr(group_tuple, Anum_pg_group_grolist, pg_group_dsc, &null);
+		if (null)
+		{
+			if (!is_dropuser)
+				elog(NOTICE, "ALTER GROUP: group \"%s\" does not have any members", stmt->name);
+		}
+		else
+		{
+			HeapTuple	tuple;
+			Datum		new_record[Natts_pg_group];
+			char		new_record_nulls[Natts_pg_group] = {' ', ' ', ' '};
+			ArrayType  *oldarray,
+					   *newarray;
+			List	   *newlist = NULL,
+					   *item;
+			int			i;
+
+			oldarray = (ArrayType *) datum;
+			Assert(ARR_NDIM(oldarray) == 1);
+			/* first add the old array to the hitherto empty list */
+			for (i = ARR_LBOUND(oldarray)[0]; i < ARR_LBOUND(oldarray)[0] + ARR_DIMS(oldarray)[0]; i++)
+			{
+				int			index,
+							arrval;
+				Value	   *v;
+				bool		valueNull;
+
+				index = i;
+				arrval = DatumGetInt32(array_ref(oldarray, 1, &index, true /* by value */ ,
+											sizeof(int), 0, &valueNull));
+				v = makeInteger(arrval);
+				/* filter out duplicates */
+				if (!member(v, newlist))
+					newlist = lcons(v, newlist);
+			}
+
+			/*
+			 * now convert the to be dropped usernames to sysids and
+			 * remove them from the list
+			 */
+			foreach(item, stmt->listUsers)
+			{
+				Value	   *v;
+
+				if (!is_dropuser)
+				{
+					/* Get the uid of the proposed user to drop. */
+					tuple = SearchSysCacheTuple(SHADOWNAME,
+								   PointerGetDatum(strVal(lfirst(item))),
+												0, 0, 0);
+					if (!HeapTupleIsValid(tuple))
+					{
+						heap_close(pg_group_rel, AccessExclusiveLock);
+						elog(ERROR, "ALTER GROUP: user \"%s\" does not exist", strVal(lfirst(item)));
+					}
+					v = makeInteger(((Form_pg_shadow) GETSTRUCT(tuple))->usesysid);
+				}
+				else
+				{
+					/* for dropuser we already know the uid */
+					v = lfirst(item);
+				}
+				if (member(v, newlist))
+					newlist = LispRemove(v, newlist);
+				else if (!is_dropuser)
+					elog(NOTICE, "ALTER GROUP: user \"%s\" is not in group \"%s\"", strVal(lfirst(item)), stmt->name);
+			}
+
+			newarray = palloc(ARR_OVERHEAD(1) + length(newlist) * sizeof(int32));
+			ARR_SIZE(newarray) = ARR_OVERHEAD(1) + length(newlist) * sizeof(int32);
+			ARR_FLAGS(newarray) = 0x0;
+			ARR_NDIM(newarray) = 1;		/* one dimensional array */
+			ARR_LBOUND(newarray)[0] = 1;		/* axis starts at one */
+			ARR_DIMS(newarray)[0] = length(newlist);	/* axis is this long */
+			/* fill the array */
+			i = 0;
+			foreach(item, newlist)
+				((int *) ARR_DATA_PTR(newarray))[i++] = intVal(lfirst(item));
+
+			/*
+			 * Insert the new tuple with the updated user list
+			 */
+			new_record[Anum_pg_group_groname - 1] = (Datum) (stmt->name);
+			new_record[Anum_pg_group_grosysid - 1] = heap_getattr(group_tuple, Anum_pg_group_grosysid, pg_group_dsc, &null);
+			new_record[Anum_pg_group_grolist - 1] = PointerGetDatum(newarray);
+
+			tuple = heap_formtuple(pg_group_dsc, new_record, new_record_nulls);
+			heap_update(pg_group_rel, &group_tuple->t_self, tuple, NULL);
+
+			/* Update indexes */
+			if (RelationGetForm(pg_group_rel)->relhasindex)
+			{
+				Relation	idescs[Num_pg_group_indices];
+
+				CatalogOpenIndices(Num_pg_group_indices,
+								   Name_pg_group_indices, idescs);
+				CatalogIndexInsert(idescs, Num_pg_group_indices, pg_group_rel,
+								   tuple);
+				CatalogCloseIndices(Num_pg_group_indices, idescs);
+			}
+
+		}						/* endif group not null */
+	}							/* endif alter group drop user */
+
+	heap_close(pg_group_rel, AccessExclusiveLock);
+
+	pfree(group_tuple);
 }
 
 
@@ -1046,52 +1082,52 @@ DropGroup(DropGroupStmt *stmt)
 	Relation	pg_group_rel;
 	HeapScanDesc scan;
 	HeapTuple	tuple;
-    TupleDesc   pg_group_dsc;
-    bool        gro_exists = false;
+	TupleDesc	pg_group_dsc;
+	bool		gro_exists = false;
 
-    /*
+	/*
 	 * Make sure the user can do this.
 	 */
 	if (!superuser())
 		elog(ERROR, "DROP GROUP: permission denied");
 
-    /*
-     * There is not real reason for this, but it makes it consistent
-     * with drop user, and it seems like a good idea anyway.
-     */
+	/*
+	 * There is not real reason for this, but it makes it consistent with
+	 * drop user, and it seems like a good idea anyway.
+	 */
 	if (IsTransactionBlock())
-        elog(ERROR, "DROP GROUP: may not be called in a transaction block");
+		elog(ERROR, "DROP GROUP: may not be called in a transaction block");
 
-    /*
-     * Scan the pg_group table and delete all matching groups.
-     */
+	/*
+	 * Scan the pg_group table and delete all matching groups.
+	 */
 	pg_group_rel = heap_openr(GroupRelationName, AccessExclusiveLock);
 	pg_group_dsc = RelationGetDescr(pg_group_rel);
 	scan = heap_beginscan(pg_group_rel, false, SnapshotNow, 0, NULL);
 
 	while (HeapTupleIsValid(tuple = heap_getnext(scan, false)))
 	{
-        Datum datum;
-        bool null;
-
-        datum = heap_getattr(tuple, Anum_pg_group_groname, pg_group_dsc, &null);
-        if (datum && !null && strcmp((char*)datum, stmt->name)==0)
-        {
-            gro_exists = true;
-            heap_delete(pg_group_rel, &tuple->t_self, NULL);
-        }
+		Datum		datum;
+		bool		null;
+
+		datum = heap_getattr(tuple, Anum_pg_group_groname, pg_group_dsc, &null);
+		if (datum && !null && strcmp((char *) datum, stmt->name) == 0)
+		{
+			gro_exists = true;
+			heap_delete(pg_group_rel, &tuple->t_self, NULL);
+		}
 	}
 
 	heap_endscan(scan);
 
-    /*
-     * Did we find any?
-     */
-    if (!gro_exists)
-    {
-        heap_close(pg_group_rel, AccessExclusiveLock);
+	/*
+	 * Did we find any?
+	 */
+	if (!gro_exists)
+	{
+		heap_close(pg_group_rel, AccessExclusiveLock);
 		elog(ERROR, "DROP GROUP: group \"%s\" does not exist", stmt->name);
-    }
+	}
 
 	heap_close(pg_group_rel, AccessExclusiveLock);
 }
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 5c300c69398935a6333dfbc24ce370fafb4d816b..834438b798651ca181e577b23f72b739aaaad139 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.146 2000/04/06 18:12:07 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.147 2000/04/12 17:14:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -102,15 +102,17 @@ static char *vc_show_rusage(struct rusage * ru0);
 
 /*
  * This routines handle a special cross-transaction portal.
- * However it is automatically closed in case of abort. 
+ * However it is automatically closed in case of abort.
  */
-void CommonSpecialPortalOpen(void)
+void
+CommonSpecialPortalOpen(void)
 {
 	char	   *pname;
 
 
 	if (CommonSpecialPortalInUse)
 		elog(ERROR, "CommonSpecialPortal is in use");
+
 	/*
 	 * Create a portal for safe memory across transactions. We need to
 	 * palloc the name space for it because our hash function expects the
@@ -130,7 +132,8 @@ void CommonSpecialPortalOpen(void)
 	CommonSpecialPortalInUse = true;
 }
 
-void CommonSpecialPortalClose(void)
+void
+CommonSpecialPortalClose(void)
 {
 	/* Clear flag first, to avoid recursion if PortalDrop elog's */
 	CommonSpecialPortalInUse = false;
@@ -141,16 +144,18 @@ void CommonSpecialPortalClose(void)
 	PortalDrop(&vc_portal);
 }
 
-PortalVariableMemory CommonSpecialPortalGetMemory(void)
+PortalVariableMemory
+CommonSpecialPortalGetMemory(void)
 {
 	return PortalGetVariableMemory(vc_portal);
 }
 
-bool CommonSpecialPortalIsOpen(void)
+bool
+CommonSpecialPortalIsOpen(void)
 {
 	return CommonSpecialPortalInUse;
-} 
- 
+}
+
 void
 vacuum(char *vacrel, bool verbose, bool analyze, List *va_spec)
 {
@@ -208,9 +213,9 @@ vacuum(char *vacrel, bool verbose, bool analyze, List *va_spec)
 	 * Start up the vacuum cleaner.
 	 *
 	 * NOTE: since this commits the current transaction, the memory holding
-	 * any passed-in parameters gets freed here.  We must have already copied
-	 * pass-by-reference parameters to safe storage.  Don't make me fix this
-	 * again!
+	 * any passed-in parameters gets freed here.  We must have already
+	 * copied pass-by-reference parameters to safe storage.  Don't make me
+	 * fix this again!
 	 */
 	vc_init();
 
@@ -316,11 +321,12 @@ vc_getrels(NameData *VacRelP)
 
 	if (NameStr(*VacRelP))
 	{
+
 		/*
 		 * we could use the cache here, but it is clearer to use scankeys
 		 * for both vacuum cases, bjm 2000/01/19
 		 */
-		char *nontemp_relname;
+		char	   *nontemp_relname;
 
 		/* We must re-map temp table names bjm 2000-04-06 */
 		if ((nontemp_relname =
@@ -414,7 +420,7 @@ vc_vacone(Oid relid, bool analyze, List *va_cols)
 	int32		nindices,
 				i;
 	VRelStats  *vacrelstats;
-	bool	   reindex = false;
+	bool		reindex = false;
 
 	StartTransactionCommand();
 
@@ -678,7 +684,7 @@ static void
 vc_scanheap(VRelStats *vacrelstats, Relation onerel,
 			VPageList vacuum_pages, VPageList fraged_pages)
 {
-	BlockNumber	nblocks,
+	BlockNumber nblocks,
 				blkno;
 	ItemId		itemid;
 	Buffer		buf;
@@ -1201,7 +1207,7 @@ vc_repair_frag(VRelStats *vacrelstats, Relation onerel,
 				last_vacuum_block = -1;
 			}
 			if (num_fraged_pages > 0 &&
-				fraged_pages->vpl_pagedesc[num_fraged_pages - 1]->vpd_blkno ==
+			fraged_pages->vpl_pagedesc[num_fraged_pages - 1]->vpd_blkno ==
 				(BlockNumber) blkno)
 			{
 				/* page is in fraged_pages too; remove it */
@@ -1456,8 +1462,8 @@ vc_repair_frag(VRelStats *vacrelstats, Relation onerel,
 						 * we stop shrinking here. I could try to find
 						 * real parent row but want not to do it because
 						 * of real solution will be implemented anyway,
-						 * latter, and we are too close to 6.5 release.
-						 * - vadim 06/11/99
+						 * latter, and we are too close to 6.5 release. -
+						 * vadim 06/11/99
 						 */
 						if (Ptp.t_data->t_xmax != tp.t_data->t_xmin)
 						{
@@ -1539,20 +1545,23 @@ vc_repair_frag(VRelStats *vacrelstats, Relation onerel,
 					 * to get t_infomask of inserted heap tuple !!!
 					 */
 					ToPage = BufferGetPage(cur_buffer);
+
 					/*
 					 * If this page was not used before - clean it.
 					 *
 					 * This path is different from the other callers of
 					 * vc_vacpage, because we have already incremented the
 					 * vpd's vpd_offsets_used field to account for the
-					 * tuple(s) we expect to move onto the page.  Therefore
-					 * vc_vacpage's check for vpd_offsets_used == 0 is wrong.
-					 * But since that's a good debugging check for all other
-					 * callers, we work around it here rather than remove it.
+					 * tuple(s) we expect to move onto the page. Therefore
+					 * vc_vacpage's check for vpd_offsets_used == 0 is
+					 * wrong. But since that's a good debugging check for
+					 * all other callers, we work around it here rather
+					 * than remove it.
 					 */
 					if (!PageIsEmpty(ToPage) && vtmove[ti].cleanVpd)
 					{
-						int sv_offsets_used = destvpd->vpd_offsets_used;
+						int			sv_offsets_used = destvpd->vpd_offsets_used;
+
 						destvpd->vpd_offsets_used = 0;
 						vc_vacpage(ToPage, destvpd);
 						destvpd->vpd_offsets_used = sv_offsets_used;
@@ -2267,7 +2276,7 @@ vc_attrstats(Relation onerel, VRelStats *vacrelstats, HeapTuple tuple)
 #ifdef	_DROP_COLUMN_HACK__
 		if (COLUMN_IS_DROPPED(stats->attr))
 			continue;
-#endif	/* _DROP_COLUMN_HACK__ */
+#endif	 /* _DROP_COLUMN_HACK__ */
 		value = heap_getattr(tuple,
 							 stats->attr->attnum, tupDesc, &isnull);
 
diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c
index 6432d3c2b8f7e76ed2a7768c97d1e953a47cd576..367b17aa64c52e3e35373faf17f0795b4f8b7131 100644
--- a/src/backend/commands/variable.c
+++ b/src/backend/commands/variable.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.33 2000/04/07 13:39:24 thomas Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.34 2000/04/12 17:15:00 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -436,7 +436,7 @@ parse_geqo(char *value)
 
 	if (strcasecmp(tok, "on") == 0)
 	{
-		int		new_geqo_rels = GEQO_RELS;
+		int			new_geqo_rels = GEQO_RELS;
 
 		if (val != NULL)
 		{
@@ -505,7 +505,7 @@ static bool
 show_effective_cache_size()
 {
 	elog(NOTICE, "EFFECTIVE_CACHE_SIZE is %g (%dK pages)",
-		 effective_cache_size, BLCKSZ/1024);
+		 effective_cache_size, BLCKSZ / 1024);
 	return TRUE;
 }
 
@@ -656,12 +656,12 @@ reset_cpu_operator_cost()
  * DATE_STYLE
  *
  * NOTE: set_default_datestyle() is called during backend startup to check
- * if the PGDATESTYLE environment variable is set.  We want the env var
+ * if the PGDATESTYLE environment variable is set.	We want the env var
  * to determine the value that "RESET DateStyle" will reset to!
  */
 
 /* These get initialized from the "master" values in init/globals.c */
-static int DefaultDateStyle;
+static int	DefaultDateStyle;
 static bool DefaultEuroDates;
 
 static bool
@@ -777,8 +777,9 @@ set_default_datestyle(void)
 {
 	char	   *DBDate;
 
-	/* Initialize from compile-time defaults in init/globals.c.
-	 * NB: this is a necessary step; consider PGDATESTYLE="DEFAULT".
+	/*
+	 * Initialize from compile-time defaults in init/globals.c. NB: this
+	 * is a necessary step; consider PGDATESTYLE="DEFAULT".
 	 */
 	DefaultDateStyle = DateStyle;
 	DefaultEuroDates = EuroDates;
@@ -788,9 +789,11 @@ set_default_datestyle(void)
 	if (DBDate == NULL)
 		return;
 
-	/* Make a modifiable copy --- overwriting the env var doesn't seem
+	/*
+	 * Make a modifiable copy --- overwriting the env var doesn't seem
 	 * like a good idea, even though we currently won't look at it again.
-	 * Note that we cannot use palloc at this early stage of initialization.
+	 * Note that we cannot use palloc at this early stage of
+	 * initialization.
 	 */
 	DBDate = strdup(DBDate);
 
@@ -1041,9 +1044,8 @@ reset_XactIsoLevel()
 static bool
 parse_pg_options(char *value)
 {
-	if (!superuser()) {
+	if (!superuser())
 		elog(ERROR, "Only users with superuser privilege can set pg_options");
-	}
 	if (value == NULL)
 		read_pg_options(0);
 	else
@@ -1061,9 +1063,8 @@ show_pg_options(void)
 static bool
 reset_pg_options(void)
 {
-	if (!superuser()) {
+	if (!superuser())
 		elog(ERROR, "Only users with superuser privilege can set pg_options");
-	}
 	read_pg_options(0);
 	return (TRUE);
 }
@@ -1075,7 +1076,7 @@ reset_pg_options(void)
 static bool
 parse_random_seed(char *value)
 {
-	double seed = 0;
+	double		seed = 0;
 
 	if (value == NULL)
 		reset_random_seed();
@@ -1097,7 +1098,7 @@ show_random_seed(void)
 static bool
 reset_random_seed(void)
 {
-	double seed = 0.5;
+	double		seed = 0.5;
 
 	setseed(&seed);
 	return (TRUE);
diff --git a/src/backend/executor/execAmi.c b/src/backend/executor/execAmi.c
index cdde7c198015fed2b1e18005d2ee76d19b80c892..579465bf0b8916d11842e8c611319e602ebf709d 100644
--- a/src/backend/executor/execAmi.c
+++ b/src/backend/executor/execAmi.c
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- *	$Id: execAmi.c,v 1.45 2000/01/26 05:56:21 momjian Exp $
+ *	$Id: execAmi.c,v 1.46 2000/04/12 17:15:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -235,9 +235,10 @@ ExecCloseR(Plan *node)
 		heap_endscan(scanDesc);
 
 	/*
-	 * endscan released AccessShareLock acquired by beginscan.  If we are
-	 * holding any stronger locks on the rel, they should be held till end of
-	 * xact.  Therefore, we need only close the rel and not release locks.
+	 * endscan released AccessShareLock acquired by beginscan.	If we are
+	 * holding any stronger locks on the rel, they should be held till end
+	 * of xact.  Therefore, we need only close the rel and not release
+	 * locks.
 	 */
 	if (relation != NULL)
 		heap_close(relation, NoLock);
@@ -423,7 +424,7 @@ ExecMarkPos(Plan *node)
 {
 	switch (nodeTag(node))
 	{
-		case T_SeqScan:
+			case T_SeqScan:
 			ExecSeqMarkPos((SeqScan *) node);
 			break;
 
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index bbcba0fbc12c7db2f78001d2082856ab5db4e2aa..c879417baf6df0eeb887acc55325397700ae46e8 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -27,7 +27,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.112 2000/04/07 07:24:47 vadim Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.113 2000/04/12 17:15:08 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -48,7 +48,7 @@
 
 /* XXX no points for style */
 extern TupleTableSlot *EvalPlanQual(EState *estate, Index rti,
-									ItemPointer tid);
+			 ItemPointer tid);
 
 /* decls for local routines only used within this module */
 static TupleDesc InitPlan(CmdType operation,
@@ -75,13 +75,14 @@ static void ExecReplace(TupleTableSlot *slot, ItemPointer tupleid,
 static TupleTableSlot *EvalPlanQualNext(EState *estate);
 static void EndEvalPlanQual(EState *estate);
 static void ExecCheckQueryPerms(CmdType operation, Query *parseTree,
-								Plan *plan);
+					Plan *plan);
 static void ExecCheckPlanPerms(Plan *plan, CmdType operation,
-							   int resultRelation, bool resultIsScanned);
+				   int resultRelation, bool resultIsScanned);
 static void ExecCheckRTPerms(List *rangeTable, CmdType operation,
-							 int resultRelation, bool resultIsScanned);
+				 int resultRelation, bool resultIsScanned);
 static void ExecCheckRTEPerms(RangeTblEntry *rte, CmdType operation,
-							  bool isResultRelation, bool resultIsScanned);
+				  bool isResultRelation, bool resultIsScanned);
+
 /* end of local decls */
 
 
@@ -460,14 +461,14 @@ ExecCheckPlanPerms(Plan *plan, CmdType operation,
 
 	foreach(subp, plan->initPlan)
 	{
-		SubPlan	   *subplan = (SubPlan *) lfirst(subp);
+		SubPlan    *subplan = (SubPlan *) lfirst(subp);
 
 		ExecCheckRTPerms(subplan->rtable, CMD_SELECT, 0, false);
 		ExecCheckPlanPerms(subplan->plan, CMD_SELECT, 0, false);
 	}
 	foreach(subp, plan->subPlan)
 	{
-		SubPlan	   *subplan = (SubPlan *) lfirst(subp);
+		SubPlan    *subplan = (SubPlan *) lfirst(subp);
 
 		ExecCheckRTPerms(subplan->rtable, CMD_SELECT, 0, false);
 		ExecCheckPlanPerms(subplan->plan, CMD_SELECT, 0, false);
@@ -485,49 +486,51 @@ ExecCheckPlanPerms(Plan *plan, CmdType operation,
 	switch (nodeTag(plan))
 	{
 		case T_Append:
-		{
-			Append	   *app = (Append *) plan;
-			List	   *appendplans;
-
-			if (app->inheritrelid > 0)
 			{
-				/*
-				 * Append implements expansion of inheritance; all members
-				 * of inheritrtable list will be plugged into same RTE slot.
-				 * Therefore, they are either all result relations or none.
-				 */
-				List	   *rtable;
+				Append	   *app = (Append *) plan;
+				List	   *appendplans;
 
-				foreach(rtable, app->inheritrtable)
+				if (app->inheritrelid > 0)
 				{
-					ExecCheckRTEPerms((RangeTblEntry *) lfirst(rtable),
-									  operation,
-									  (app->inheritrelid == resultRelation),
-									  resultIsScanned);
-				}
-			}
-			else
-			{
-				/* Append implements UNION, which must be a SELECT */
-				List	   *rtables;
 
-				foreach(rtables, app->unionrtables)
+					/*
+					 * Append implements expansion of inheritance; all
+					 * members of inheritrtable list will be plugged into
+					 * same RTE slot. Therefore, they are either all
+					 * result relations or none.
+					 */
+					List	   *rtable;
+
+					foreach(rtable, app->inheritrtable)
+					{
+						ExecCheckRTEPerms((RangeTblEntry *) lfirst(rtable),
+										  operation,
+								   (app->inheritrelid == resultRelation),
+										  resultIsScanned);
+					}
+				}
+				else
 				{
-					ExecCheckRTPerms((List *) lfirst(rtables),
-									 CMD_SELECT, 0, false);
+					/* Append implements UNION, which must be a SELECT */
+					List	   *rtables;
+
+					foreach(rtables, app->unionrtables)
+					{
+						ExecCheckRTPerms((List *) lfirst(rtables),
+										 CMD_SELECT, 0, false);
+					}
 				}
-			}
 
-			/* Check appended plans */
-			foreach(appendplans, app->appendplans)
-			{
-				ExecCheckPlanPerms((Plan *) lfirst(appendplans),
-								   operation,
-								   resultRelation,
-								   resultIsScanned);
+				/* Check appended plans */
+				foreach(appendplans, app->appendplans)
+				{
+					ExecCheckPlanPerms((Plan *) lfirst(appendplans),
+									   operation,
+									   resultRelation,
+									   resultIsScanned);
+				}
+				break;
 			}
-			break;
-		}
 
 		default:
 			break;
@@ -539,7 +542,7 @@ ExecCheckPlanPerms(Plan *plan, CmdType operation,
  *		Check access permissions for all relations listed in a range table.
  *
  * If resultRelation is not 0, it is the RT index of the relation to be
- * treated as the result relation.  All other relations are assumed to be
+ * treated as the result relation.	All other relations are assumed to be
  * read-only for the query.
  */
 static void
@@ -576,10 +579,11 @@ ExecCheckRTEPerms(RangeTblEntry *rte, CmdType operation,
 
 	if (rte->skipAcl)
 	{
+
 		/*
-		 * This happens if the access to this table is due to a view
-		 * query rewriting - the rewrite handler already checked the
-		 * permissions against the view owner, so we just skip this entry.
+		 * This happens if the access to this table is due to a view query
+		 * rewriting - the rewrite handler already checked the permissions
+		 * against the view owner, so we just skip this entry.
 		 */
 		return;
 	}
@@ -620,14 +624,12 @@ ExecCheckRTEPerms(RangeTblEntry *rte, CmdType operation,
 			default:
 				elog(ERROR, "ExecCheckRTEPerms: bogus operation %d",
 					 operation);
-				aclcheck_result = ACLCHECK_OK; /* keep compiler quiet */
+				aclcheck_result = ACLCHECK_OK;	/* keep compiler quiet */
 				break;
 		}
 	}
 	else
-	{
 		aclcheck_result = CHECK(ACL_RD);
-	}
 
 	if (aclcheck_result != ACLCHECK_OK)
 		elog(ERROR, "%s: %s",
@@ -734,8 +736,9 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate)
 		/*
 		 * If there are indices on the result relation, open them and save
 		 * descriptors in the result relation info, so that we can add new
-		 * index entries for the tuples we add/update.  We need not do this
-		 * for a DELETE, however, since deletion doesn't affect indexes.
+		 * index entries for the tuples we add/update.	We need not do
+		 * this for a DELETE, however, since deletion doesn't affect
+		 * indexes.
 		 */
 		if (resultRelationDesc->rd_rel->relhasindex &&
 			operation != CMD_DELETE)
@@ -805,10 +808,11 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate)
 	targetList = plan->targetlist;
 
 	/*
-	 * Now that we have the target list, initialize the junk filter if needed.
-	 * SELECT and INSERT queries need a filter if there are any junk attrs
-	 * in the tlist.  UPDATE and DELETE always need one, since there's always
-	 * a junk 'ctid' attribute present --- no need to look first.
+	 * Now that we have the target list, initialize the junk filter if
+	 * needed. SELECT and INSERT queries need a filter if there are any
+	 * junk attrs in the tlist.  UPDATE and DELETE always need one, since
+	 * there's always a junk 'ctid' attribute present --- no need to look
+	 * first.
 	 */
 	{
 		bool		junk_filter_needed = false;
@@ -948,8 +952,8 @@ EndPlan(Plan *plan, EState *estate)
 	}
 
 	/*
-	 * close the result relations if necessary,
-	 * but hold locks on them until xact commit
+	 * close the result relations if necessary, but hold locks on them
+	 * until xact commit
 	 */
 	if (resultRelationInfo != NULL)
 	{
@@ -1708,10 +1712,10 @@ ExecRelCheck(Relation rel, HeapTuple tuple, EState *estate)
 
 		/*
 		 * NOTE: SQL92 specifies that a NULL result from a constraint
-		 * expression is not to be treated as a failure.  Therefore,
-		 * tell ExecQual to return TRUE for NULL.
+		 * expression is not to be treated as a failure.  Therefore, tell
+		 * ExecQual to return TRUE for NULL.
 		 */
-		if (! ExecQual(qual, econtext, true))
+		if (!ExecQual(qual, econtext, true))
 			return check[i].ccname;
 	}
 
@@ -1738,7 +1742,7 @@ ExecConstraints(char *caller, Relation rel, HeapTuple tuple, EState *estate)
 		{
 			if (rel->rd_att->attrs[attrChk - 1]->attnotnull && heap_attisnull(tuple, attrChk))
 				elog(ERROR, "%s: Fail to add null value in not null attribute %s",
-				  caller, NameStr(rel->rd_att->attrs[attrChk - 1]->attname));
+					 caller, NameStr(rel->rd_att->attrs[attrChk - 1]->attname));
 		}
 	}
 
@@ -1791,7 +1795,7 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid)
 			Assert(oldepq->rti != 0);
 			/* stop execution */
 			ExecEndNode(epq->plan, epq->plan);
-		    epqstate->es_tupleTable->next = 0;
+			epqstate->es_tupleTable->next = 0;
 			heap_freetuple(epqstate->es_evTuple[epq->rti - 1]);
 			epqstate->es_evTuple[epq->rti - 1] = NULL;
 			/* push current PQ to freePQ stack */
@@ -1861,7 +1865,7 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid)
 	if (endNode)
 	{
 		ExecEndNode(epq->plan, epq->plan);
-	    epqstate->es_tupleTable->next = 0;
+		epqstate->es_tupleTable->next = 0;
 	}
 
 	/* free old RTE' tuple */
@@ -1949,10 +1953,10 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid)
 			estate->es_evalPlanQual = (Pointer) epq;
 		}
 		else
-		{									
-			epq->rti = 0;					/* this is the first (oldest) */
-			estate->es_useEvalPlan = false;	/* PQ - mark as free and      */
-			return (NULL);					/* continue Query execution   */
+		{
+			epq->rti = 0;		/* this is the first (oldest) */
+			estate->es_useEvalPlan = false;		/* PQ - mark as free and	  */
+			return (NULL);		/* continue Query execution   */
 		}
 	}
 
@@ -1961,7 +1965,7 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid)
 			   estate->es_origPlan->nParamExec * sizeof(ParamExecData));
 	memset(epqstate->es_evTupleNull, false,
 		   length(estate->es_range_table) * sizeof(bool));
-    Assert(epqstate->es_tupleTable->next == 0);
+	Assert(epqstate->es_tupleTable->next == 0);
 	ExecInitNode(epq->plan, epqstate, NULL);
 
 	/*
@@ -1992,16 +1996,16 @@ lpqnext:;
 	if (TupIsNull(slot))
 	{
 		ExecEndNode(epq->plan, epq->plan);
-	    epqstate->es_tupleTable->next = 0;
+		epqstate->es_tupleTable->next = 0;
 		heap_freetuple(epqstate->es_evTuple[epq->rti - 1]);
 		epqstate->es_evTuple[epq->rti - 1] = NULL;
 		/* pop old PQ from the stack */
 		oldepq = (evalPlanQual *) epqstate->es_evalPlanQual;
 		if (oldepq == (evalPlanQual *) NULL)
 		{
-			epq->rti = 0;					/* this is the first (oldest) */
-			estate->es_useEvalPlan = false;	/* PQ - mark as free and	  */
-			return (NULL);					/* continue Query execution   */
+			epq->rti = 0;		/* this is the first (oldest) */
+			estate->es_useEvalPlan = false;		/* PQ - mark as free and	  */
+			return (NULL);		/* continue Query execution   */
 		}
 		Assert(oldepq->rti != 0);
 		/* push current PQ to freePQ stack */
@@ -2031,7 +2035,7 @@ EndEvalPlanQual(EState *estate)
 	for (;;)
 	{
 		ExecEndNode(epq->plan, epq->plan);
-	    epqstate->es_tupleTable->next = 0;
+		epqstate->es_tupleTable->next = 0;
 		if (epqstate->es_evTuple[epq->rti - 1] != NULL)
 		{
 			heap_freetuple(epqstate->es_evTuple[epq->rti - 1]);
@@ -2041,8 +2045,8 @@ EndEvalPlanQual(EState *estate)
 		oldepq = (evalPlanQual *) epqstate->es_evalPlanQual;
 		if (oldepq == (evalPlanQual *) NULL)
 		{
-			epq->rti = 0;					/* this is the first (oldest) */
-			estate->es_useEvalPlan = false;	/* PQ - mark as free */
+			epq->rti = 0;		/* this is the first (oldest) */
+			estate->es_useEvalPlan = false;		/* PQ - mark as free */
 			break;
 		}
 		Assert(oldepq->rti != 0);
diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c
index a319e2c2b37c678624d6b66f167765eec752c282..58307e6a695e15568eb1f72b20f64a3c2e632dee 100644
--- a/src/backend/executor/execQual.c
+++ b/src/backend/executor/execQual.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.68 2000/02/20 21:32:04 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.69 2000/04/12 17:15:08 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -108,12 +108,14 @@ ExecEvalArrayRef(ArrayRef *arrayRef,
 	}
 	else
 	{
-		/* Null refexpr indicates we are doing an INSERT into an array column.
-		 * For now, we just take the refassgnexpr (which the parser will have
-		 * ensured is an array value) and return it as-is, ignoring any
-		 * subscripts that may have been supplied in the INSERT column list.
-		 * This is a kluge, but it's not real clear what the semantics ought
-		 * to be...
+
+		/*
+		 * Null refexpr indicates we are doing an INSERT into an array
+		 * column. For now, we just take the refassgnexpr (which the
+		 * parser will have ensured is an array value) and return it
+		 * as-is, ignoring any subscripts that may have been supplied in
+		 * the INSERT column list. This is a kluge, but it's not real
+		 * clear what the semantics ought to be...
 		 */
 		array_scanner = NULL;
 	}
@@ -153,16 +155,15 @@ ExecEvalArrayRef(ArrayRef *arrayRef,
 		lIndex = lower.indx;
 	}
 	else
-	{
 		lIndex = NULL;
-	}
 
 	if (arrayRef->refassgnexpr != NULL)
 	{
-		Datum sourceData = ExecEvalExpr(arrayRef->refassgnexpr,
-										econtext,
-										isNull,
-										&dummy);
+		Datum		sourceData = ExecEvalExpr(arrayRef->refassgnexpr,
+											  econtext,
+											  isNull,
+											  &dummy);
+
 		if (*isNull)
 			return (Datum) NULL;
 
@@ -209,7 +210,7 @@ ExecEvalArrayRef(ArrayRef *arrayRef,
 static Datum
 ExecEvalAggref(Aggref *aggref, ExprContext *econtext, bool *isNull)
 {
-	if (econtext->ecxt_aggvalues == NULL) /* safety check */
+	if (econtext->ecxt_aggvalues == NULL)		/* safety check */
 		elog(ERROR, "ExecEvalAggref: no aggregates in this expression context");
 
 	*isNull = econtext->ecxt_aggnulls[aggref->aggno];
@@ -281,7 +282,7 @@ ExecEvalVar(Var *variable, ExprContext *econtext, bool *isNull)
 	Assert(attnum <= 0 ||
 		   (attnum - 1 <= tuple_type->natts - 1 &&
 			tuple_type->attrs[attnum - 1] != NULL &&
-			variable->vartype == tuple_type->attrs[attnum - 1]->atttypid));
+		  variable->vartype == tuple_type->attrs[attnum - 1]->atttypid));
 
 	/*
 	 * If the attribute number is invalid, then we are supposed to return
@@ -633,7 +634,7 @@ ExecEvalFuncArgs(FunctionCachePtr fcache,
 		 */
 		argV[i] = ExecEvalExpr((Node *) lfirst(arg),
 							   econtext,
-							   & nullVect[i],
+							   &nullVect[i],
 							   argIsDone);
 
 		if (!(*argIsDone))
@@ -779,9 +780,9 @@ ExecMakeFunctionResult(Node *node,
 			result = postquel_function(funcNode, (char **) argV,
 									   isNull, isDone);
 
-			if (! *isDone)
+			if (!*isDone)
 				break;			/* got a result from current argument */
-			if (! fcache->hasSetArg)
+			if (!fcache->hasSetArg)
 				break;			/* input not a set, so done */
 
 			/* OK, get the next argument... */
@@ -789,7 +790,11 @@ ExecMakeFunctionResult(Node *node,
 
 			if (argDone)
 			{
-				/* End of arguments, so reset the setArg flag and say "Done" */
+
+				/*
+				 * End of arguments, so reset the setArg flag and say
+				 * "Done"
+				 */
 				fcache->setArg = (char *) NULL;
 				fcache->hasSetArg = false;
 				*isDone = true;
@@ -797,7 +802,8 @@ ExecMakeFunctionResult(Node *node,
 				break;
 			}
 
-			/* If we reach here, loop around to run the function on the
+			/*
+			 * If we reach here, loop around to run the function on the
 			 * new argument.
 			 */
 		}
@@ -1003,20 +1009,22 @@ ExecEvalOr(Expr *orExpr, ExprContext *econtext, bool *isNull)
 	AnyNull = false;
 
 	/*
-	 * If any of the clauses is TRUE, the OR result is TRUE regardless
-	 * of the states of the rest of the clauses, so we can stop evaluating
+	 * If any of the clauses is TRUE, the OR result is TRUE regardless of
+	 * the states of the rest of the clauses, so we can stop evaluating
 	 * and return TRUE immediately.  If none are TRUE and one or more is
 	 * NULL, we return NULL; otherwise we return FALSE.  This makes sense
 	 * when you interpret NULL as "don't know": if we have a TRUE then the
 	 * OR is TRUE even if we aren't sure about some of the other inputs.
 	 * If all the known inputs are FALSE, but we have one or more "don't
 	 * knows", then we have to report that we "don't know" what the OR's
-	 * result should be --- perhaps one of the "don't knows" would have been
-	 * TRUE if we'd known its value.  Only when all the inputs are known
-	 * to be FALSE can we state confidently that the OR's result is FALSE.
+	 * result should be --- perhaps one of the "don't knows" would have
+	 * been TRUE if we'd known its value.  Only when all the inputs are
+	 * known to be FALSE can we state confidently that the OR's result is
+	 * FALSE.
 	 */
 	foreach(clause, clauses)
 	{
+
 		/*
 		 * We don't iterate over sets in the quals, so pass in an isDone
 		 * flag, but ignore it.
@@ -1025,6 +1033,7 @@ ExecEvalOr(Expr *orExpr, ExprContext *econtext, bool *isNull)
 									econtext,
 									isNull,
 									&isDone);
+
 		/*
 		 * if we have a non-null true result, then return it.
 		 */
@@ -1059,12 +1068,13 @@ ExecEvalAnd(Expr *andExpr, ExprContext *econtext, bool *isNull)
 	 * If any of the clauses is FALSE, the AND result is FALSE regardless
 	 * of the states of the rest of the clauses, so we can stop evaluating
 	 * and return FALSE immediately.  If none are FALSE and one or more is
-	 * NULL, we return NULL; otherwise we return TRUE.  This makes sense
+	 * NULL, we return NULL; otherwise we return TRUE.	This makes sense
 	 * when you interpret NULL as "don't know", using the same sort of
 	 * reasoning as for OR, above.
 	 */
 	foreach(clause, clauses)
 	{
+
 		/*
 		 * We don't iterate over sets in the quals, so pass in an isDone
 		 * flag, but ignore it.
@@ -1073,6 +1083,7 @@ ExecEvalAnd(Expr *andExpr, ExprContext *econtext, bool *isNull)
 									econtext,
 									isNull,
 									&isDone);
+
 		/*
 		 * if we have a non-null false result, then return it.
 		 */
@@ -1084,7 +1095,7 @@ ExecEvalAnd(Expr *andExpr, ExprContext *econtext, bool *isNull)
 
 	/* AnyNull is true if at least one clause evaluated to NULL */
 	*isNull = AnyNull;
-	return (Datum) (! AnyNull);
+	return (Datum) (!AnyNull);
 }
 
 /* ----------------------------------------------------------------
@@ -1129,7 +1140,7 @@ ExecEvalCase(CaseExpr *caseExpr, ExprContext *econtext, bool *isNull)
 		 * case statement is satisfied.  A NULL result from the test is
 		 * not considered true.
 		 */
-		if (DatumGetInt32(clause_value) != 0 && ! *isNull)
+		if (DatumGetInt32(clause_value) != 0 && !*isNull)
 		{
 			return ExecEvalExpr(wclause->result,
 								econtext,
@@ -1258,7 +1269,7 @@ ExecEvalExpr(Node *expression,
 					default:
 						elog(ERROR, "ExecEvalExpr: unknown expression type %d",
 							 expr->opType);
-						retDatum = 0; /* keep compiler quiet */
+						retDatum = 0;	/* keep compiler quiet */
 						break;
 				}
 				break;
@@ -1332,7 +1343,7 @@ ExecQual(List *qual, ExprContext *econtext, bool resultForNull)
 	IncrProcessed();
 
 	/*
-	 * Evaluate the qual conditions one at a time.  If we find a FALSE
+	 * Evaluate the qual conditions one at a time.	If we find a FALSE
 	 * result, we can stop evaluating and return FALSE --- the AND result
 	 * must be FALSE.  Also, if we find a NULL result when resultForNull
 	 * is FALSE, we can stop and return FALSE --- the AND result must be
@@ -1353,14 +1364,15 @@ ExecQual(List *qual, ExprContext *econtext, bool resultForNull)
 
 		/*
 		 * If there is a null clause, consider the qualification to fail.
-		 * XXX is this still correct for constraints?  It probably shouldn't
-		 * happen at all ...
+		 * XXX is this still correct for constraints?  It probably
+		 * shouldn't happen at all ...
 		 */
 		if (clause == NULL)
 			return false;
+
 		/*
-		 * pass isDone, but ignore it.	We don't iterate over multiple returns
-		 * in the qualifications.
+		 * pass isDone, but ignore it.	We don't iterate over multiple
+		 * returns in the qualifications.
 		 */
 		expr_value = ExecEvalExpr(clause, econtext, &isNull, &isDone);
 
@@ -1429,7 +1441,8 @@ ExecTargetList(List *targetlist,
 	HeapTuple	newTuple;
 	bool		isNull;
 	bool		haveDoneIters;
-	static struct tupleDesc NullTupleDesc; /* we assume this inits to zeroes */
+	static struct tupleDesc NullTupleDesc;		/* we assume this inits to
+												 * zeroes */
 
 	/*
 	 * debugging stuff
@@ -1512,7 +1525,8 @@ ExecTargetList(List *targetlist,
 				if (itemIsDone[resind])
 					haveDoneIters = true;
 				else
-					*isDone = false; /* we have undone Iters in the list */
+					*isDone = false;	/* we have undone Iters in the
+										 * list */
 			}
 		}
 		else
@@ -1571,7 +1585,9 @@ ExecTargetList(List *targetlist,
 	{
 		if (*isDone)
 		{
-			/* all Iters are done, so return a null indicating tlist set
+
+			/*
+			 * all Iters are done, so return a null indicating tlist set
 			 * expansion is complete.
 			 */
 			newTuple = NULL;
@@ -1579,21 +1595,24 @@ ExecTargetList(List *targetlist,
 		}
 		else
 		{
-			/* We have some done and some undone Iters.  Restart the done ones
-			 * so that we can deliver a tuple (if possible).
+
+			/*
+			 * We have some done and some undone Iters.  Restart the done
+			 * ones so that we can deliver a tuple (if possible).
 			 *
 			 * XXX this code is a crock, because it only works for Iters at
-			 * the top level of tlist expressions, and doesn't even work right
-			 * for them: you should get all possible combinations of Iter
-			 * results, but you won't unless the numbers of values returned by
-			 * each are relatively prime.  Should have a mechanism more like
-			 * aggregate functions, where we make a list of all Iters
-			 * contained in the tlist and cycle through their values in a
-			 * methodical fashion.  To do someday; can't get excited about
-			 * fixing a Berkeley feature that's not in SQL92.  (The only
-			 * reason we're doing this much is that we have to be sure all
-			 * the Iters are run to completion, or their subplan executors
-			 * will have unreleased resources, e.g. pinned buffers...)
+			 * the top level of tlist expressions, and doesn't even work
+			 * right for them: you should get all possible combinations of
+			 * Iter results, but you won't unless the numbers of values
+			 * returned by each are relatively prime.  Should have a
+			 * mechanism more like aggregate functions, where we make a
+			 * list of all Iters contained in the tlist and cycle through
+			 * their values in a methodical fashion.  To do someday; can't
+			 * get excited about fixing a Berkeley feature that's not in
+			 * SQL92.  (The only reason we're doing this much is that we
+			 * have to be sure all the Iters are run to completion, or
+			 * their subplan executors will have unreleased resources,
+			 * e.g. pinned buffers...)
 			 */
 			foreach(tl, targetlist)
 			{
@@ -1605,16 +1624,18 @@ ExecTargetList(List *targetlist,
 					resdom = tle->resdom;
 					resind = resdom->resno - 1;
 
-					if (IsA(expr, Iter) && itemIsDone[resind])
+					if (IsA(expr, Iter) &&itemIsDone[resind])
 					{
 						constvalue = (Datum) ExecEvalExpr(expr,
 														  econtext,
 														  &isNull,
-														  &itemIsDone[resind]);
+													&itemIsDone[resind]);
 						if (itemIsDone[resind])
 						{
-							/* Oh dear, this Iter is returning an empty set.
-							 * Guess we can't make a tuple after all.
+
+							/*
+							 * Oh dear, this Iter is returning an empty
+							 * set. Guess we can't make a tuple after all.
 							 */
 							*isDone = true;
 							newTuple = NULL;
@@ -1639,6 +1660,7 @@ ExecTargetList(List *targetlist,
 	newTuple = (HeapTuple) heap_formtuple(targettype, values, null_head);
 
 exit:
+
 	/*
 	 * free the status arrays if we palloc'd them
 	 */
diff --git a/src/backend/executor/execTuples.c b/src/backend/executor/execTuples.c
index 1cbae3519a9e24ee6721206a64ce68cbe4b745f0..578b8b806812a15bd9f7abaec82cf8a0ce57f7c9 100644
--- a/src/backend/executor/execTuples.c
+++ b/src/backend/executor/execTuples.c
@@ -15,7 +15,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.36 2000/01/27 18:11:27 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.37 2000/04/12 17:15:08 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -188,8 +188,8 @@ ExecCreateTupleTable(int initialSize)	/* initial number of slots in
  * --------------------------------
  */
 void
-ExecDropTupleTable(TupleTable table, /* tuple table */
-					  bool shouldFree)	/* true if we should free slot
+ExecDropTupleTable(TupleTable table,	/* tuple table */
+				   bool shouldFree)		/* true if we should free slot
 										 * contents */
 {
 	int			next;			/* next available slot */
@@ -262,7 +262,7 @@ TupleTableSlot *				/* return: the slot allocated in the tuple
 ExecAllocTableSlot(TupleTable table)
 {
 	int			slotnum;		/* new slot number */
-	TupleTableSlot*   slot;
+	TupleTableSlot *slot;
 
 	/* ----------------
 	 *	sanity checks
@@ -335,8 +335,8 @@ ExecAllocTableSlot(TupleTable table)
  *
  *		tuple:	tuple to store
  *		slot:	slot to store it in
- *		buffer:	disk buffer if tuple is in a disk page, else InvalidBuffer
- *		shouldFree:	true if ExecClearTuple should pfree() the tuple
+ *		buffer: disk buffer if tuple is in a disk page, else InvalidBuffer
+ *		shouldFree: true if ExecClearTuple should pfree() the tuple
  *					when done with it
  *
  * If 'buffer' is not InvalidBuffer, the tuple table code acquires a pin
@@ -350,7 +350,7 @@ ExecAllocTableSlot(TupleTable table)
  * Another case where it is 'false' is when the referenced tuple is held
  * in a tuple table slot belonging to a lower-level executor Proc node.
  * In this case the lower-level slot retains ownership and responsibility
- * for eventually releasing the tuple.  When this method is used, we must
+ * for eventually releasing the tuple.	When this method is used, we must
  * be certain that the upper-level Proc node will lose interest in the tuple
  * sooner than the lower-level one does!  If you're not certain, copy the
  * lower-level tuple with heap_copytuple and let the upper-level table
@@ -385,7 +385,8 @@ ExecStoreTuple(HeapTuple tuple,
 	slot->ttc_buffer = buffer;
 	slot->ttc_shouldFree = shouldFree;
 
-	/* If tuple is on a disk page, keep the page pinned as long as we hold
+	/*
+	 * If tuple is on a disk page, keep the page pinned as long as we hold
 	 * a pointer into it.
 	 */
 	if (BufferIsValid(buffer))
@@ -426,7 +427,7 @@ ExecClearTuple(TupleTableSlot *slot)	/* slot in which to store tuple */
 
 	slot->val = (HeapTuple) NULL;
 
-	slot->ttc_shouldFree = true; /* probably useless code... */
+	slot->ttc_shouldFree = true;/* probably useless code... */
 
 	/* ----------------
 	 *	Drop the pin on the referenced buffer, if there is one.
@@ -776,6 +777,7 @@ NodeGetResultTupleSlot(Plan *node)
 		case T_TidScan:
 			{
 				CommonScanState *scanstate = ((IndexScan *) node)->scan.scanstate;
+
 				slot = scanstate->cstate.cs_ResultTupleSlot;
 			}
 			break;
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c
index 8f15ac1ed180b18493ecb850d2bf5c9c47fa8a55..e3783473f96efdc98717e7257b276c437841a41f 100644
--- a/src/backend/executor/execUtils.c
+++ b/src/backend/executor/execUtils.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.54 2000/02/18 09:29:57 inoue Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.55 2000/04/12 17:15:08 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -776,7 +776,7 @@ ExecOpenIndices(Oid resultRelationOid,
 	if (!RelationGetForm(resultRelationInfo->ri_RelationDesc)->relhasindex)
 		return;
 	if (IsIgnoringSystemIndexes() &&
-	    IsSystemRelationName(RelationGetRelationName(resultRelationInfo->ri_RelationDesc)))
+		IsSystemRelationName(RelationGetRelationName(resultRelationInfo->ri_RelationDesc)))
 		return;
 	/* ----------------
 	 *	open pg_index
@@ -923,8 +923,8 @@ ExecOpenIndices(Oid resultRelationOid,
 
 				/*
 				 * Hack for not btree and hash indices: they use relation
-				 * level exclusive locking on update (i.e. - they are
-				 * not ready for MVCC) and so we have to exclusively lock
+				 * level exclusive locking on update (i.e. - they are not
+				 * ready for MVCC) and so we have to exclusively lock
 				 * indices here to prevent deadlocks if we will scan them
 				 * - index_beginscan places AccessShareLock, indices
 				 * update methods don't use locks at all. We release this
@@ -1186,7 +1186,7 @@ ExecInsertIndexTuples(TupleTableSlot *slot,
 			econtext->ecxt_scantuple = slot;
 
 			/* Skip this index-update if the predicate isn't satisfied */
-			if (! ExecQual((List *) predicate, econtext, false))
+			if (!ExecQual((List *) predicate, econtext, false))
 				continue;
 		}
 
diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c
index 3854978029b2393a7f5c1f0f3b59d905164c027d..c8d119df482001972556148a76b87734becbf7b1 100644
--- a/src/backend/executor/functions.c
+++ b/src/backend/executor/functions.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.32 2000/04/04 21:44:39 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.33 2000/04/12 17:15:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -150,6 +150,7 @@ init_execution_state(FunctionCachePtr fcache,
 static TupleDesc
 postquel_start(execution_state *es)
 {
+
 	/*
 	 * Do nothing for utility commands. (create, destroy...)  DZ -
 	 * 30-8-1996
@@ -166,9 +167,9 @@ postquel_getnext(execution_state *es)
 
 	if (es->qd->operation == CMD_UTILITY)
 	{
+
 		/*
-		 * Process a utility command. (create, destroy...)  DZ -
-		 * 30-8-1996
+		 * Process a utility command. (create, destroy...)	DZ - 30-8-1996
 		 */
 		ProcessUtility(es->qd->parsetree->utilityStmt, es->qd->dest);
 		if (!LAST_POSTQUEL_COMMAND(es))
@@ -184,6 +185,7 @@ postquel_getnext(execution_state *es)
 static void
 postquel_end(execution_state *es)
 {
+
 	/*
 	 * Do nothing for utility commands. (create, destroy...)  DZ -
 	 * 30-8-1996
diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c
index 961440cc66d99a893a99501cbe578862a2d136c8..e2db06f84d140690bf2e9673783015bc7de00da0 100644
--- a/src/backend/executor/nodeAgg.c
+++ b/src/backend/executor/nodeAgg.c
@@ -15,7 +15,7 @@
  *		 value1 = finalfunc(value1, value2)
  *
  *	  If initcond1 is NULL then the first non-NULL input_value is
- *	  assigned directly to value1.  sfunc1 isn't applied until value1
+ *	  assigned directly to value1.	sfunc1 isn't applied until value1
  *	  is non-NULL.
  *
  *	  sfunc1 is never applied when the current tuple's input_value is NULL.
@@ -24,7 +24,7 @@
  *	  (usenulls was formerly used for COUNT(*), but is no longer needed for
  *	  that purpose; as of 10/1999 the support for usenulls is dead code.
  *	  I have not removed it because it seems like a potentially useful
- *	  feature for user-defined aggregates.  We'd just need to add a
+ *	  feature for user-defined aggregates.	We'd just need to add a
  *	  flag column to pg_aggregate and a parameter to CREATE AGGREGATE...)
  *
  *
@@ -32,7 +32,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.62 2000/01/26 05:56:22 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.63 2000/04/12 17:15:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -56,6 +56,7 @@
  */
 typedef struct AggStatePerAggData
 {
+
 	/*
 	 * These values are set up during ExecInitAgg() and do not change
 	 * thereafter:
@@ -68,6 +69,7 @@ typedef struct AggStatePerAggData
 	Oid			xfn1_oid;
 	Oid			xfn2_oid;
 	Oid			finalfn_oid;
+
 	/*
 	 * fmgr lookup data for transfer functions --- only valid when
 	 * corresponding oid is not InvalidOid
@@ -75,18 +77,21 @@ typedef struct AggStatePerAggData
 	FmgrInfo	xfn1;
 	FmgrInfo	xfn2;
 	FmgrInfo	finalfn;
+
 	/*
-	 * Type of input data and Oid of sort operator to use for it;
-	 * only set/used when aggregate has DISTINCT flag.  (These are not
-	 * used directly by nodeAgg, but must be passed to the Tuplesort object.)
+	 * Type of input data and Oid of sort operator to use for it; only
+	 * set/used when aggregate has DISTINCT flag.  (These are not used
+	 * directly by nodeAgg, but must be passed to the Tuplesort object.)
 	 */
 	Oid			inputType;
 	Oid			sortOperator;
+
 	/*
-	 * fmgr lookup data for input type's equality operator --- only set/used
-	 * when aggregate has DISTINCT flag.
+	 * fmgr lookup data for input type's equality operator --- only
+	 * set/used when aggregate has DISTINCT flag.
 	 */
 	FmgrInfo	equalfn;
+
 	/*
 	 * initial values from pg_aggregate entry
 	 */
@@ -94,6 +99,7 @@ typedef struct AggStatePerAggData
 	Datum		initValue2;		/* for transtype2 */
 	bool		initValue1IsNull,
 				initValue2IsNull;
+
 	/*
 	 * We need the len and byval info for the agg's input and transition
 	 * data types in order to know how to copy/delete values.
@@ -106,14 +112,14 @@ typedef struct AggStatePerAggData
 				transtype2ByVal;
 
 	/*
-	 * These values are working state that is initialized at the start
-	 * of an input tuple group and updated for each input tuple.
+	 * These values are working state that is initialized at the start of
+	 * an input tuple group and updated for each input tuple.
 	 *
 	 * For a simple (non DISTINCT) aggregate, we just feed the input values
-	 * straight to the transition functions.  If it's DISTINCT, we pass the
-	 * input values into a Tuplesort object; then at completion of the input
-	 * tuple group, we scan the sorted values, eliminate duplicates, and run
-	 * the transition functions on the rest.
+	 * straight to the transition functions.  If it's DISTINCT, we pass
+	 * the input values into a Tuplesort object; then at completion of the
+	 * input tuple group, we scan the sorted values, eliminate duplicates,
+	 * and run the transition functions on the rest.
 	 */
 
 	Tuplesortstate *sortstate;	/* sort object, if a DISTINCT agg */
@@ -123,20 +129,22 @@ typedef struct AggStatePerAggData
 	bool		value1IsNull,
 				value2IsNull;
 	bool		noInitValue;	/* true if value1 not set yet */
+
 	/*
-	 * Note: right now, noInitValue always has the same value as value1IsNull.
-	 * But we should keep them separate because once the fmgr interface is
-	 * fixed, we'll need to distinguish a null returned by transfn1 from
-	 * a null we haven't yet replaced with an input value.
+	 * Note: right now, noInitValue always has the same value as
+	 * value1IsNull. But we should keep them separate because once the
+	 * fmgr interface is fixed, we'll need to distinguish a null returned
+	 * by transfn1 from a null we haven't yet replaced with an input
+	 * value.
 	 */
 } AggStatePerAggData;
 
 
-static void initialize_aggregate (AggStatePerAgg peraggstate);
-static void advance_transition_functions (AggStatePerAgg peraggstate,
-										  Datum newVal, bool isNull);
-static void finalize_aggregate (AggStatePerAgg peraggstate,
-								Datum *resultVal, bool *resultIsNull);
+static void initialize_aggregate(AggStatePerAgg peraggstate);
+static void advance_transition_functions(AggStatePerAgg peraggstate,
+							 Datum newVal, bool isNull);
+static void finalize_aggregate(AggStatePerAgg peraggstate,
+				   Datum *resultVal, bool *resultIsNull);
 static Datum copyDatum(Datum val, int typLen, bool typByVal);
 
 
@@ -144,17 +152,19 @@ static Datum copyDatum(Datum val, int typLen, bool typByVal);
  * Initialize one aggregate for a new set of input values.
  */
 static void
-initialize_aggregate (AggStatePerAgg peraggstate)
+initialize_aggregate(AggStatePerAgg peraggstate)
 {
-	Aggref		   *aggref = peraggstate->aggref;
+	Aggref	   *aggref = peraggstate->aggref;
 
 	/*
 	 * Start a fresh sort operation for each DISTINCT aggregate.
 	 */
 	if (aggref->aggdistinct)
 	{
-		/* In case of rescan, maybe there could be an uncompleted
-		 * sort operation?  Clean it up if so.
+
+		/*
+		 * In case of rescan, maybe there could be an uncompleted sort
+		 * operation?  Clean it up if so.
 		 */
 		if (peraggstate->sortstate)
 			tuplesort_end(peraggstate->sortstate);
@@ -169,8 +179,8 @@ initialize_aggregate (AggStatePerAgg peraggstate)
 	 * (Re)set value1 and value2 to their initial values.
 	 */
 	if (OidIsValid(peraggstate->xfn1_oid) &&
-		! peraggstate->initValue1IsNull)
-		peraggstate->value1 = copyDatum(peraggstate->initValue1, 
+		!peraggstate->initValue1IsNull)
+		peraggstate->value1 = copyDatum(peraggstate->initValue1,
 										peraggstate->transtype1Len,
 										peraggstate->transtype1ByVal);
 	else
@@ -178,8 +188,8 @@ initialize_aggregate (AggStatePerAgg peraggstate)
 	peraggstate->value1IsNull = peraggstate->initValue1IsNull;
 
 	if (OidIsValid(peraggstate->xfn2_oid) &&
-		! peraggstate->initValue2IsNull)
-		peraggstate->value2 = copyDatum(peraggstate->initValue2, 
+		!peraggstate->initValue2IsNull)
+		peraggstate->value2 = copyDatum(peraggstate->initValue2,
 										peraggstate->transtype2Len,
 										peraggstate->transtype2ByVal);
 	else
@@ -205,8 +215,8 @@ initialize_aggregate (AggStatePerAgg peraggstate)
  * out before reaching here.
  */
 static void
-advance_transition_functions (AggStatePerAgg peraggstate,
-							  Datum newVal, bool isNull)
+advance_transition_functions(AggStatePerAgg peraggstate,
+							 Datum newVal, bool isNull)
 {
 	Datum		args[2];
 
@@ -214,6 +224,7 @@ advance_transition_functions (AggStatePerAgg peraggstate,
 	{
 		if (peraggstate->noInitValue)
 		{
+
 			/*
 			 * value1 has not been initialized. This is the first non-NULL
 			 * input value. We use it as the initial value for value1.
@@ -238,7 +249,7 @@ advance_transition_functions (AggStatePerAgg peraggstate,
 			newVal = (Datum) fmgr_c(&peraggstate->xfn1,
 									(FmgrValues *) args,
 									&isNull);
-			if (! peraggstate->transtype1ByVal)
+			if (!peraggstate->transtype1ByVal)
 				pfree(peraggstate->value1);
 			peraggstate->value1 = newVal;
 		}
@@ -252,7 +263,7 @@ advance_transition_functions (AggStatePerAgg peraggstate,
 		newVal = (Datum) fmgr_c(&peraggstate->xfn2,
 								(FmgrValues *) args,
 								&isNull);
-		if (! peraggstate->transtype2ByVal)
+		if (!peraggstate->transtype2ByVal)
 			pfree(peraggstate->value2);
 		peraggstate->value2 = newVal;
 	}
@@ -262,17 +273,18 @@ advance_transition_functions (AggStatePerAgg peraggstate,
  * Compute the final value of one aggregate.
  */
 static void
-finalize_aggregate (AggStatePerAgg peraggstate,
-					Datum *resultVal, bool *resultIsNull)
+finalize_aggregate(AggStatePerAgg peraggstate,
+				   Datum *resultVal, bool *resultIsNull)
 {
 	Aggref	   *aggref = peraggstate->aggref;
 	char	   *args[2];
 
 	/*
 	 * If it's a DISTINCT aggregate, all we've done so far is to stuff the
-	 * input values into the sort object.  Complete the sort, then run
-	 * the transition functions on the non-duplicate values.  Note that
-	 * DISTINCT always suppresses nulls, per SQL spec, regardless of usenulls.
+	 * input values into the sort object.  Complete the sort, then run the
+	 * transition functions on the non-duplicate values.  Note that
+	 * DISTINCT always suppresses nulls, per SQL spec, regardless of
+	 * usenulls.
 	 */
 	if (aggref->aggdistinct)
 	{
@@ -289,41 +301,41 @@ finalize_aggregate (AggStatePerAgg peraggstate,
 				continue;
 			if (haveOldVal)
 			{
-				Datum	equal;
+				Datum		equal;
 
 				equal = (Datum) (*fmgr_faddr(&peraggstate->equalfn)) (oldVal,
-																	  newVal);
+																 newVal);
 				if (DatumGetInt32(equal) != 0)
 				{
-					if (! peraggstate->inputtypeByVal)
+					if (!peraggstate->inputtypeByVal)
 						pfree(DatumGetPointer(newVal));
 					continue;
 				}
 			}
 			advance_transition_functions(peraggstate, newVal, false);
-			if (haveOldVal && ! peraggstate->inputtypeByVal)
+			if (haveOldVal && !peraggstate->inputtypeByVal)
 				pfree(DatumGetPointer(oldVal));
 			oldVal = newVal;
 			haveOldVal = true;
 		}
-		if (haveOldVal && ! peraggstate->inputtypeByVal)
+		if (haveOldVal && !peraggstate->inputtypeByVal)
 			pfree(DatumGetPointer(oldVal));
 		tuplesort_end(peraggstate->sortstate);
 		peraggstate->sortstate = NULL;
 	}
 
 	/*
-	 * Now apply the agg's finalfn, or substitute the appropriate transition
-	 * value if there is no finalfn.
+	 * Now apply the agg's finalfn, or substitute the appropriate
+	 * transition value if there is no finalfn.
 	 *
-	 * XXX For now, only apply finalfn if we got at least one
-	 * non-null input value.  This prevents zero divide in AVG().
-	 * If we had cleaner handling of null inputs/results in functions,
-	 * we could probably take out this hack and define the result
-	 * for no inputs as whatever finalfn returns for null input.
+	 * XXX For now, only apply finalfn if we got at least one non-null input
+	 * value.  This prevents zero divide in AVG(). If we had cleaner
+	 * handling of null inputs/results in functions, we could probably
+	 * take out this hack and define the result for no inputs as whatever
+	 * finalfn returns for null input.
 	 */
 	if (OidIsValid(peraggstate->finalfn_oid) &&
-		! peraggstate->noInitValue)
+		!peraggstate->noInitValue)
 	{
 		if (peraggstate->finalfn.fn_nargs > 1)
 		{
@@ -361,17 +373,17 @@ finalize_aggregate (AggStatePerAgg peraggstate,
 		elog(ERROR, "ExecAgg: no valid transition functions??");
 
 	/*
-	 * Release any per-group working storage, unless we're passing
-	 * it back as the result of the aggregate.
+	 * Release any per-group working storage, unless we're passing it back
+	 * as the result of the aggregate.
 	 */
 	if (OidIsValid(peraggstate->xfn1_oid) &&
-		! peraggstate->value1IsNull &&
-		! peraggstate->transtype1ByVal)
+		!peraggstate->value1IsNull &&
+		!peraggstate->transtype1ByVal)
 		pfree(peraggstate->value1);
-	
+
 	if (OidIsValid(peraggstate->xfn2_oid) &&
-		! peraggstate->value2IsNull &&
-		! peraggstate->transtype2ByVal)
+		!peraggstate->value2IsNull &&
+		!peraggstate->transtype2ByVal)
 		pfree(peraggstate->value2);
 }
 
@@ -383,8 +395,8 @@ finalize_aggregate (AggStatePerAgg peraggstate,
  *	  the appropriate attribute for each aggregate function use (Aggref
  *	  node) appearing in the targetlist or qual of the node.  The number
  *	  of tuples to aggregate over depends on whether a GROUP BY clause is
- *	  present.  We can produce an aggregate result row per group, or just
- *	  one for the whole query.  The value of each aggregate is stored in
+ *	  present.	We can produce an aggregate result row per group, or just
+ *	  one for the whole query.	The value of each aggregate is stored in
  *	  the expression context to be used when ExecProject evaluates the
  *	  result tuple.
  *
@@ -403,7 +415,7 @@ ExecAgg(Agg *node)
 	ProjectionInfo *projInfo;
 	Datum	   *aggvalues;
 	bool	   *aggnulls;
-	AggStatePerAgg	peragg;
+	AggStatePerAgg peragg;
 	TupleTableSlot *resultSlot;
 	HeapTuple	inputTuple;
 	int			aggno;
@@ -437,7 +449,7 @@ ExecAgg(Agg *node)
 		 */
 		for (aggno = 0; aggno < aggstate->numaggs; aggno++)
 		{
-			AggStatePerAgg	peraggstate = &peragg[aggno];
+			AggStatePerAgg peraggstate = &peragg[aggno];
 
 			initialize_aggregate(peraggstate);
 		}
@@ -459,9 +471,9 @@ ExecAgg(Agg *node)
 
 			for (aggno = 0; aggno < aggstate->numaggs; aggno++)
 			{
-				AggStatePerAgg	peraggstate = &peragg[aggno];
-				Aggref		   *aggref = peraggstate->aggref;
-				Datum			newVal;
+				AggStatePerAgg peraggstate = &peragg[aggno];
+				Aggref	   *aggref = peraggstate->aggref;
+				Datum		newVal;
 
 				newVal = ExecEvalExpr(aggref->target, econtext,
 									  &isNull, &isDone);
@@ -479,37 +491,37 @@ ExecAgg(Agg *node)
 
 			/*
 			 * Keep a copy of the first input tuple for the projection.
-			 * (We only need one since only the GROUP BY columns in it
-			 * can be referenced, and these will be the same for all
-			 * tuples aggregated over.)
+			 * (We only need one since only the GROUP BY columns in it can
+			 * be referenced, and these will be the same for all tuples
+			 * aggregated over.)
 			 */
 			if (!inputTuple)
 				inputTuple = heap_copytuple(outerslot->val);
 		}
 
 		/*
-		 * Done scanning input tuple group.
-		 * Finalize each aggregate calculation.
+		 * Done scanning input tuple group. Finalize each aggregate
+		 * calculation.
 		 */
 		for (aggno = 0; aggno < aggstate->numaggs; aggno++)
 		{
-			AggStatePerAgg	peraggstate = &peragg[aggno];
+			AggStatePerAgg peraggstate = &peragg[aggno];
 
 			finalize_aggregate(peraggstate,
-							   & aggvalues[aggno], & aggnulls[aggno]);
+							   &aggvalues[aggno], &aggnulls[aggno]);
 		}
 
 		/*
 		 * If the outerPlan is a Group node, we will reach here after each
 		 * group.  We are not done unless the Group node is done (a little
-		 * ugliness here while we reach into the Group's state to find out).
-		 * Furthermore, when grouping we return nothing at all unless we
-		 * had some input tuple(s).  By the nature of Group, there are
-		 * no empty groups, so if we get here with no input the whole scan
-		 * is empty.
+		 * ugliness here while we reach into the Group's state to find
+		 * out). Furthermore, when grouping we return nothing at all
+		 * unless we had some input tuple(s).  By the nature of Group,
+		 * there are no empty groups, so if we get here with no input the
+		 * whole scan is empty.
 		 *
-		 * If the outerPlan isn't a Group, we are done when we get here,
-		 * and we will emit a (single) tuple even if there were no input
+		 * If the outerPlan isn't a Group, we are done when we get here, and
+		 * we will emit a (single) tuple even if there were no input
 		 * tuples.
 		 */
 		if (IsA(outerPlan, Group))
@@ -523,17 +535,18 @@ ExecAgg(Agg *node)
 		else
 		{
 			aggstate->agg_done = true;
+
 			/*
-			 * If inputtuple==NULL (ie, the outerPlan didn't return anything),
-			 * create a dummy all-nulls input tuple for use by execProject.
-			 * 99.44% of the time this is a waste of cycles, because
-			 * ordinarily the projected output tuple's targetlist cannot
-			 * contain any direct (non-aggregated) references to input
-			 * columns, so the dummy tuple will not be referenced.  However
-			 * there are special cases where this isn't so --- in particular
-			 * an UPDATE involving an aggregate will have a targetlist
-			 * reference to ctid.  We need to return a null for ctid in that
-			 * situation, not coredump.
+			 * If inputtuple==NULL (ie, the outerPlan didn't return
+			 * anything), create a dummy all-nulls input tuple for use by
+			 * execProject. 99.44% of the time this is a waste of cycles,
+			 * because ordinarily the projected output tuple's targetlist
+			 * cannot contain any direct (non-aggregated) references to
+			 * input columns, so the dummy tuple will not be referenced.
+			 * However there are special cases where this isn't so --- in
+			 * particular an UPDATE involving an aggregate will have a
+			 * targetlist reference to ctid.  We need to return a null for
+			 * ctid in that situation, not coredump.
 			 *
 			 * The values returned for the aggregates will be the initial
 			 * values of the transition functions.
@@ -550,7 +563,7 @@ ExecAgg(Agg *node)
 				/* watch out for null input tuples, though... */
 				if (tupType && tupValue)
 				{
-					null_array = (char *) palloc(sizeof(char)*tupType->natts);
+					null_array = (char *) palloc(sizeof(char) * tupType->natts);
 					for (attnum = 0; attnum < tupType->natts; attnum++)
 						null_array[attnum] = 'n';
 					inputTuple = heap_formtuple(tupType, tupValue, null_array);
@@ -571,17 +584,17 @@ ExecAgg(Agg *node)
 
 		/*
 		 * Form a projection tuple using the aggregate results and the
-		 * representative input tuple.  Store it in the result tuple slot.
+		 * representative input tuple.	Store it in the result tuple slot.
 		 */
 		resultSlot = ExecProject(projInfo, &isDone);
 
 		/*
-		 * If the completed tuple does not match the qualifications,
-		 * it is ignored and we loop back to try to process another group.
+		 * If the completed tuple does not match the qualifications, it is
+		 * ignored and we loop back to try to process another group.
 		 * Otherwise, return the tuple.
 		 */
 	}
-	while (! ExecQual(node->plan.qual, econtext, false));
+	while (!ExecQual(node->plan.qual, econtext, false));
 
 	return resultSlot;
 }
@@ -596,13 +609,13 @@ ExecAgg(Agg *node)
 bool
 ExecInitAgg(Agg *node, EState *estate, Plan *parent)
 {
-	AggState	   *aggstate;
-	AggStatePerAgg	peragg;
-	Plan		   *outerPlan;
-	ExprContext	   *econtext;
-	int				numaggs,
-					aggno;
-	List		   *alist;
+	AggState   *aggstate;
+	AggStatePerAgg peragg;
+	Plan	   *outerPlan;
+	ExprContext *econtext;
+	int			numaggs,
+				aggno;
+	List	   *alist;
 
 	/*
 	 * assign the node's execution state
@@ -620,21 +633,23 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
 	 * find aggregates in targetlist and quals
 	 *
 	 * Note: pull_agg_clauses also checks that no aggs contain other agg
-	 * calls in their arguments.  This would make no sense under SQL semantics
-	 * anyway (and it's forbidden by the spec).  Because that is true, we
-	 * don't need to worry about evaluating the aggs in any particular order.
+	 * calls in their arguments.  This would make no sense under SQL
+	 * semantics anyway (and it's forbidden by the spec).  Because that is
+	 * true, we don't need to worry about evaluating the aggs in any
+	 * particular order.
 	 */
 	aggstate->aggs = nconc(pull_agg_clause((Node *) node->plan.targetlist),
 						   pull_agg_clause((Node *) node->plan.qual));
 	aggstate->numaggs = numaggs = length(aggstate->aggs);
 	if (numaggs <= 0)
 	{
+
 		/*
-		 * This used to be treated as an error, but we can't do that anymore
-		 * because constant-expression simplification could optimize away
-		 * all of the Aggrefs in the targetlist and qual.  So, just make a
-		 * debug note, and force numaggs positive so that palloc()s below
-		 * don't choke.
+		 * This used to be treated as an error, but we can't do that
+		 * anymore because constant-expression simplification could
+		 * optimize away all of the Aggrefs in the targetlist and qual.
+		 * So, just make a debug note, and force numaggs positive so that
+		 * palloc()s below don't choke.
 		 */
 		elog(DEBUG, "ExecInitAgg: could not find any aggregate functions");
 		numaggs = 1;
@@ -655,8 +670,8 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
 	ExecInitResultTupleSlot(estate, &aggstate->csstate.cstate);
 
 	/*
-	 * Set up aggregate-result storage in the expr context,
-	 * and also allocate my private per-agg working storage
+	 * Set up aggregate-result storage in the expr context, and also
+	 * allocate my private per-agg working storage
 	 */
 	econtext = aggstate->csstate.cstate.cs_ExprContext;
 	econtext->ecxt_aggvalues = (Datum *) palloc(sizeof(Datum) * numaggs);
@@ -693,15 +708,15 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
 	aggno = -1;
 	foreach(alist, aggstate->aggs)
 	{
-		Aggref		   *aggref = (Aggref *) lfirst(alist);
-		AggStatePerAgg	peraggstate = &peragg[++aggno];
-		char		   *aggname = aggref->aggname;
-		HeapTuple		aggTuple;
+		Aggref	   *aggref = (Aggref *) lfirst(alist);
+		AggStatePerAgg peraggstate = &peragg[++aggno];
+		char	   *aggname = aggref->aggname;
+		HeapTuple	aggTuple;
 		Form_pg_aggregate aggform;
-		Type			typeInfo;
-		Oid				xfn1_oid,
-						xfn2_oid,
-						finalfn_oid;
+		Type		typeInfo;
+		Oid			xfn1_oid,
+					xfn2_oid,
+					finalfn_oid;
 
 		/* Mark Aggref node with its associated index in the result array */
 		aggref->aggno = aggno;
@@ -762,9 +777,7 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
 		}
 
 		if (OidIsValid(finalfn_oid))
-		{
 			fmgr_info(finalfn_oid, &peraggstate->finalfn);
-		}
 
 		if (aggref->aggdistinct)
 		{
@@ -848,7 +861,7 @@ copyDatum(Datum val, int typLen, bool typByVal)
 		return val;
 	else
 	{
-		char   *newVal;
+		char	   *newVal;
 
 		if (typLen == -1)		/* variable length type? */
 			typLen = VARSIZE((struct varlena *) DatumGetPointer(val));
diff --git a/src/backend/executor/nodeAppend.c b/src/backend/executor/nodeAppend.c
index f5c5701fd25c8e1e62f715cecc434628f7f259a9..1200d9e6ba92b4caea555545daaa7fc8c19f01cb 100644
--- a/src/backend/executor/nodeAppend.c
+++ b/src/backend/executor/nodeAppend.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.29 2000/01/26 05:56:22 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.30 2000/04/12 17:15:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -251,9 +251,9 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
 
 		foreach(rtentryP, rtable)
 		{
-			RangeTblEntry  *rtentry = lfirst(rtentryP);
-			Oid				reloid;
-			RelationInfo   *rri;
+			RangeTblEntry *rtentry = lfirst(rtentryP);
+			Oid			reloid;
+			RelationInfo *rri;
 
 			reloid = rtentry->relid;
 			rri = makeNode(RelationInfo);
@@ -304,6 +304,7 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
 		{
 			JunkFilter *j = ExecInitJunkFilter(initNode->targetlist,
 											   ExecGetTupType(initNode));
+
 			junkList = lappend(junkList, j);
 		}
 
diff --git a/src/backend/executor/nodeGroup.c b/src/backend/executor/nodeGroup.c
index cad023776d8ea3c51c59d6a0b330c60486b4785c..1a35ea578e9bc1624018b188a97913ed7c84a8b6 100644
--- a/src/backend/executor/nodeGroup.c
+++ b/src/backend/executor/nodeGroup.c
@@ -15,7 +15,7 @@
  *	  locate group boundaries.
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.33 2000/01/27 18:11:27 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.34 2000/04/12 17:15:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -97,8 +97,9 @@ ExecGroupEveryTuple(Group *node)
 	{
 		grpstate->grp_useFirstTuple = FALSE;
 
-		/* note we rely on subplan to hold ownership of the tuple
-		 * for as long as we need it; we don't copy it.
+		/*
+		 * note we rely on subplan to hold ownership of the tuple for as
+		 * long as we need it; we don't copy it.
 		 */
 		ExecStoreTuple(grpstate->grp_firstTuple,
 					   grpstate->csstate.css_ScanTupleSlot,
@@ -122,17 +123,20 @@ ExecGroupEveryTuple(Group *node)
 		}
 		else
 		{
+
 			/*
 			 * Compare with first tuple and see if this tuple is of the
 			 * same group.
 			 */
-			if (! execTuplesMatch(firsttuple, outerTuple,
-								  tupdesc,
-								  node->numCols, node->grpColIdx,
-								  grpstate->eqfunctions))
+			if (!execTuplesMatch(firsttuple, outerTuple,
+								 tupdesc,
+								 node->numCols, node->grpColIdx,
+								 grpstate->eqfunctions))
 			{
+
 				/*
-				 * No; save the tuple to return it next time, and return NULL
+				 * No; save the tuple to return it next time, and return
+				 * NULL
 				 */
 				grpstate->grp_useFirstTuple = TRUE;
 				heap_freetuple(firsttuple);
@@ -142,8 +146,9 @@ ExecGroupEveryTuple(Group *node)
 			}
 		}
 
-		/* note we rely on subplan to hold ownership of the tuple
-		 * for as long as we need it; we don't copy it.
+		/*
+		 * note we rely on subplan to hold ownership of the tuple for as
+		 * long as we need it; we don't copy it.
 		 */
 		ExecStoreTuple(outerTuple,
 					   grpstate->csstate.css_ScanTupleSlot,
@@ -227,13 +232,13 @@ ExecGroupOneTuple(Group *node)
 		outerTuple = outerslot->val;
 
 		/*
-		 * Compare with first tuple and see if this tuple is of the
-		 * same group.
+		 * Compare with first tuple and see if this tuple is of the same
+		 * group.
 		 */
-		if (! execTuplesMatch(firsttuple, outerTuple,
-							  tupdesc,
-							  node->numCols, node->grpColIdx,
-							  grpstate->eqfunctions))
+		if (!execTuplesMatch(firsttuple, outerTuple,
+							 tupdesc,
+							 node->numCols, node->grpColIdx,
+							 grpstate->eqfunctions))
 			break;
 	}
 
@@ -244,8 +249,9 @@ ExecGroupOneTuple(Group *node)
 	 */
 	projInfo = grpstate->csstate.cstate.cs_ProjInfo;
 
-	/* note we rely on subplan to hold ownership of the tuple
-	 * for as long as we need it; we don't copy it.
+	/*
+	 * note we rely on subplan to hold ownership of the tuple for as long
+	 * as we need it; we don't copy it.
 	 */
 	ExecStoreTuple(firsttuple,
 				   grpstate->csstate.css_ScanTupleSlot,
@@ -418,7 +424,7 @@ execTuplesMatch(HeapTuple tuple1,
 	 * start comparing at the last field (least significant sort key).
 	 * That's the most likely to be different...
 	 */
-	for (i = numCols; --i >= 0; )
+	for (i = numCols; --i >= 0;)
 	{
 		AttrNumber	att = matchColIdx[i];
 		Datum		attr1,
@@ -445,7 +451,7 @@ execTuplesMatch(HeapTuple tuple1,
 
 		/* Apply the type-specific equality function */
 
-		equal = (Datum) (*fmgr_faddr(& eqfunctions[i])) (attr1, attr2);
+		equal = (Datum) (*fmgr_faddr(&eqfunctions[i])) (attr1, attr2);
 
 		if (DatumGetInt32(equal) == 0)
 			return FALSE;
@@ -459,7 +465,7 @@ execTuplesMatch(HeapTuple tuple1,
  *		Look up the equality functions needed for execTuplesMatch.
  *		The result is a palloc'd array.
  */
-FmgrInfo *
+FmgrInfo   *
 execTuplesMatchPrepare(TupleDesc tupdesc,
 					   int numCols,
 					   AttrNumber *matchColIdx)
@@ -481,7 +487,7 @@ execTuplesMatchPrepare(TupleDesc tupdesc,
 				 typeidTypeName(typid));
 		}
 		pgopform = (Form_pg_operator) GETSTRUCT(eq_operator);
-		fmgr_info(pgopform->oprcode, & eqfunctions[i]);
+		fmgr_info(pgopform->oprcode, &eqfunctions[i]);
 	}
 
 	return eqfunctions;
diff --git a/src/backend/executor/nodeIndexscan.c b/src/backend/executor/nodeIndexscan.c
index 16fcd225a8eb0645698deaa44099cb80ac5fe44f..d6fdce309de9a49ca599cab80a839193434ed088 100644
--- a/src/backend/executor/nodeIndexscan.c
+++ b/src/backend/executor/nodeIndexscan.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.48 2000/04/07 00:30:41 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.49 2000/04/12 17:15:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -106,7 +106,7 @@ IndexNext(IndexScan *node)
 			direction = BackwardScanDirection;
 		else if (ScanDirectionIsBackward(direction))
 			direction = ForwardScanDirection;
-	}  
+	}
 	snapshot = estate->es_snapshot;
 	scanstate = node->scan.scanstate;
 	indexstate = node->indxstate;
@@ -195,11 +195,11 @@ IndexNext(IndexScan *node)
 				List	   *qual;
 
 				/*
-				 *	store the scanned tuple in the scan tuple slot of
-				 *	the scan state.  Eventually we will only do this and not
-				 *	return a tuple.  Note: we pass 'false' because tuples
-				 *	returned by amgetnext are pointers onto disk pages and
-				 *	must not be pfree()'d.
+				 * store the scanned tuple in the scan tuple slot of the
+				 * scan state.	Eventually we will only do this and not
+				 * return a tuple.	Note: we pass 'false' because tuples
+				 * returned by amgetnext are pointers onto disk pages and
+				 * must not be pfree()'d.
 				 */
 				ExecStoreTuple(tuple,	/* tuple to store */
 							   slot,	/* slot to store in */
@@ -208,16 +208,17 @@ IndexNext(IndexScan *node)
 
 				/*
 				 * At this point we have an extra pin on the buffer,
-				 * because ExecStoreTuple incremented the pin count.
-				 * Drop our local pin.
+				 * because ExecStoreTuple incremented the pin count. Drop
+				 * our local pin.
 				 */
 				ReleaseBuffer(buffer);
 
 				/*
 				 * We must check to see if the current tuple was already
-				 * matched by an earlier index, so we don't double-report it.
-				 * We do this by passing the tuple through ExecQual and
-				 * checking for failure with all previous qualifications.
+				 * matched by an earlier index, so we don't double-report
+				 * it. We do this by passing the tuple through ExecQual
+				 * and checking for failure with all previous
+				 * qualifications.
 				 */
 				scanstate->cstate.cs_ExprContext->ecxt_scantuple = slot;
 				qual = node->indxqualorig;
@@ -234,7 +235,7 @@ IndexNext(IndexScan *node)
 					qual = lnext(qual);
 				}
 				if (!prev_matches)
-					return slot;		/* OK to return tuple */
+					return slot;/* OK to return tuple */
 				/* Duplicate tuple, so drop it and loop back for another */
 				ExecClearTuple(slot);
 			}
@@ -380,13 +381,14 @@ ExecIndexReScan(IndexScan *node, ExprContext *exprCtxt, Plan *parent)
 					scanexpr = (run_keys[j] == RIGHT_OP) ?
 						(Node *) get_rightop(clause) :
 						(Node *) get_leftop(clause);
+
 					/*
 					 * pass in isDone but ignore it.  We don't iterate in
 					 * quals
 					 */
 					scanvalue = (Datum)
 						ExecEvalExpr(scanexpr,
-								node->scan.scanstate->cstate.cs_ExprContext,
+							 node->scan.scanstate->cstate.cs_ExprContext,
 									 &isNull, &isDone);
 					scan_keys[j].sk_argument = scanvalue;
 					if (isNull)
@@ -750,7 +752,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
 			clause = nth(j, qual);
 
 			op = (Oper *) clause->oper;
-			if (!IsA(clause, Expr) || !IsA(op, Oper))
+			if (!IsA(clause, Expr) ||!IsA(op, Oper))
 				elog(ERROR, "ExecInitIndexScan: indxqual not an opclause!");
 
 			opid = op->opid;
@@ -801,7 +803,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
 
 			Assert(leftop != NULL);
 
-			if (IsA(leftop, Var) && var_is_rel((Var *) leftop))
+			if (IsA(leftop, Var) &&var_is_rel((Var *) leftop))
 			{
 				/* ----------------
 				 *	if the leftop is a "rel-var", then it means
@@ -884,7 +886,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
 
 			Assert(rightop != NULL);
 
-			if (IsA(rightop, Var) && var_is_rel((Var *) rightop))
+			if (IsA(rightop, Var) &&var_is_rel((Var *) rightop))
 			{
 				/* ----------------
 				 *	here we make sure only one op identifies the
@@ -1049,10 +1051,8 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
 				  &currentRelation,		/* return: rel desc */
 				  (Pointer *) &currentScanDesc);		/* return: scan desc */
 
-if (!RelationGetForm(currentRelation)->relhasindex)
-{
-	elog(ERROR, "indexes of the relation %u was inactivated", reloid);
-}
+	if (!RelationGetForm(currentRelation)->relhasindex)
+		elog(ERROR, "indexes of the relation %u was inactivated", reloid);
 	scanstate->css_currentRelation = currentRelation;
 	scanstate->css_currentScanDesc = currentScanDesc;
 
diff --git a/src/backend/executor/nodeSort.c b/src/backend/executor/nodeSort.c
index 9a70851e9f713a4c39619d21b0dbb23b3c09af67..362aef88d3ab0c5a3c233fb6237591507c85813f 100644
--- a/src/backend/executor/nodeSort.c
+++ b/src/backend/executor/nodeSort.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.25 2000/01/26 05:56:23 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.26 2000/04/12 17:15:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -126,7 +126,7 @@ ExecSort(Sort *node)
 	 * ----------------
 	 */
 
-	if (! sortstate->sort_Done)
+	if (!sortstate->sort_Done)
 	{
 		Plan	   *outerNode;
 		TupleDesc	tupDesc;
@@ -156,7 +156,7 @@ ExecSort(Sort *node)
 		sortkeys = (ScanKey) sortstate->sort_Keys;
 
 		tuplesortstate = tuplesort_begin_heap(tupDesc, keycount, sortkeys,
-											  true /* randomAccess */);
+											  true /* randomAccess */ );
 
 		sortstate->tuplesortstate = (void *) tuplesortstate;
 
@@ -371,7 +371,7 @@ ExecSortMarkPos(Sort *node)
 	 *	if we haven't sorted yet, just return
 	 * ----------------
 	 */
-	if (! sortstate->sort_Done)
+	if (!sortstate->sort_Done)
 		return;
 
 	tuplesort_markpos((Tuplesortstate *) sortstate->tuplesortstate);
@@ -392,7 +392,7 @@ ExecSortRestrPos(Sort *node)
 	 *	if we haven't sorted yet, just return.
 	 * ----------------
 	 */
-	if (! sortstate->sort_Done)
+	if (!sortstate->sort_Done)
 		return;
 
 	/* ----------------
@@ -412,14 +412,14 @@ ExecReScanSort(Sort *node, ExprContext *exprCtxt, Plan *parent)
 	 * not NULL then it will be re-scanned by ExecProcNode, else - no
 	 * reason to re-scan it at all.
 	 */
-	if (! sortstate->sort_Done)
+	if (!sortstate->sort_Done)
 		return;
 
 	ExecClearTuple(sortstate->csstate.cstate.cs_ResultTupleSlot);
 
 	/*
-	 * If subnode is to be rescanned then we forget previous sort
-	 * results; we have to re-read the subplan and re-sort.
+	 * If subnode is to be rescanned then we forget previous sort results;
+	 * we have to re-read the subplan and re-sort.
 	 *
 	 * Otherwise we can just rewind and rescan the sorted output.
 	 */
@@ -430,7 +430,5 @@ ExecReScanSort(Sort *node, ExprContext *exprCtxt, Plan *parent)
 		sortstate->tuplesortstate = NULL;
 	}
 	else
-	{
 		tuplesort_rescan((Tuplesortstate *) sortstate->tuplesortstate);
-	}
 }
diff --git a/src/backend/executor/nodeSubplan.c b/src/backend/executor/nodeSubplan.c
index ed09a0bc9f22f26389ceeb9a89ff541525db60c1..99b09f685a0cd21f2bf0748aeb63fe09c1207134 100644
--- a/src/backend/executor/nodeSubplan.c
+++ b/src/backend/executor/nodeSubplan.c
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeSubplan.c,v 1.24 2000/03/23 07:32:58 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeSubplan.c,v 1.25 2000/04/12 17:15:10 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -67,20 +67,20 @@ ExecSubPlan(SubPlan *node, List *pvar, ExprContext *econtext, bool *isNull)
 	ExecReScan(plan, (ExprContext *) NULL, plan);
 
 	/*
-	 * For all sublink types except EXPR_SUBLINK, the result is boolean
-	 * as are the results of the combining operators.  We combine results
+	 * For all sublink types except EXPR_SUBLINK, the result is boolean as
+	 * are the results of the combining operators.	We combine results
 	 * within a tuple (if there are multiple columns) using OR semantics
 	 * if "useor" is true, AND semantics if not.  We then combine results
 	 * across tuples (if the subplan produces more than one) using OR
 	 * semantics for ANY_SUBLINK or AND semantics for ALL_SUBLINK.
 	 * (MULTIEXPR_SUBLINK doesn't allow multiple tuples from the subplan.)
 	 * NULL results from the combining operators are handled according to
-	 * the usual SQL semantics for OR and AND.  The result for no input
+	 * the usual SQL semantics for OR and AND.	The result for no input
 	 * tuples is FALSE for ANY_SUBLINK, TRUE for ALL_SUBLINK, NULL for
 	 * MULTIEXPR_SUBLINK.
 	 *
 	 * For EXPR_SUBLINK we require the subplan to produce no more than one
-	 * tuple, else an error is raised.  If zero tuples are produced, we
+	 * tuple, else an error is raised.	If zero tuples are produced, we
 	 * return NULL.  Assuming we get a tuple, we just return its first
 	 * column (there can be only one non-junk column in this case).
 	 */
@@ -106,13 +106,14 @@ ExecSubPlan(SubPlan *node, List *pvar, ExprContext *econtext, bool *isNull)
 			if (found)
 				elog(ERROR, "More than one tuple returned by a subselect used as an expression.");
 			found = true;
+
 			/*
-			 * We need to copy the subplan's tuple in case the result is of
-			 * pass-by-ref type --- our return value will point into this
-			 * copied tuple!  Can't use the subplan's instance of the tuple
-			 * since it won't still be valid after next ExecProcNode() call.
-			 * node->curTuple keeps track of the copied tuple for eventual
-			 * freeing.
+			 * We need to copy the subplan's tuple in case the result is
+			 * of pass-by-ref type --- our return value will point into
+			 * this copied tuple!  Can't use the subplan's instance of the
+			 * tuple since it won't still be valid after next
+			 * ExecProcNode() call. node->curTuple keeps track of the
+			 * copied tuple for eventual freeing.
 			 */
 			tup = heap_copytuple(tup);
 			if (node->curTuple)
@@ -129,7 +130,8 @@ ExecSubPlan(SubPlan *node, List *pvar, ExprContext *econtext, bool *isNull)
 
 		found = true;
 
-		/* For ALL, ANY, and MULTIEXPR sublinks, iterate over combining
+		/*
+		 * For ALL, ANY, and MULTIEXPR sublinks, iterate over combining
 		 * operators for columns of tuple.
 		 */
 		foreach(lst, sublink->oper)
@@ -140,14 +142,14 @@ ExecSubPlan(SubPlan *node, List *pvar, ExprContext *econtext, bool *isNull)
 			bool		expnull;
 
 			/*
-			 * The righthand side of the expression should be either a Const
-			 * or a function call or RelabelType node taking a Const as arg
-			 * (these nodes represent run-time type coercions inserted by
-			 * the parser to get to the input type needed by the operator).
-			 * Find the Const node and insert the actual righthand-side value
-			 * into it.
+			 * The righthand side of the expression should be either a
+			 * Const or a function call or RelabelType node taking a Const
+			 * as arg (these nodes represent run-time type coercions
+			 * inserted by the parser to get to the input type needed by
+			 * the operator). Find the Const node and insert the actual
+			 * righthand-side value into it.
 			 */
-			if (! IsA(con, Const))
+			if (!IsA(con, Const))
 			{
 				switch (con->type)
 				{
@@ -161,16 +163,18 @@ ExecSubPlan(SubPlan *node, List *pvar, ExprContext *econtext, bool *isNull)
 						/* will fail below */
 						break;
 				}
-				if (! IsA(con, Const))
+				if (!IsA(con, Const))
 					elog(ERROR, "ExecSubPlan: failed to find placeholder for subplan result");
 			}
 			con->constvalue = heap_getattr(tup, col, tdesc,
 										   &(con->constisnull));
+
 			/*
 			 * Now we can eval the combining operator for this column.
 			 */
 			expresult = ExecEvalExpr((Node *) expr, econtext, &expnull,
 									 (bool *) NULL);
+
 			/*
 			 * Combine the result into the row result as appropriate.
 			 */
@@ -240,14 +244,16 @@ ExecSubPlan(SubPlan *node, List *pvar, ExprContext *econtext, bool *isNull)
 
 	if (!found)
 	{
-		/* deal with empty subplan result.  result/isNull were previously
+
+		/*
+		 * deal with empty subplan result.	result/isNull were previously
 		 * initialized correctly for all sublink types except EXPR and
 		 * MULTIEXPR; for those, return NULL.
 		 */
 		if (subLinkType == EXPR_SUBLINK || subLinkType == MULTIEXPR_SUBLINK)
 		{
-				result = (Datum) false;
-				*isNull = true;
+			result = (Datum) false;
+			*isNull = true;
 		}
 	}
 
@@ -354,9 +360,9 @@ ExecSetParamPlan(SubPlan *node)
 
 		/*
 		 * We need to copy the subplan's tuple in case any of the params
-		 * are pass-by-ref type --- the pointers stored in the param structs
-		 * will point at this copied tuple!  node->curTuple keeps track
-		 * of the copied tuple for eventual freeing.
+		 * are pass-by-ref type --- the pointers stored in the param
+		 * structs will point at this copied tuple!  node->curTuple keeps
+		 * track of the copied tuple for eventual freeing.
 		 */
 		tup = heap_copytuple(tup);
 		if (node->curTuple)
diff --git a/src/backend/executor/nodeTidscan.c b/src/backend/executor/nodeTidscan.c
index 7d9c6748637cf77a0ee12409ac9ba67ced0a7132..31cdc20523533af670dbabe60eb200285abef03d 100644
--- a/src/backend/executor/nodeTidscan.c
+++ b/src/backend/executor/nodeTidscan.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.5 2000/04/07 00:30:41 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.6 2000/04/12 17:15:10 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -32,21 +32,21 @@
 #include "access/heapam.h"
 #include "parser/parsetree.h"
 
-static int TidListCreate(List *, ExprContext *, ItemPointer *);
+static int	TidListCreate(List *, ExprContext *, ItemPointer *);
 static TupleTableSlot *TidNext(TidScan *node);
 
 static int
 TidListCreate(List *evalList, ExprContext *econtext, ItemPointer *tidList)
 {
-	List		*lst;
-	ItemPointer	itemptr;
+	List	   *lst;
+	ItemPointer itemptr;
 	bool		isNull;
-	int		numTids = 0;
+	int			numTids = 0;
 
-	foreach (lst, evalList)
+	foreach(lst, evalList)
 	{
-		itemptr = (ItemPointer)ExecEvalExpr(lfirst(lst), econtext,
-				&isNull, (bool *)0);
+		itemptr = (ItemPointer) ExecEvalExpr(lfirst(lst), econtext,
+											 &isNull, (bool *) 0);
 		if (itemptr && ItemPointerIsValid(itemptr))
 		{
 			tidList[numTids] = itemptr;
@@ -67,20 +67,21 @@ TidListCreate(List *evalList, ExprContext *econtext, ItemPointer *tidList)
 static TupleTableSlot *
 TidNext(TidScan *node)
 {
-	EState		*estate;
+	EState	   *estate;
 	CommonScanState *scanstate;
-	TidScanState	*tidstate;
-	ScanDirection	direction;
+	TidScanState *tidstate;
+	ScanDirection direction;
 	Snapshot	snapshot;
 	Relation	heapRelation;
 	HeapTuple	tuple;
-	TupleTableSlot	*slot;
+	TupleTableSlot *slot;
 	Buffer		buffer = InvalidBuffer;
-	int		numTids;
+	int			numTids;
 
 	bool		bBackward;
-	int		tidNumber;
-	ItemPointer	*tidList, itemptr;
+	int			tidNumber;
+	ItemPointer *tidList,
+				itemptr;
 
 	/* ----------------
 	 *	extract necessary information from tid scan node
@@ -108,7 +109,7 @@ TidNext(TidScan *node)
 		ExecClearTuple(slot);
 		if (estate->es_evTupleNull[node->scan.scanrelid - 1])
 			return slot;		/* return empty slot */
-		
+
 		/* probably ought to use ExecStoreTuple here... */
 		slot->val = estate->es_evTuple[node->scan.scanrelid - 1];
 		slot->ttc_shouldFree = false;
@@ -159,7 +160,7 @@ TidNext(TidScan *node)
 		if (tuple->t_data != NULL)
 		{
 			bool		prev_matches = false;
-			int		prev_tid;
+			int			prev_tid;
 
 			/* ----------------
 			 *	store the scanned tuple in the scan tuple slot of
@@ -169,23 +170,23 @@ TidNext(TidScan *node)
 			 *	were not created with palloc() and so should not be pfree()'d.
 			 * ----------------
 			 */
-			ExecStoreTuple(tuple,	/* tuple to store */
-						   slot,	/* slot to store in */
-						   buffer,	/* buffer associated with tuple  */
-						   false);	/* don't pfree */
+			ExecStoreTuple(tuple,		/* tuple to store */
+						   slot,/* slot to store in */
+						   buffer,		/* buffer associated with tuple  */
+						   false);		/* don't pfree */
 
 			/*
-			 * At this point we have an extra pin on the buffer,
-			 * because ExecStoreTuple incremented the pin count.
-			 * Drop our local pin.
-			*/
-			ReleaseBuffer(buffer);  
+			 * At this point we have an extra pin on the buffer, because
+			 * ExecStoreTuple incremented the pin count. Drop our local
+			 * pin.
+			 */
+			ReleaseBuffer(buffer);
+
 			/*
-			 * We must check to see if the current tuple would have
-			 * been matched by an earlier tid, so we don't double
-			 * report it. We do this by passing the tuple through
-			 * ExecQual and look for failure with all previous
-			 * qualifications.
+			 * We must check to see if the current tuple would have been
+			 * matched by an earlier tid, so we don't double report it. We
+			 * do this by passing the tuple through ExecQual and look for
+			 * failure with all previous qualifications.
 			 */
 			for (prev_tid = 0; prev_tid < tidstate->tss_TidPtr;
 				 prev_tid++)
@@ -209,7 +210,7 @@ TidNext(TidScan *node)
 		else
 			tidstate->tss_TidPtr++;
 		if (slot_is_valid)
-			return slot; 
+			return slot;
 	}
 	/* ----------------
 	 *	if we get here it means the tid scan failed so we
@@ -255,9 +256,9 @@ ExecTidScan(TidScan *node)
 void
 ExecTidReScan(TidScan *node, ExprContext *exprCtxt, Plan *parent)
 {
-	EState		*estate;
-	TidScanState	*tidstate;
-	ItemPointer	*tidList;
+	EState	   *estate;
+	TidScanState *tidstate;
+	ItemPointer *tidList;
 
 	tidstate = node->tidstate;
 	estate = node->scan.plan.state;
@@ -278,7 +279,7 @@ ExecTidReScan(TidScan *node, ExprContext *exprCtxt, Plan *parent)
 	}
 
 	tidstate->tss_NumTids = TidListCreate(node->tideval,
-									node->scan.scanstate->cstate.cs_ExprContext,
+							 node->scan.scanstate->cstate.cs_ExprContext,
 										  tidList);
 
 	/* ----------------
@@ -299,7 +300,7 @@ void
 ExecEndTidScan(TidScan *node)
 {
 	CommonScanState *scanstate;
-	TidScanState	*tidstate;
+	TidScanState *tidstate;
 
 	scanstate = node->scan.scanstate;
 	tidstate = node->tidstate;
@@ -385,18 +386,18 @@ ExecTidRestrPos(TidScan *node)
 bool
 ExecInitTidScan(TidScan *node, EState *estate, Plan *parent)
 {
-	TidScanState	*tidstate;
+	TidScanState *tidstate;
 	CommonScanState *scanstate;
-	ItemPointer	*tidList;
-	int		numTids;
-	int		tidPtr;
-	List		*rangeTable;
-	RangeTblEntry	*rtentry;
-	Oid		relid;
-	Oid		reloid;
+	ItemPointer *tidList;
+	int			numTids;
+	int			tidPtr;
+	List	   *rangeTable;
+	RangeTblEntry *rtentry;
+	Oid			relid;
+	Oid			reloid;
 
 	Relation	currentRelation;
-	int		baseid;
+	int			baseid;
 
 	List	   *execParam = NULL;
 
@@ -473,7 +474,7 @@ ExecInitTidScan(TidScan *node, EState *estate, Plan *parent)
 	 *	get the tid node information
 	 * ----------------
 	 */
-	tidList = (ItemPointer *)palloc(length(node->tideval) * sizeof(ItemPointer));
+	tidList = (ItemPointer *) palloc(length(node->tideval) * sizeof(ItemPointer));
 	numTids = 0;
 	if (!node->needRescan)
 		numTids = TidListCreate(node->tideval, scanstate->cstate.cs_ExprContext, tidList);
@@ -502,8 +503,8 @@ ExecInitTidScan(TidScan *node, EState *estate, Plan *parent)
 	reloid = rtentry->relid;
 
 	currentRelation = heap_open(reloid, AccessShareLock);
-        if (currentRelation == NULL)
-                elog(ERROR, "ExecInitTidScan heap_open failed."); 
+	if (currentRelation == NULL)
+		elog(ERROR, "ExecInitTidScan heap_open failed.");
 	scanstate->css_currentRelation = currentRelation;
 	scanstate->css_currentScanDesc = 0;
 
diff --git a/src/backend/executor/nodeUnique.c b/src/backend/executor/nodeUnique.c
index f9f1fe81ab3f5e407af6e35126263ba0eb04248d..8c02126ebfbf05a7418ee91477ab47209626d482 100644
--- a/src/backend/executor/nodeUnique.c
+++ b/src/backend/executor/nodeUnique.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.27 2000/01/27 18:11:27 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.28 2000/04/12 17:15:10 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -55,7 +55,7 @@ ExecUnique(Unique *node)
 	uniquestate = node->uniquestate;
 	outerPlan = outerPlan((Plan *) node);
 	resultTupleSlot = uniquestate->cstate.cs_ResultTupleSlot;
-	tupDesc = ExecGetResultType(& uniquestate->cstate);
+	tupDesc = ExecGetResultType(&uniquestate->cstate);
 
 	/* ----------------
 	 *	now loop, returning only non-duplicate tuples.
@@ -86,16 +86,16 @@ ExecUnique(Unique *node)
 		 *	 another new tuple from the subplan.
 		 * ----------------
 		 */
-		if (! execTuplesMatch(slot->val, uniquestate->priorTuple,
-							  tupDesc,
-							  node->numCols, node->uniqColIdx,
-							  uniquestate->eqfunctions))
+		if (!execTuplesMatch(slot->val, uniquestate->priorTuple,
+							 tupDesc,
+							 node->numCols, node->uniqColIdx,
+							 uniquestate->eqfunctions))
 			break;
 	}
 
 	/* ----------------
 	 *	We have a new tuple different from the previous saved tuple (if any).
-	 *	Save it and return it.  Note that we make two copies of the tuple:
+	 *	Save it and return it.	Note that we make two copies of the tuple:
 	 *	one to keep for our own future comparisons, and one to return to the
 	 *	caller.  We need to copy the tuple returned by the subplan to avoid
 	 *	holding buffer refcounts, and we need our own copy because the caller
@@ -151,14 +151,14 @@ ExecInitUnique(Unique *node, EState *estate, Plan *parent)
 	 *	they never call ExecQual or ExecTargetList.
 	 * ----------------
 	 */
-	ExecAssignNodeBaseInfo(estate, & uniquestate->cstate, parent);
+	ExecAssignNodeBaseInfo(estate, &uniquestate->cstate, parent);
 
 #define UNIQUE_NSLOTS 1
 	/* ------------
 	 * Tuple table initialization
 	 * ------------
 	 */
-	ExecInitResultTupleSlot(estate, & uniquestate->cstate);
+	ExecInitResultTupleSlot(estate, &uniquestate->cstate);
 
 	/* ----------------
 	 *	then initialize outer plan
@@ -172,14 +172,14 @@ ExecInitUnique(Unique *node, EState *estate, Plan *parent)
 	 *	projection info for this node appropriately
 	 * ----------------
 	 */
-	ExecAssignResultTypeFromOuterPlan((Plan *) node, & uniquestate->cstate);
+	ExecAssignResultTypeFromOuterPlan((Plan *) node, &uniquestate->cstate);
 	uniquestate->cstate.cs_ProjInfo = NULL;
 
 	/*
 	 * Precompute fmgr lookup data for inner loop
 	 */
 	uniquestate->eqfunctions =
-		execTuplesMatchPrepare(ExecGetResultType(& uniquestate->cstate),
+		execTuplesMatchPrepare(ExecGetResultType(&uniquestate->cstate),
 							   node->numCols,
 							   node->uniqColIdx);
 
diff --git a/src/backend/lib/dllist.c b/src/backend/lib/dllist.c
index 41663b40c1d4d6e720ea795d9c83ebb2ab138215..5711f70b6904d1546c5af15ad8f1f52f3d82a614 100644
--- a/src/backend/lib/dllist.c
+++ b/src/backend/lib/dllist.c
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/lib/dllist.c,v 1.16 2000/01/26 05:56:26 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/lib/dllist.c,v 1.17 2000/04/12 17:15:10 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -128,14 +128,16 @@ DLRemove(Dlelem *e)
 
 	if (e->dle_prev)
 		e->dle_prev->dle_next = e->dle_next;
-	else						/* must be the head element */
+	else
+/* must be the head element */
 	{
 		Assert(e == l->dll_head);
 		l->dll_head = e->dle_next;
 	}
 	if (e->dle_next)
 		e->dle_next->dle_prev = e->dle_prev;
-	else						/* must be the tail element */
+	else
+/* must be the tail element */
 	{
 		Assert(e == l->dll_tail);
 		l->dll_tail = e->dle_prev;
@@ -236,7 +238,8 @@ DLMoveToFront(Dlelem *e)
 
 	if (e->dle_next)
 		e->dle_next->dle_prev = e->dle_prev;
-	else						/* must be the tail element */
+	else
+/* must be the tail element */
 	{
 		Assert(e == l->dll_tail);
 		l->dll_tail = e->dle_prev;
diff --git a/src/backend/lib/stringinfo.c b/src/backend/lib/stringinfo.c
index 9bfa42554ae53099777fbe7ee46f66b65d5a8b4c..4f2df746843fdd388baadc2d7e173b3ed479fd83 100644
--- a/src/backend/lib/stringinfo.c
+++ b/src/backend/lib/stringinfo.c
@@ -9,7 +9,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- *	  $Id: stringinfo.c,v 1.24 2000/01/26 05:56:26 momjian Exp $
+ *	  $Id: stringinfo.c,v 1.25 2000/04/12 17:15:11 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -85,7 +85,7 @@ enlargeStringInfo(StringInfo str, int needed)
 	str->data = (char *) repalloc(str->data, newlen);
 	if (str->data == NULL)
 		elog(ERROR,
-			 "enlargeStringInfo: Out of memory (%d bytes requested)", newlen);
+		"enlargeStringInfo: Out of memory (%d bytes requested)", newlen);
 
 	str->maxlen = newlen;
 }
@@ -122,12 +122,13 @@ appendStringInfo(StringInfo str, const char *fmt,...)
 			nprinted = vsnprintf(str->data + str->len, avail,
 								 fmt, args);
 			va_end(args);
+
 			/*
 			 * Note: some versions of vsnprintf return the number of chars
-			 * actually stored, but at least one returns -1 on failure.
-			 * Be conservative about believing whether the print worked.
+			 * actually stored, but at least one returns -1 on failure. Be
+			 * conservative about believing whether the print worked.
 			 */
-			if (nprinted >= 0 && nprinted < avail-1)
+			if (nprinted >= 0 && nprinted < avail - 1)
 			{
 				/* Success.  Note nprinted does not include trailing null. */
 				str->len += nprinted;
diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c
index 0b62b29c797c456b68045630d94f185fe157a155..890be537c2e745bf462e1d92e6b97c0aaccb2b41 100644
--- a/src/backend/libpq/auth.c
+++ b/src/backend/libpq/auth.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.43 2000/01/26 05:56:28 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.44 2000/04/12 17:15:13 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -48,7 +48,7 @@ static int	pg_passwordv0_recvauth(void *arg, PacketLen len, void *pkt);
 static int	checkPassword(Port *port, char *user, char *password);
 static int	old_be_recvauth(Port *port);
 static int	map_old_to_new(Port *port, UserAuth old, int status);
-static void	auth_failed(Port *port);
+static void auth_failed(Port *port);
 
 
 #ifdef KRB4
@@ -130,7 +130,7 @@ static int
 pg_krb4_recvauth(Port *port)
 {
 	snprintf(PQerrormsg, PQERRORMSG_LENGTH,
-			 "pg_krb4_recvauth: Kerberos not implemented on this server.\n");
+		 "pg_krb4_recvauth: Kerberos not implemented on this server.\n");
 	fputs(PQerrormsg, stderr);
 	pqdebug("%s", PQerrormsg);
 
@@ -455,7 +455,7 @@ be_recvauth(Port *port)
 	 * an error message into the postmaster logfile if it failed.
 	 */
 
-        if (hba_getauthmethod(port) != STATUS_OK) 
+	if (hba_getauthmethod(port) != STATUS_OK)
 		PacketSendError(&port->pktInfo,
 						"Missing or erroneous pg_hba.conf file, see postmaster log for details");
 
@@ -472,6 +472,7 @@ be_recvauth(Port *port)
 
 		AuthRequest areq = AUTH_REQ_OK;
 		PacketDoneProc auth_handler = NULL;
+
 		switch (port->auth_method)
 		{
 			case uaReject:
diff --git a/src/backend/libpq/be-dumpdata.c b/src/backend/libpq/be-dumpdata.c
index 296527337b49d03ce465fefd5c7a04ccff396a96..fcc63e1e2a0e0179cb50a844d2e2cf14c361059c 100644
--- a/src/backend/libpq/be-dumpdata.c
+++ b/src/backend/libpq/be-dumpdata.c
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- *	$Id: be-dumpdata.c,v 1.32 2000/01/26 05:56:28 momjian Exp $
+ *	$Id: be-dumpdata.c,v 1.33 2000/04/12 17:15:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -184,7 +184,7 @@ be_typeinit(PortalEntry *entry,
 		for (i = 0; i < natts; ++i)
 		{
 			strncpy(group->types[i].name,
-				NameStr(attrs[i]->attname), NAMEDATALEN);
+					NameStr(attrs[i]->attname), NAMEDATALEN);
 			group->types[i].typid = attrs[i]->atttypid;
 			group->types[i].typlen = attrs[i]->attlen;
 		}
diff --git a/src/backend/libpq/be-fsstubs.c b/src/backend/libpq/be-fsstubs.c
index c97bf0d0647202420cbe188a7ea9a15142b74c52..1ac73fa0ea4b16431b5910c0cb41dc79c440b286 100644
--- a/src/backend/libpq/be-fsstubs.c
+++ b/src/backend/libpq/be-fsstubs.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.43 2000/01/26 05:56:28 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.44 2000/04/12 17:15:14 momjian Exp $
  *
  * NOTES
  *	  This should be moved to a more appropriate place.  It is here
@@ -18,7 +18,7 @@
  *
  *	  These functions operate in a private GlobalMemoryContext, which means
  *	  that large object descriptors hang around until we destroy the context.
- *	  That happens in lo_commit().  It'd be possible to prolong the lifetime
+ *	  That happens in lo_commit().	It'd be possible to prolong the lifetime
  *	  of the context so that LO FDs are good across transactions (for example,
  *	  we could release the context only if we see that no FDs remain open).
  *	  But we'd need additional state in order to do the right thing at the
@@ -259,9 +259,9 @@ lo_tell(int fd)
 	}
 
 	/*
-	 * We assume we do not need to switch contexts for inv_tell.
-	 * That is true for now, but is probably more than this module
-	 * ought to assume...
+	 * We assume we do not need to switch contexts for inv_tell. That is
+	 * true for now, but is probably more than this module ought to
+	 * assume...
 	 */
 	return inv_tell(cookies[fd]);
 }
@@ -269,10 +269,11 @@ lo_tell(int fd)
 int
 lo_unlink(Oid lobjId)
 {
+
 	/*
-	 * inv_drop does not need a context switch, indeed it doesn't
-	 * touch any LO-specific data structures at all.  (Again, that's
-	 * probably more than this module ought to be assuming.)
+	 * inv_drop does not need a context switch, indeed it doesn't touch
+	 * any LO-specific data structures at all.	(Again, that's probably
+	 * more than this module ought to be assuming.)
 	 *
 	 * XXX there ought to be some code to clean up any open LOs that
 	 * reference the specified relation... as is, they remain "open".
@@ -417,9 +418,9 @@ lo_export(Oid lobjId, text *filename)
 	/*
 	 * open the file to be written to
 	 *
-	 * Note: we reduce backend's normal 077 umask to the slightly
-	 * friendlier 022.  This code used to drop it all the way to 0,
-	 * but creating world-writable export files doesn't seem wise.
+	 * Note: we reduce backend's normal 077 umask to the slightly friendlier
+	 * 022.  This code used to drop it all the way to 0, but creating
+	 * world-writable export files doesn't seem wise.
 	 */
 	nbytes = VARSIZE(filename) - VARHDRSZ + 1;
 	if (nbytes > FNAME_BUFSIZE)
@@ -470,8 +471,9 @@ lo_commit(bool isCommit)
 
 	currentContext = MemoryContextSwitchTo((MemoryContext) fscxt);
 
-	/* Clean out still-open index scans (not necessary if aborting)
-	 * and clear cookies array so that LO fds are no longer good.
+	/*
+	 * Clean out still-open index scans (not necessary if aborting) and
+	 * clear cookies array so that LO fds are no longer good.
 	 */
 	for (i = 0; i < MAX_LOBJ_FDS; i++)
 	{
diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c
index 799693ca51d0f241eec9129fd5eeff989f9b5139..2bdf5fbf4b416e2704e863f0f1d89bcb5c6f18c3 100644
--- a/src/backend/libpq/hba.c
+++ b/src/backend/libpq/hba.c
@@ -5,7 +5,7 @@
  *	  wherein you authenticate a user by seeing what IP address the system
  *	  says he comes from and possibly using ident).
  *
- *	$Id: hba.c,v 1.50 2000/03/17 02:36:08 tgl Exp $
+ *	$Id: hba.c,v 1.51 2000/04/12 17:15:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -209,31 +209,32 @@ process_hba_record(FILE *file, hbaPort *port, bool *matches_p, bool *error_p)
 		 */
 
 		if ((strcmp(db, port->database) != 0 && strcmp(db, "all") != 0 &&
-		 (strcmp(db, "sameuser") != 0 || strcmp(port->database, port->user) != 0)) ||
-		        port->raddr.sa.sa_family != AF_UNIX)
+			 (strcmp(db, "sameuser") != 0 || strcmp(port->database, port->user) != 0)) ||
+			port->raddr.sa.sa_family != AF_UNIX)
 			return;
 	}
 	else if (strcmp(buf, "host") == 0 || strcmp(buf, "hostssl") == 0)
 	{
 		struct in_addr file_ip_addr,
 					mask;
-		bool discard = 0; /* Discard this entry */
+		bool		discard = 0;/* Discard this entry */
 
 #ifdef USE_SSL
 		/* If SSL, then check that we are on SSL */
-		if (strcmp(buf, "hostssl") == 0) {
-		  if (!port->ssl) 
-		    discard = 1; 
-		  
-		  /* Placeholder to require specific SSL level, perhaps? */
-		  /* Or a client certificate */
-
-		  /* Since we were on SSL, proceed as with normal 'host' mode */
+		if (strcmp(buf, "hostssl") == 0)
+		{
+			if (!port->ssl)
+				discard = 1;
+
+			/* Placeholder to require specific SSL level, perhaps? */
+			/* Or a client certificate */
+
+			/* Since we were on SSL, proceed as with normal 'host' mode */
 		}
 #else
 		/* If not SSL, we don't support this */
-		if (strcmp(buf,"hostssl") == 0) 
-		  goto syntax;
+		if (strcmp(buf, "hostssl") == 0)
+			goto syntax;
 #endif
 
 		/* Get the database. */
@@ -286,7 +287,7 @@ process_hba_record(FILE *file, hbaPort *port, bool *matches_p, bool *error_p)
 		 * "out of sync" with the file.
 		 */
 		if (discard)
-		  return;
+			return;
 
 		/*
 		 * If this record isn't for our database, or this is the wrong
@@ -294,8 +295,8 @@ process_hba_record(FILE *file, hbaPort *port, bool *matches_p, bool *error_p)
 		 */
 
 		if ((strcmp(db, port->database) != 0 && strcmp(db, "all") != 0 &&
-		 (strcmp(db, "sameuser") != 0 || strcmp(port->database, port->user) != 0)) ||
-		        port->raddr.sa.sa_family != AF_INET ||
+			 (strcmp(db, "sameuser") != 0 || strcmp(port->database, port->user) != 0)) ||
+			port->raddr.sa.sa_family != AF_INET ||
 			((file_ip_addr.s_addr ^ port->raddr.in.sin_addr.s_addr) & mask.s_addr) != 0x0000)
 			return;
 	}
@@ -353,7 +354,7 @@ process_open_config_file(FILE *file, hbaPort *port, bool *hba_ok_p)
 		/* If no matching entry was found, synthesize 'reject' entry. */
 
 		if (!found_entry)
-		        port->auth_method = uaReject;
+			port->auth_method = uaReject;
 
 		*hba_ok_p = true;
 	}
diff --git a/src/backend/libpq/portalbuf.c b/src/backend/libpq/portalbuf.c
index 44be2950611a6ff2c659bebb5cba7c03effd7327..3cab2e4a7df2d7747e27d8dd14b350fbb85adb07 100644
--- a/src/backend/libpq/portalbuf.c
+++ b/src/backend/libpq/portalbuf.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/libpq/Attic/portalbuf.c,v 1.23 2000/03/17 02:36:08 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/libpq/Attic/portalbuf.c,v 1.24 2000/04/12 17:15:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -88,7 +88,7 @@ portals_realloc(size_t size)
 		portals = newp;
 	else
 		libpq_raise(&PortalError,
-					vararg_format("Cannot alloc more memory in portals_realloc"));
+		   vararg_format("Cannot alloc more memory in portals_realloc"));
 
 	for (i = oldsize; i < (int) portals_array_size; i++)
 		portals[i] = (PortalEntry *) NULL;
@@ -461,7 +461,7 @@ pbuf_findGroup(PortalBuffer *portal,
 
 	if (group == NULL)
 		libpq_raise(&PortalError,
-					vararg_format("Group index %d out of bound.", group_index));
+			 vararg_format("Group index %d out of bound.", group_index));
 
 	return group;
 }
@@ -484,7 +484,7 @@ pbuf_findFnumber(GroupBuffer *group,
 			return i;
 
 	libpq_raise(&PortalError,
-				vararg_format("Field-name %s does not exist.", field_name));
+			 vararg_format("Field-name %s does not exist.", field_name));
 
 	/* not reached, here to make compiler happy */
 	return 0;
@@ -501,7 +501,7 @@ pbuf_checkFnumber(GroupBuffer *group,
 {
 	if (field_number < 0 || field_number >= group->no_fields)
 		libpq_raise(&PortalError,
-					vararg_format("Field number %d out of bound.", field_number));
+		   vararg_format("Field number %d out of bound.", field_number));
 }
 
 /* --------------------------------
diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c
index 3895ae546f070b187808614cfd1322dd05b96ba4..61c9e97b39229d029b158adea6e3fa3cc9a59e21 100644
--- a/src/backend/libpq/pqcomm.c
+++ b/src/backend/libpq/pqcomm.c
@@ -29,7 +29,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- *	$Id: pqcomm.c,v 1.87 2000/01/26 05:56:29 momjian Exp $
+ *	$Id: pqcomm.c,v 1.88 2000/04/12 17:15:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -75,7 +75,7 @@
 #include "postgres.h"
 
 #include "libpq/libpq.h"
-#include "utils/trace.h" /* needed for HAVE_FCNTL_SETLK */
+#include "utils/trace.h"		/* needed for HAVE_FCNTL_SETLK */
 #include "miscadmin.h"
 
 
@@ -270,7 +270,7 @@ StreamServerPort(char *hostName, unsigned short portName, int *fdP)
 	{
 		snprintf(PQerrormsg, PQERRORMSG_LENGTH,
 				 "FATAL: StreamServerPort: bind() failed: %s\n"
-				 "\tIs another postmaster already running on that port?\n",
+			   "\tIs another postmaster already running on that port?\n",
 				 strerror(errno));
 		if (family == AF_UNIX)
 			snprintf(PQerrormsg + strlen(PQerrormsg),
@@ -438,15 +438,15 @@ pq_recvbuf(void)
 	for (;;)
 	{
 		int			r;
-		
+
 #ifdef USE_SSL
 		if (MyProcPort->ssl)
-		  r = SSL_read(MyProcPort->ssl, PqRecvBuffer + PqRecvLength,
-			       PQ_BUFFER_SIZE - PqRecvLength);
+			r = SSL_read(MyProcPort->ssl, PqRecvBuffer + PqRecvLength,
+						 PQ_BUFFER_SIZE - PqRecvLength);
 		else
 #endif
-		  r = recv(MyProcPort->sock, PqRecvBuffer + PqRecvLength,
-			   PQ_BUFFER_SIZE - PqRecvLength, 0);
+			r = recv(MyProcPort->sock, PqRecvBuffer + PqRecvLength,
+					 PQ_BUFFER_SIZE - PqRecvLength, 0);
 
 		if (r < 0)
 		{
@@ -561,9 +561,7 @@ pq_getstring(StringInfo s)
 
 	/* Read until we get the terminating '\0' */
 	while ((c = pq_getbyte()) != EOF && c != '\0')
-	{
 		appendStringInfoChar(s, c);
-	}
 
 	if (c == EOF)
 		return EOF;
@@ -614,12 +612,13 @@ pq_flush(void)
 	while (bufptr < bufend)
 	{
 		int			r;
+
 #ifdef USE_SSL
 		if (MyProcPort->ssl)
-		  r = SSL_write(MyProcPort->ssl, bufptr, bufend - bufptr);
+			r = SSL_write(MyProcPort->ssl, bufptr, bufend - bufptr);
 		else
 #endif
-		  r = send(MyProcPort->sock, bufptr, bufend - bufptr, 0);
+			r = send(MyProcPort->sock, bufptr, bufend - bufptr, 0);
 
 		if (r <= 0)
 		{
diff --git a/src/backend/libpq/pqformat.c b/src/backend/libpq/pqformat.c
index 9147039a008aa3b9f8622ccfc9c9898368605f91..7275893c5c0fd49a8afa509beb8574fc4e7ac050 100644
--- a/src/backend/libpq/pqformat.c
+++ b/src/backend/libpq/pqformat.c
@@ -16,7 +16,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- *	$Id: pqformat.c,v 1.12 2000/01/26 05:56:29 momjian Exp $
+ *	$Id: pqformat.c,v 1.13 2000/04/12 17:15:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -156,6 +156,7 @@ void
 pq_sendstring(StringInfo buf, const char *str)
 {
 	int			slen = strlen(str);
+
 #ifdef MULTIBYTE
 	char	   *p;
 
@@ -237,13 +238,15 @@ int
 pq_puttextmessage(char msgtype, const char *str)
 {
 	int			slen = strlen(str);
+
 #ifdef MULTIBYTE
 	char	   *p;
 
 	p = (char *) pg_server_to_client((unsigned char *) str, slen);
 	if (p != str)				/* actual conversion has been done? */
 	{
-		int result = pq_putmessage(msgtype, p, strlen(p) + 1);
+		int			result = pq_putmessage(msgtype, p, strlen(p) + 1);
+
 		pfree(p);
 		return result;
 	}
@@ -308,8 +311,10 @@ int
 pq_getstr(StringInfo s)
 {
 	int			result;
+
 #ifdef MULTIBYTE
 	char	   *p;
+
 #endif
 
 	result = pq_getstring(s);
diff --git a/src/backend/libpq/pqpacket.c b/src/backend/libpq/pqpacket.c
index 21dd26ca1786cf45811a87d7a89bc1fae20fa5ef..defc57f69af278b3e890851076182221bafee499 100644
--- a/src/backend/libpq/pqpacket.c
+++ b/src/backend/libpq/pqpacket.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/libpq/Attic/pqpacket.c,v 1.25 2000/03/19 22:10:07 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/libpq/Attic/pqpacket.c,v 1.26 2000/04/12 17:15:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -54,17 +54,17 @@ int
 PacketReceiveFragment(Port *port)
 {
 	int			got;
-	Packet                  *pkt = &port->pktInfo;
+	Packet	   *pkt = &port->pktInfo;
 
 #ifdef USE_SSL
-	if (port->ssl) 
-	  got = SSL_read(port->ssl, pkt->ptr, pkt->nrtodo);
+	if (port->ssl)
+		got = SSL_read(port->ssl, pkt->ptr, pkt->nrtodo);
 	else
 #endif
-  	  got = read(port->sock, pkt->ptr, pkt->nrtodo);
+		got = read(port->sock, pkt->ptr, pkt->nrtodo);
 	if (got > 0)
 	{
-	        pkt->nrtodo -= got;
+		pkt->nrtodo -= got;
 		pkt->ptr += got;
 
 		/* See if we have got what we need for the packet length. */
@@ -143,14 +143,14 @@ int
 PacketSendFragment(Port *port)
 {
 	int			done;
-        Packet                  *pkt = &port->pktInfo;
+	Packet	   *pkt = &port->pktInfo;
 
 #ifdef USE_SSL
-	if (port->ssl) 
-	  done = SSL_write(port->ssl, pkt->ptr, pkt->nrtodo);
+	if (port->ssl)
+		done = SSL_write(port->ssl, pkt->ptr, pkt->nrtodo);
 	else
 #endif
-	  done = write(port->sock, pkt->ptr, pkt->nrtodo);
+		done = write(port->sock, pkt->ptr, pkt->nrtodo);
 
 	if (done > 0)
 	{
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 58774b153aa5142e04935c15021ffb50960a4efd..e146661fb84dd015a4e11ed13a40029a60c5dc63 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.112 2000/04/08 00:21:15 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.113 2000/04/12 17:15:16 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -143,7 +143,7 @@ _copyResult(Result *from)
 	 */
 	if (from->plan.subPlan != NIL)
 		newnode->plan.subPlan = nconc(newnode->plan.subPlan,
-									  pull_subplans(newnode->resconstantqual));
+								pull_subplans(newnode->resconstantqual));
 
 	return newnode;
 }
@@ -259,25 +259,25 @@ _copyIndexScan(IndexScan *from)
 	if (from->scan.plan.subPlan != NIL)
 	{
 		newnode->scan.plan.subPlan = nconc(newnode->scan.plan.subPlan,
-										   pull_subplans((Node *) newnode->indxqual));
+							  pull_subplans((Node *) newnode->indxqual));
 		newnode->scan.plan.subPlan = nconc(newnode->scan.plan.subPlan,
-										   pull_subplans((Node *) newnode->indxqualorig));
+						  pull_subplans((Node *) newnode->indxqualorig));
 	}
 
 	return newnode;
 }
 
 /* ----------------
- *              _copyTidScan
+ *				_copyTidScan
  * ----------------
  */
 static TidScan *
 _copyTidScan(TidScan *from)
 {
-	TidScan	*newnode = makeNode(TidScan);
+	TidScan    *newnode = makeNode(TidScan);
 
 	/* ----------------
- 	 *	copy node superclass fields
+	 *	copy node superclass fields
 	 * ----------------
 	 */
 	CopyPlanFields((Plan *) from, (Plan *) newnode);
@@ -292,7 +292,7 @@ _copyTidScan(TidScan *from)
 	return newnode;
 }
 
-    
+
 /* ----------------
  *		CopyJoinFields
  *
@@ -375,7 +375,7 @@ _copyMergeJoin(MergeJoin *from)
 	 */
 	if (from->join.subPlan != NIL)
 		newnode->join.subPlan = nconc(newnode->join.subPlan,
-									  pull_subplans((Node *) newnode->mergeclauses));
+						  pull_subplans((Node *) newnode->mergeclauses));
 
 	return newnode;
 }
@@ -408,7 +408,7 @@ _copyHashJoin(HashJoin *from)
 	 */
 	if (from->join.subPlan != NIL)
 		newnode->join.subPlan = nconc(newnode->join.subPlan,
-									  pull_subplans((Node *) newnode->hashclauses));
+						   pull_subplans((Node *) newnode->hashclauses));
 
 	return newnode;
 }
@@ -871,7 +871,7 @@ _copyAggref(Aggref *from)
 	newnode->usenulls = from->usenulls;
 	newnode->aggstar = from->aggstar;
 	newnode->aggdistinct = from->aggdistinct;
-	newnode->aggno = from->aggno; /* probably not needed */
+	newnode->aggno = from->aggno;		/* probably not needed */
 
 	return newnode;
 }
@@ -905,7 +905,7 @@ _copySubLink(SubLink *from)
 static RelabelType *
 _copyRelabelType(RelabelType *from)
 {
-	RelabelType    *newnode = makeNode(RelabelType);
+	RelabelType *newnode = makeNode(RelabelType);
 
 	/* ----------------
 	 *	copy remainder of node
@@ -1108,6 +1108,7 @@ _copyIndexOptInfo(IndexOptInfo *from)
 static void
 CopyPathFields(Path *from, Path *newnode)
 {
+
 	/*
 	 * Modify the next line, since it causes the copying to cycle (i.e.
 	 * the parent points right back here! -- JMH, 7/7/92. Old version:
@@ -1166,13 +1167,13 @@ _copyIndexPath(IndexPath *from)
 }
 
 /* ----------------
- *              _copyTidPath
+ *				_copyTidPath
  * ----------------
  */
 static TidPath *
 _copyTidPath(TidPath *from)
 {
-	TidPath	*newnode = makeNode(TidPath);
+	TidPath    *newnode = makeNode(TidPath);
 
 	/* ----------------
 	 *	copy the node superclass fields
@@ -1189,6 +1190,7 @@ _copyTidPath(TidPath *from)
 
 	return newnode;
 }
+
 /* ----------------
  *		CopyJoinPathFields
  *
@@ -1282,7 +1284,7 @@ _copyHashPath(HashPath *from)
 static PathKeyItem *
 _copyPathKeyItem(PathKeyItem *from)
 {
-	PathKeyItem   *newnode = makeNode(PathKeyItem);
+	PathKeyItem *newnode = makeNode(PathKeyItem);
 
 	/* ----------------
 	 *	copy remainder of node
@@ -1497,8 +1499,8 @@ _copyQuery(Query *from)
 
 	/*
 	 * We do not copy the planner internal fields: base_rel_list,
-	 * join_rel_list, equi_key_list, query_pathkeys.
-	 * Not entirely clear if this is right?
+	 * join_rel_list, equi_key_list, query_pathkeys. Not entirely clear if
+	 * this is right?
 	 */
 
 	return newnode;
@@ -1507,7 +1509,7 @@ _copyQuery(Query *from)
 static ClosePortalStmt *
 _copyClosePortalStmt(ClosePortalStmt *from)
 {
-	ClosePortalStmt	   *newnode = makeNode(ClosePortalStmt);
+	ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
 
 	if (from->portalname)
 		newnode->portalname = pstrdup(from->portalname);
@@ -1518,7 +1520,7 @@ _copyClosePortalStmt(ClosePortalStmt *from)
 static TruncateStmt *
 _copyTruncateStmt(TruncateStmt *from)
 {
-	TruncateStmt	   *newnode = makeNode(TruncateStmt);
+	TruncateStmt *newnode = makeNode(TruncateStmt);
 
 	newnode->relName = pstrdup(from->relName);
 
@@ -1528,7 +1530,7 @@ _copyTruncateStmt(TruncateStmt *from)
 static NotifyStmt *
 _copyNotifyStmt(NotifyStmt *from)
 {
-	NotifyStmt	   *newnode = makeNode(NotifyStmt);
+	NotifyStmt *newnode = makeNode(NotifyStmt);
 
 	if (from->relname)
 		newnode->relname = pstrdup(from->relname);
@@ -1539,7 +1541,7 @@ _copyNotifyStmt(NotifyStmt *from)
 static ListenStmt *
 _copyListenStmt(ListenStmt *from)
 {
-	ListenStmt	   *newnode = makeNode(ListenStmt);
+	ListenStmt *newnode = makeNode(ListenStmt);
 
 	if (from->relname)
 		newnode->relname = pstrdup(from->relname);
@@ -1550,7 +1552,7 @@ _copyListenStmt(ListenStmt *from)
 static UnlistenStmt *
 _copyUnlistenStmt(UnlistenStmt *from)
 {
-	UnlistenStmt	   *newnode = makeNode(UnlistenStmt);
+	UnlistenStmt *newnode = makeNode(UnlistenStmt);
 
 	if (from->relname)
 		newnode->relname = pstrdup(from->relname);
@@ -1561,7 +1563,7 @@ _copyUnlistenStmt(UnlistenStmt *from)
 static TransactionStmt *
 _copyTransactionStmt(TransactionStmt *from)
 {
-	TransactionStmt	   *newnode = makeNode(TransactionStmt);
+	TransactionStmt *newnode = makeNode(TransactionStmt);
 
 	newnode->command = from->command;
 
@@ -1571,7 +1573,7 @@ _copyTransactionStmt(TransactionStmt *from)
 static LoadStmt *
 _copyLoadStmt(LoadStmt *from)
 {
-	LoadStmt	   *newnode = makeNode(LoadStmt);
+	LoadStmt   *newnode = makeNode(LoadStmt);
 
 	if (from->filename)
 		newnode->filename = pstrdup(from->filename);
@@ -1582,7 +1584,7 @@ _copyLoadStmt(LoadStmt *from)
 static VariableSetStmt *
 _copyVariableSetStmt(VariableSetStmt *from)
 {
-	VariableSetStmt	   *newnode = makeNode(VariableSetStmt);
+	VariableSetStmt *newnode = makeNode(VariableSetStmt);
 
 	if (from->name)
 		newnode->name = pstrdup(from->name);
@@ -1595,7 +1597,7 @@ _copyVariableSetStmt(VariableSetStmt *from)
 static VariableResetStmt *
 _copyVariableResetStmt(VariableResetStmt *from)
 {
-	VariableResetStmt	   *newnode = makeNode(VariableResetStmt);
+	VariableResetStmt *newnode = makeNode(VariableResetStmt);
 
 	if (from->name)
 		newnode->name = pstrdup(from->name);
@@ -1606,7 +1608,7 @@ _copyVariableResetStmt(VariableResetStmt *from)
 static LockStmt *
 _copyLockStmt(LockStmt *from)
 {
-	LockStmt	   *newnode = makeNode(LockStmt);
+	LockStmt   *newnode = makeNode(LockStmt);
 
 	if (from->relname)
 		newnode->relname = pstrdup(from->relname);
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index 139822ffae914a6fb88e5dc16bf768e21354f801..ddb5c72391b2f9a804f5f2bd82ca999306bdb070 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.65 2000/03/22 22:08:32 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.66 2000/04/12 17:15:16 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -81,9 +81,11 @@ _equalFjoin(Fjoin *a, Fjoin *b)
 static bool
 _equalExpr(Expr *a, Expr *b)
 {
-	/* We do not examine typeOid, since the optimizer often doesn't
-	 * bother to set it in created nodes, and it is logically a
-	 * derivative of the oper field anyway.
+
+	/*
+	 * We do not examine typeOid, since the optimizer often doesn't bother
+	 * to set it in created nodes, and it is logically a derivative of the
+	 * oper field anyway.
 	 */
 	if (a->opType != b->opType)
 		return false;
@@ -134,7 +136,9 @@ _equalOper(Oper *a, Oper *b)
 		return false;
 	if (a->opresulttype != b->opresulttype)
 		return false;
-	/* We do not examine opid, opsize, or op_fcache, since these are
+
+	/*
+	 * We do not examine opid, opsize, or op_fcache, since these are
 	 * logically derived from opno, and they may not be set yet depending
 	 * on how far along the node is in the parse/plan pipeline.
 	 *
@@ -156,10 +160,11 @@ _equalConst(Const *a, Const *b)
 	if (a->constbyval != b->constbyval)
 		return false;
 	/* XXX What about constisset and constiscast? */
+
 	/*
-	 * We treat all NULL constants of the same type as equal.
-	 * Someday this might need to change?  But datumIsEqual
-	 * doesn't work on nulls, so...
+	 * We treat all NULL constants of the same type as equal. Someday this
+	 * might need to change?  But datumIsEqual doesn't work on nulls,
+	 * so...
 	 */
 	if (a->constisnull)
 		return true;
@@ -320,7 +325,9 @@ _equalArrayRef(ArrayRef *a, ArrayRef *b)
 static bool
 _equalRelOptInfo(RelOptInfo *a, RelOptInfo *b)
 {
-	/* We treat RelOptInfos as equal if they refer to the same base rels
+
+	/*
+	 * We treat RelOptInfos as equal if they refer to the same base rels
 	 * joined in the same order.  Is this sufficient?
 	 */
 	return equali(a->relids, b->relids);
@@ -329,8 +336,10 @@ _equalRelOptInfo(RelOptInfo *a, RelOptInfo *b)
 static bool
 _equalIndexOptInfo(IndexOptInfo *a, IndexOptInfo *b)
 {
-	/* We treat IndexOptInfos as equal if they refer to the same index.
-	 * Is this sufficient?
+
+	/*
+	 * We treat IndexOptInfos as equal if they refer to the same index. Is
+	 * this sufficient?
 	 */
 	if (a->indexoid != b->indexoid)
 		return false;
@@ -354,7 +363,9 @@ _equalPath(Path *a, Path *b)
 		return false;
 	if (!equal(a->parent, b->parent))
 		return false;
-	/* do not check path costs, since they may not be set yet, and being
+
+	/*
+	 * do not check path costs, since they may not be set yet, and being
 	 * float values there are roundoff error issues anyway...
 	 */
 	if (!equal(a->pathkeys, b->pathkeys))
@@ -375,8 +386,10 @@ _equalIndexPath(IndexPath *a, IndexPath *b)
 		return false;
 	if (!equali(a->joinrelids, b->joinrelids))
 		return false;
-	/* Skip 'rows' because of possibility of floating-point roundoff error.
-	 * It should be derivable from the other fields anyway.
+
+	/*
+	 * Skip 'rows' because of possibility of floating-point roundoff
+	 * error. It should be derivable from the other fields anyway.
 	 */
 	return true;
 }
@@ -442,12 +455,13 @@ _equalHashPath(HashPath *a, HashPath *b)
 /* XXX	This equality function is a quick hack, should be
  *		fixed to compare all fields.
  *
- * XXX  Why is this even here?  We don't have equal() funcs for
- *      any other kinds of Plan nodes... likely this is dead code...
+ * XXX	Why is this even here?	We don't have equal() funcs for
+ *		any other kinds of Plan nodes... likely this is dead code...
  */
 static bool
 _equalIndexScan(IndexScan *a, IndexScan *b)
 {
+
 	/*
 	 * if(a->scan.plan.cost != b->scan.plan.cost) return(false);
 	 */
@@ -642,9 +656,9 @@ _equalQuery(Query *a, Query *b)
 
 	/*
 	 * We do not check the internal-to-the-planner fields: base_rel_list,
-	 * join_rel_list, equi_key_list, query_pathkeys.
-	 * They might not be set yet, and in any case they should be derivable
-	 * from the other fields.
+	 * join_rel_list, equi_key_list, query_pathkeys. They might not be set
+	 * yet, and in any case they should be derivable from the other
+	 * fields.
 	 */
 	return true;
 }
@@ -882,7 +896,8 @@ equal(void *a, void *b)
 				List	   *lb = (List *) b;
 				List	   *l;
 
-				/* Try to reject by length check before we grovel through
+				/*
+				 * Try to reject by length check before we grovel through
 				 * all the elements...
 				 */
 				if (length(la) != length(lb))
diff --git a/src/backend/nodes/freefuncs.c b/src/backend/nodes/freefuncs.c
index 96ce56c94c4ae18e083eae148c75d255fe7b9344..c0d07a05dbae8d2ad2773df87387dd784b599693 100644
--- a/src/backend/nodes/freefuncs.c
+++ b/src/backend/nodes/freefuncs.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.39 2000/03/14 23:06:28 thomas Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.40 2000/04/12 17:15:16 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -746,7 +746,9 @@ _freeRelOptInfo(RelOptInfo *node)
 
 	freeObject(node->targetlist);
 	freeObject(node->pathlist);
-	/* XXX is this right? cheapest-path fields will typically be pointers
+
+	/*
+	 * XXX is this right? cheapest-path fields will typically be pointers
 	 * into pathlist, not separate structs...
 	 */
 	freeObject(node->cheapest_startup_path);
@@ -870,7 +872,9 @@ FreeJoinPathFields(JoinPath *node)
 {
 	freeObject(node->outerjoinpath);
 	freeObject(node->innerjoinpath);
-	/* XXX probably wrong, since ordinarily a JoinPath would share its
+
+	/*
+	 * XXX probably wrong, since ordinarily a JoinPath would share its
 	 * restrictinfo list with other paths made for the same join?
 	 */
 	freeObject(node->joinrestrictinfo);
@@ -970,7 +974,9 @@ _freeRestrictInfo(RestrictInfo *node)
 	 * ----------------
 	 */
 	freeObject(node->clause);
-	/* this is certainly wrong?  IndexOptInfos don't belong to
+
+	/*
+	 * this is certainly wrong?  IndexOptInfos don't belong to
 	 * RestrictInfo...
 	 */
 	freeObject(node->subclauseindices);
@@ -1131,8 +1137,8 @@ _freeValue(Value *node)
 {
 	switch (node->type)
 	{
-		case T_Float:
-		case T_String:
+			case T_Float:
+			case T_String:
 			pfree(node->val.str);
 			break;
 		default:
diff --git a/src/backend/nodes/list.c b/src/backend/nodes/list.c
index a47851f2420b8b066c5b23ea706658453b08dbb6..66d69199beb433cf7d1e47a63f345678aea5dc39 100644
--- a/src/backend/nodes/list.c
+++ b/src/backend/nodes/list.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.30 2000/02/21 18:47:00 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.31 2000/04/12 17:15:16 momjian Exp $
  *
  * NOTES
  *	  XXX a few of the following functions are duplicated to handle
@@ -251,9 +251,9 @@ length(List *l)
  *	freeList
  *
  *	Free the List nodes of a list
- *  The pointed-to nodes, if any, are NOT freed.
- *  This works for integer lists too.
- * 
+ *	The pointed-to nodes, if any, are NOT freed.
+ *	This works for integer lists too.
+ *
  */
 void
 freeList(List *list)
@@ -314,7 +314,7 @@ LispUnion(List *l1, List *l2)
 
 	foreach(i, l2)
 	{
-		if (! member(lfirst(i), retval))
+		if (!member(lfirst(i), retval))
 			retval = lappend(retval, lfirst(i));
 	}
 	return retval;
@@ -328,7 +328,7 @@ LispUnioni(List *l1, List *l2)
 
 	foreach(i, l2)
 	{
-		if (! intMember(lfirsti(i), retval))
+		if (!intMember(lfirsti(i), retval))
 			retval = lappendi(retval, lfirsti(i));
 	}
 	return retval;
@@ -459,7 +459,7 @@ intLispRemove(int elem, List *list)
 List *
 ltruncate(int n, List *list)
 {
-	List	*ptr;
+	List	   *ptr;
 
 	if (n <= 0)
 		return NIL;				/* truncate to zero length */
@@ -494,7 +494,7 @@ set_difference(List *l1, List *l2)
 
 	foreach(i, l1)
 	{
-		if (! member(lfirst(i), l2))
+		if (!member(lfirst(i), l2))
 			result = lappend(result, lfirst(i));
 	}
 	return result;
@@ -516,7 +516,7 @@ set_differencei(List *l1, List *l2)
 
 	foreach(i, l1)
 	{
-		if (! intMember(lfirsti(i), l2))
+		if (!intMember(lfirsti(i), l2))
 			result = lappendi(result, lfirsti(i));
 	}
 	return result;
diff --git a/src/backend/nodes/makefuncs.c b/src/backend/nodes/makefuncs.c
index e42930ef87b64495ab60f12d0b998044eb39bf6d..4bad2008d77a8dd206440fc85af9111fdeeb2c18 100644
--- a/src/backend/nodes/makefuncs.c
+++ b/src/backend/nodes/makefuncs.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.20 2000/02/15 03:37:09 thomas Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.21 2000/04/12 17:15:16 momjian Exp $
  *
  * NOTES
  *	  Creator functions in POSTGRES 4.2 are generated automatically. Most of
@@ -62,11 +62,13 @@ makeVar(Index varno,
 	var->vartype = vartype;
 	var->vartypmod = vartypmod;
 	var->varlevelsup = varlevelsup;
+
 	/*
-	 * Since few if any routines ever create Var nodes with varnoold/varoattno
-	 * different from varno/varattno, we don't provide separate arguments
-	 * for them, but just initialize them to the given varno/varattno.
-	 * This reduces code clutter and chance of error for most callers.
+	 * Since few if any routines ever create Var nodes with
+	 * varnoold/varoattno different from varno/varattno, we don't provide
+	 * separate arguments for them, but just initialize them to the given
+	 * varno/varattno. This reduces code clutter and chance of error for
+	 * most callers.
 	 */
 	var->varnoold = varno;
 	var->varoattno = varattno;
@@ -107,7 +109,9 @@ makeResdom(AttrNumber resno,
 	resdom->restype = restype;
 	resdom->restypmod = restypmod;
 	resdom->resname = resname;
-	/* For historical reasons, ressortgroupref defaults to 0 while
+
+	/*
+	 * For historical reasons, ressortgroupref defaults to 0 while
 	 * reskey/reskeyop are passed in explicitly.  This is pretty silly.
 	 */
 	resdom->ressortgroupref = 0;
@@ -159,8 +163,3 @@ makeAttr(char *relname, char *attname)
 
 	return a;
 }
-
-
-
-
-
diff --git a/src/backend/nodes/nodes.c b/src/backend/nodes/nodes.c
index 3615a762a8ab38b1846fb7e27ec047a9fba96520..0f0c417f68ce2cedcf747712dd8db3ee4d0354d7 100644
--- a/src/backend/nodes/nodes.c
+++ b/src/backend/nodes/nodes.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/nodes/nodes.c,v 1.12 2000/01/26 05:56:31 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/nodes/nodes.c,v 1.13 2000/04/12 17:15:16 momjian Exp $
  *
  * HISTORY
  *	  Andrew Yu			Oct 20, 1994	file creation
@@ -33,7 +33,7 @@ newNode(Size size, NodeTag tag)
 {
 	Node	   *newNode;
 
-	Assert(size >= sizeof(Node)); /* need the tag, at least */
+	Assert(size >= sizeof(Node));		/* need the tag, at least */
 
 	newNode = (Node *) palloc(size);
 	MemSet((char *) newNode, 0, size);
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 489e4fbbf915443860ac23810545fa6da915b58f..a870a9f5702747aef517f485837b00743c904097 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- *	$Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.113 2000/03/24 02:58:25 tgl Exp $
+ *	$Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.114 2000/04/12 17:15:16 momjian Exp $
  *
  * NOTES
  *	  Every (plan) node in POSTGRES has an associated "out" routine which
@@ -60,10 +60,11 @@ _outToken(StringInfo str, char *s)
 		appendStringInfo(str, "<>");
 		return;
 	}
+
 	/*
 	 * Look for characters or patterns that are treated specially by
-	 * read.c (either in lsptok() or in nodeRead()), and therefore need
-	 * a protective backslash.
+	 * read.c (either in lsptok() or in nodeRead()), and therefore need a
+	 * protective backslash.
 	 */
 	/* These characters only need to be quoted at the start of the string */
 	if (*s == '<' ||
@@ -256,7 +257,7 @@ _outQuery(StringInfo str, Query *node)
 	_outToken(str, node->into);
 
 	appendStringInfo(str,
-					 " :isPortal %s :isBinary %s :isTemp %s :unionall %s :distinctClause ",
+	" :isPortal %s :isBinary %s :isTemp %s :unionall %s :distinctClause ",
 					 node->isPortal ? "true" : "false",
 					 node->isBinary ? "true" : "false",
 					 node->isTemp ? "true" : "false",
@@ -633,7 +634,7 @@ static void
 _outResdom(StringInfo str, Resdom *node)
 {
 	appendStringInfo(str,
-					 " RESDOM :resno %d :restype %u :restypmod %d :resname ",
+				 " RESDOM :resno %d :restype %u :restypmod %d :resname ",
 					 node->resno,
 					 node->restype,
 					 node->restypmod);
@@ -925,7 +926,7 @@ _outRelOptInfo(StringInfo str, RelOptInfo *node)
 	_outIntList(str, node->relids);
 
 	appendStringInfo(str,
-	 " :rows %.0f :width %d :indexed %s :pages %ld :tuples %.0f :targetlist ",
+					 " :rows %.0f :width %d :indexed %s :pages %ld :tuples %.0f :targetlist ",
 					 node->rows,
 					 node->width,
 					 node->indexed ? "true" : "false",
@@ -983,7 +984,7 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
 	appendStringInfo(str, " :ref ");
 	_outNode(str, node->ref);
 	appendStringInfo(str,
-					 " :relid %u :inh %s :inFromCl %s :inJoinSet %s :skipAcl %s",
+			 " :relid %u :inh %s :inFromCl %s :inJoinSet %s :skipAcl %s",
 					 node->relid,
 					 node->inh ? "true" : "false",
 					 node->inFromCl ? "true" : "false",
@@ -1004,7 +1005,7 @@ static void
 _outPath(StringInfo str, Path *node)
 {
 	appendStringInfo(str,
-					 " PATH :pathtype %d :startup_cost %.2f :total_cost %.2f :pathkeys ",
+	 " PATH :pathtype %d :startup_cost %.2f :total_cost %.2f :pathkeys ",
 					 node->pathtype,
 					 node->startup_cost,
 					 node->total_cost);
@@ -1282,12 +1283,14 @@ _outValue(StringInfo str, Value *value)
 {
 	switch (value->type)
 	{
-		case T_Integer:
+			case T_Integer:
 			appendStringInfo(str, " %ld ", value->val.ival);
 			break;
 		case T_Float:
-			/* We assume the value is a valid numeric literal
-			 * and so does not need quoting.
+
+			/*
+			 * We assume the value is a valid numeric literal and so does
+			 * not need quoting.
 			 */
 			appendStringInfo(str, " %s ", value->val.str);
 			break;
diff --git a/src/backend/nodes/print.c b/src/backend/nodes/print.c
index 248991c0928623d1e224c11159cb1d12dfa960bf..8d3cd8d2a7b7f17efb5a35fb86d3f34d827ba181 100644
--- a/src/backend/nodes/print.c
+++ b/src/backend/nodes/print.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.37 2000/02/15 20:49:12 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.38 2000/04/12 17:15:16 momjian Exp $
  *
  * HISTORY
  *	  AUTHOR			DATE			MAJOR EVENT
@@ -176,7 +176,7 @@ print_expr(Node *expr, List *rtable)
 					rt = rt_fetch(var->varno, rtable);
 					relname = rt->relname;
 					if (rt->ref && rt->ref->relname)
-						relname = rt->ref->relname;	/* table renamed */
+						relname = rt->ref->relname;		/* table renamed */
 					attname = get_attname(rt->relid, var->varattno);
 				}
 				break;
@@ -221,7 +221,7 @@ print_pathkeys(List *pathkeys, List *rtable)
 		printf("(");
 		foreach(k, pathkey)
 		{
-			PathKeyItem	*item = lfirst(k);
+			PathKeyItem *item = lfirst(k);
 
 			print_expr(item->key, rtable);
 			if (lnext(k))
diff --git a/src/backend/nodes/read.c b/src/backend/nodes/read.c
index 9f68f4d0e90892e52f5062dbd1ab94b31170c051..258bb7ed30ba512b0814694ce1b6a52c277d2fb2 100644
--- a/src/backend/nodes/read.c
+++ b/src/backend/nodes/read.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/nodes/read.c,v 1.21 2000/02/21 18:47:00 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/nodes/read.c,v 1.22 2000/04/12 17:15:16 momjian Exp $
  *
  * HISTORY
  *	  AUTHOR			DATE			MAJOR EVENT
@@ -60,31 +60,31 @@ stringToNode(char *str)
  * (Pass length==NULL to set the string without reading its first token.)
  *
  * The rules for tokens are:
- *  * Whitespace (space, tab, newline) always separates tokens.
- *  * The characters '(', ')', '{', '}' form individual tokens even
- *    without any whitespace around them.
- *  * Otherwise, a token is all the characters up to the next whitespace
- *    or occurrence of one of the four special characters.
- *  * A backslash '\' can be used to quote whitespace or one of the four
- *    special characters, so that it is treated as a plain token character.
- *    Backslashes themselves must also be backslashed for consistency.
- *    Any other character can be, but need not be, backslashed as well.
- *  * If the resulting token is '<>' (with no backslash), it is returned
- *    as a non-NULL pointer to the token but with length == 0.  Note that
- *    there is no other way to get a zero-length token.
+ *	* Whitespace (space, tab, newline) always separates tokens.
+ *	* The characters '(', ')', '{', '}' form individual tokens even
+ *	  without any whitespace around them.
+ *	* Otherwise, a token is all the characters up to the next whitespace
+ *	  or occurrence of one of the four special characters.
+ *	* A backslash '\' can be used to quote whitespace or one of the four
+ *	  special characters, so that it is treated as a plain token character.
+ *	  Backslashes themselves must also be backslashed for consistency.
+ *	  Any other character can be, but need not be, backslashed as well.
+ *	* If the resulting token is '<>' (with no backslash), it is returned
+ *	  as a non-NULL pointer to the token but with length == 0.	Note that
+ *	  there is no other way to get a zero-length token.
  *
  * Returns a pointer to the start of the next token, and the length of the
- * token (including any embedded backslashes!) in *length.  If there are
+ * token (including any embedded backslashes!) in *length.	If there are
  * no more tokens, NULL and 0 are returned.
  *
  * NOTE: this routine doesn't remove backslashes; the caller must do so
  * if necessary (see "debackslash").
  *
  * NOTE: prior to release 7.0, this routine also had a special case to treat
- * a token starting with '"' as extending to the next '"'.  This code was
+ * a token starting with '"' as extending to the next '"'.	This code was
  * broken, however, since it would fail to cope with a string containing an
  * embedded '"'.  I have therefore removed this special case, and instead
- * introduced rules for using backslashes to quote characters.  Higher-level
+ * introduced rules for using backslashes to quote characters.	Higher-level
  * code should add backslashes to a string constant to ensure it is treated
  * as a single token.
  */
@@ -160,8 +160,8 @@ lsptok(char *string, int *length)
 char *
 debackslash(char *token, int length)
 {
-	char   *result = palloc(length+1);
-	char   *ptr = result;
+	char	   *result = palloc(length + 1);
+	char	   *ptr = result;
 
 	while (length > 0)
 	{
@@ -208,22 +208,23 @@ nodeTokenType(char *token, int length)
 	if ((numlen > 0 && isdigit(*numptr)) ||
 		(numlen > 1 && *numptr == '.' && isdigit(numptr[1])))
 	{
+
 		/*
-		 * Yes.  Figure out whether it is integral or float;
-		 * this requires both a syntax check and a range check.
-		 * strtol() can do both for us.
-		 * We know the token will end at a character that strtol will
+		 * Yes.  Figure out whether it is integral or float; this requires
+		 * both a syntax check and a range check. strtol() can do both for
+		 * us. We know the token will end at a character that strtol will
 		 * stop at, so we do not need to modify the string.
 		 */
 		errno = 0;
 		(void) strtol(token, &endptr, 10);
-		if (endptr != token+length || errno == ERANGE)
+		if (endptr != token + length || errno == ERANGE)
 			return T_Float;
 		return T_Integer;
 	}
+
 	/*
-	 * these three cases do not need length checks, since lsptok()
-	 * will always treat them as single-byte tokens
+	 * these three cases do not need length checks, since lsptok() will
+	 * always treat them as single-byte tokens
 	 */
 	else if (*token == '(')
 		retval = LEFT_PAREN;
@@ -233,7 +234,7 @@ nodeTokenType(char *token, int length)
 		retval = PLAN_SYM;
 	else if (*token == '@' && length == 1)
 		retval = AT_SYMBOL;
-	else if (*token == '\"' && length > 1 && token[length-1] == '\"')
+	else if (*token == '\"' && length > 1 && token[length - 1] == '\"')
 		retval = T_String;
 	else
 		retval = ATOM_TOKEN;
@@ -245,10 +246,10 @@ nodeTokenType(char *token, int length)
  *	  Slightly higher-level reader.
  *
  * This routine applies some semantic knowledge on top of the purely
- * lexical tokenizer lsptok().  It can read
+ * lexical tokenizer lsptok().	It can read
  *	* Value token nodes (integers, floats, or strings);
- *  * Plan nodes (via parsePlanString() from readfuncs.c);
- *  * Lists of the above.
+ *	* Plan nodes (via parsePlanString() from readfuncs.c);
+ *	* Lists of the above.
  *
  * Secrets:  He assumes that lsptok already has the string (see above).
  * Any callers should set read_car_only to true.
@@ -305,6 +306,7 @@ nodeRead(bool read_car_only)
 			{
 				/* must be "<>" */
 				this_value = NULL;
+
 				/*
 				 * It might be NULL but it is an atom!
 				 */
@@ -321,13 +323,17 @@ nodeRead(bool read_car_only)
 			}
 			break;
 		case T_Integer:
-			/* we know that the token terminates on a char atol will stop at */
+
+			/*
+			 * we know that the token terminates on a char atol will stop
+			 * at
+			 */
 			this_value = (Node *) makeInteger(atol(token));
 			make_dotted_pair_cell = true;
 			break;
 		case T_Float:
 			{
-				char   *fval = (char *) palloc(tok_len + 1);
+				char	   *fval = (char *) palloc(tok_len + 1);
 
 				memcpy(fval, token, tok_len);
 				fval[tok_len] = '\0';
@@ -337,7 +343,7 @@ nodeRead(bool read_car_only)
 			break;
 		case T_String:
 			/* need to remove leading and trailing quotes, and backslashes */
-			this_value = (Node *) makeString(debackslash(token+1, tok_len-2));
+			this_value = (Node *) makeString(debackslash(token + 1, tok_len - 2));
 			make_dotted_pair_cell = true;
 			break;
 		default:
diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c
index 3a3059ef4e4328390125b28a89473b4038a5e8fa..f16773574df4185830e2dcc63e1eea991c05d2f7 100644
--- a/src/backend/nodes/readfuncs.c
+++ b/src/backend/nodes/readfuncs.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.87 2000/03/22 22:08:32 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.88 2000/04/12 17:15:17 momjian Exp $
  *
  * NOTES
  *	  Most of the read functions for plan nodes are tested. (In fact, they
@@ -538,7 +538,7 @@ _readIndexScan()
 static TidScan *
 _readTidScan()
 {
-	TidScan  *local_node;
+	TidScan    *local_node;
 	char	   *token;
 	int			length;
 
@@ -551,7 +551,7 @@ _readTidScan()
 	local_node->needRescan = atoi(token);
 
 	token = lsptok(NULL, &length);		/* eat :tideval */
-	local_node->tideval = nodeRead(true);	/* now read it */
+	local_node->tideval = nodeRead(true);		/* now read it */
 
 	return local_node;
 }
@@ -1308,17 +1308,17 @@ _readRelOptInfo()
 	local_node->pathlist = nodeRead(true);		/* now read it */
 
 	token = lsptok(NULL, &length);		/* get :cheapest_startup_path */
-	local_node->cheapest_startup_path = nodeRead(true);		/* now read it */
+	local_node->cheapest_startup_path = nodeRead(true); /* now read it */
 
 	token = lsptok(NULL, &length);		/* get :cheapest_total_path */
-	local_node->cheapest_total_path = nodeRead(true);		/* now read it */
+	local_node->cheapest_total_path = nodeRead(true);	/* now read it */
 
 	token = lsptok(NULL, &length);		/* eat :pruneable */
 	token = lsptok(NULL, &length);		/* get :pruneable */
 	local_node->pruneable = (token[0] == 't') ? true : false;
 
 	token = lsptok(NULL, &length);		/* get :baserestrictinfo */
-	local_node->baserestrictinfo = nodeRead(true);	/* now read it */
+	local_node->baserestrictinfo = nodeRead(true);		/* now read it */
 
 	token = lsptok(NULL, &length);		/* get :joininfo */
 	local_node->joininfo = nodeRead(true);		/* now read it */
@@ -1365,7 +1365,7 @@ _readAttr()
 	local_node->relname = debackslash(token, length);
 
 	token = lsptok(NULL, &length);		/* eat :attrs */
-	local_node->attrs = nodeRead(true);	/* now read it */
+	local_node->attrs = nodeRead(true); /* now read it */
 
 	return local_node;
 }
@@ -1526,7 +1526,7 @@ _readIndexPath()
 static TidPath *
 _readTidPath()
 {
-	TidPath  *local_node;
+	TidPath    *local_node;
 	char	   *token;
 	int			length;
 
@@ -1548,7 +1548,7 @@ _readTidPath()
 	local_node->path.pathkeys = nodeRead(true); /* now read it */
 
 	token = lsptok(NULL, &length);		/* get :tideval */
-	local_node->tideval = nodeRead(true);	/* now read it */
+	local_node->tideval = nodeRead(true);		/* now read it */
 
 	token = lsptok(NULL, &length);		/* get :unjoined_relids */
 	local_node->unjoined_relids = toIntList(nodeRead(true));
@@ -1593,7 +1593,7 @@ _readNestPath()
 	local_node->innerjoinpath = nodeRead(true); /* now read it */
 
 	token = lsptok(NULL, &length);		/* get :joinrestrictinfo */
-	local_node->joinrestrictinfo = nodeRead(true); /* now read it */
+	local_node->joinrestrictinfo = nodeRead(true);		/* now read it */
 
 	return local_node;
 }
@@ -1629,13 +1629,13 @@ _readMergePath()
 	local_node->jpath.path.pathkeys = nodeRead(true);	/* now read it */
 
 	token = lsptok(NULL, &length);		/* get :outerjoinpath */
-	local_node->jpath.outerjoinpath = nodeRead(true); /* now read it */
+	local_node->jpath.outerjoinpath = nodeRead(true);	/* now read it */
 
 	token = lsptok(NULL, &length);		/* get :innerjoinpath */
-	local_node->jpath.innerjoinpath = nodeRead(true); /* now read it */
+	local_node->jpath.innerjoinpath = nodeRead(true);	/* now read it */
 
 	token = lsptok(NULL, &length);		/* get :joinrestrictinfo */
-	local_node->jpath.joinrestrictinfo = nodeRead(true); /* now read it */
+	local_node->jpath.joinrestrictinfo = nodeRead(true);		/* now read it */
 
 	token = lsptok(NULL, &length);		/* get :path_mergeclauses */
 	local_node->path_mergeclauses = nodeRead(true);		/* now read it */
@@ -1680,13 +1680,13 @@ _readHashPath()
 	local_node->jpath.path.pathkeys = nodeRead(true);	/* now read it */
 
 	token = lsptok(NULL, &length);		/* get :outerjoinpath */
-	local_node->jpath.outerjoinpath = nodeRead(true); /* now read it */
+	local_node->jpath.outerjoinpath = nodeRead(true);	/* now read it */
 
 	token = lsptok(NULL, &length);		/* get :innerjoinpath */
-	local_node->jpath.innerjoinpath = nodeRead(true); /* now read it */
+	local_node->jpath.innerjoinpath = nodeRead(true);	/* now read it */
 
 	token = lsptok(NULL, &length);		/* get :joinrestrictinfo */
-	local_node->jpath.joinrestrictinfo = nodeRead(true); /* now read it */
+	local_node->jpath.joinrestrictinfo = nodeRead(true);		/* now read it */
 
 	token = lsptok(NULL, &length);		/* get :path_hashclauses */
 	local_node->path_hashclauses = nodeRead(true);		/* now read it */
diff --git a/src/backend/optimizer/geqo/geqo_eval.c b/src/backend/optimizer/geqo/geqo_eval.c
index 1c70e4bcd8d274d591cafe67f96774912052a6e7..6b04eb49ea69c92512b94b14228c23ddae9673d6 100644
--- a/src/backend/optimizer/geqo/geqo_eval.c
+++ b/src/backend/optimizer/geqo/geqo_eval.c
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: geqo_eval.c,v 1.48 2000/02/15 20:49:14 tgl Exp $
+ * $Id: geqo_eval.c,v 1.49 2000/04/12 17:15:18 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -99,8 +99,8 @@ geqo_eval(Query *root, Gene *tour, int num_gene)
 	/*
 	 * compute fitness
 	 *
-	 * XXX geqo does not currently support optimization for partial
-	 * result retrieval --- how to fix?
+	 * XXX geqo does not currently support optimization for partial result
+	 * retrieval --- how to fix?
 	 */
 	fitness = joinrel->cheapest_total_path->total_cost;
 
@@ -135,7 +135,7 @@ gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *old
 		/* tour[0] = 3; tour[1] = 1; tour[2] = 2 */
 		base_rel_index = (int) tour[rel_count];
 
-		inner_rel = (RelOptInfo *) nth(base_rel_index-1, root->base_rel_list);
+		inner_rel = (RelOptInfo *) nth(base_rel_index - 1, root->base_rel_list);
 
 		if (rel_count == 0)
 		{						/* processing first join with
@@ -145,15 +145,15 @@ gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *old
 		}
 		else
 		{						/* tree main part */
-			List   *acceptable_rels = lcons(inner_rel, NIL);
+			List	   *acceptable_rels = lcons(inner_rel, NIL);
 
 			new_rel = make_rels_by_clause_joins(root, old_rel,
 												acceptable_rels);
-			if (! new_rel)
+			if (!new_rel)
 			{
 				new_rel = make_rels_by_clauseless_joins(root, old_rel,
 														acceptable_rels);
-				if (! new_rel)
+				if (!new_rel)
 					elog(ERROR, "gimme_tree: failed to construct join rel");
 			}
 
diff --git a/src/backend/optimizer/path/_deadcode/predmig.c b/src/backend/optimizer/path/_deadcode/predmig.c
index 377a836d9a1346ad3a02f279039a62ca2e1d4305..434780d664cf4540c7cac1fe4b8535fb0c28318a 100644
--- a/src/backend/optimizer/path/_deadcode/predmig.c
+++ b/src/backend/optimizer/path/_deadcode/predmig.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/predmig.c,v 1.6 2000/01/26 05:56:36 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/predmig.c,v 1.7 2000/04/12 17:15:21 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -485,7 +485,7 @@ xfunc_form_groups(Query *queryInfo, Stream root, Stream bottom)
 }
 
 
-/* -------------------					 UTILITY FUNCTIONS	   ------------------------- */
+/* -------------------						 UTILITY FUNCTIONS	   ------------------------- */
 
 /*
  ** xfunc_free_stream
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c
index 572ef00d2e8f2f6b61c215edb25c675cd4d41c76..a2e636395e2e2f93d2a59b349260dfd7e8e13d88 100644
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.59 2000/02/15 20:49:16 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.60 2000/04/12 17:15:19 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -24,8 +24,10 @@
 
 #ifdef GEQO
 bool		enable_geqo = true;
+
 #else
 bool		enable_geqo = false;
+
 #endif
 
 int			geqo_rels = GEQO_RELS;
@@ -36,6 +38,7 @@ static RelOptInfo *make_one_rel_by_joins(Query *root, int levels_needed);
 
 #ifdef OPTIMIZER_DEBUG
 static void debug_print_rel(Query *root, RelOptInfo *rel);
+
 #endif
 
 
@@ -64,6 +67,7 @@ make_one_rel(Query *root)
 
 	if (levels_needed == 1)
 	{
+
 		/*
 		 * Single relation, no more processing is required.
 		 */
@@ -71,6 +75,7 @@ make_one_rel(Query *root)
 	}
 	else
 	{
+
 		/*
 		 * Generate join tree.
 		 */
@@ -100,8 +105,8 @@ set_base_rel_pathlist(Query *root)
 		/*
 		 * Generate paths and add them to the rel's pathlist.
 		 *
-		 * Note: add_path() will discard any paths that are dominated
-		 * by another available path, keeping only those paths that are
+		 * Note: add_path() will discard any paths that are dominated by
+		 * another available path, keeping only those paths that are
 		 * superior along at least one dimension of cost or sortedness.
 		 */
 
@@ -116,9 +121,10 @@ set_base_rel_pathlist(Query *root)
 						   rel->baserestrictinfo,
 						   rel->joininfo);
 
-		/* Note: create_or_index_paths depends on create_index_paths
-		 * to have marked OR restriction clauses with relevant indices;
-		 * this is why it doesn't need to be given the list of indices.
+		/*
+		 * Note: create_or_index_paths depends on create_index_paths to
+		 * have marked OR restriction clauses with relevant indices; this
+		 * is why it doesn't need to be given the list of indices.
 		 */
 		create_or_index_paths(root, rel, rel->baserestrictinfo);
 
@@ -153,11 +159,11 @@ make_one_rel_by_joins(Query *root, int levels_needed)
 		return geqo(root);
 
 	/*
-	 * We employ a simple "dynamic programming" algorithm: we first
-	 * find all ways to build joins of two base relations, then all ways
-	 * to build joins of three base relations (from two-base-rel joins
-	 * and other base rels), then four-base-rel joins, and so on until
-	 * we have considered all ways to join all N relations into one rel.
+	 * We employ a simple "dynamic programming" algorithm: we first find
+	 * all ways to build joins of two base relations, then all ways to
+	 * build joins of three base relations (from two-base-rel joins and
+	 * other base rels), then four-base-rel joins, and so on until we have
+	 * considered all ways to join all N relations into one rel.
 	 */
 
 	for (lev = 2; lev <= levels_needed; lev++)
@@ -185,9 +191,10 @@ make_one_rel_by_joins(Query *root, int levels_needed)
 			rel = (RelOptInfo *) lfirst(x);
 
 #ifdef NOT_USED
+
 			/*
-			 * * for each expensive predicate in each path in each distinct
-			 * rel, * consider doing pullup  -- JMH
+			 * * for each expensive predicate in each path in each
+			 * distinct rel, * consider doing pullup  -- JMH
 			 */
 			if (XfuncMode != XFUNC_NOPULL && XfuncMode != XFUNC_OFF)
 				xfunc_trypullup(rel);
diff --git a/src/backend/optimizer/path/clausesel.c b/src/backend/optimizer/path/clausesel.c
index 985155edf9201b6159461f215a1c610f5a6fa3b9..d430059a1e0bae95cc82eca8ca79f850284f0b11 100644
--- a/src/backend/optimizer/path/clausesel.c
+++ b/src/backend/optimizer/path/clausesel.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.33 2000/03/23 23:35:47 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.34 2000/04/12 17:15:19 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -28,17 +28,18 @@
  * Data structure for accumulating info about possible range-query
  * clause pairs in clauselist_selectivity.
  */
-typedef struct RangeQueryClause {
-	struct RangeQueryClause *next; /* next in linked list */
+typedef struct RangeQueryClause
+{
+	struct RangeQueryClause *next;		/* next in linked list */
 	Node	   *var;			/* The common variable of the clauses */
 	bool		have_lobound;	/* found a low-bound clause yet? */
 	bool		have_hibound;	/* found a high-bound clause yet? */
-	Selectivity	lobound;		/* Selectivity of a var > something clause */
-	Selectivity	hibound;		/* Selectivity of a var < something clause */
+	Selectivity lobound;		/* Selectivity of a var > something clause */
+	Selectivity hibound;		/* Selectivity of a var < something clause */
 } RangeQueryClause;
 
 static void addRangeClause(RangeQueryClause **rqlist, Node *clause,
-						   int flag, bool isLTsel, Selectivity s2);
+			   int flag, bool isLTsel, Selectivity s2);
 
 
 /****************************************************************************
@@ -59,7 +60,7 @@ restrictlist_selectivity(Query *root,
 						 int varRelid)
 {
 	List	   *clauselist = get_actual_clauses(restrictinfo_list);
-	Selectivity	result;
+	Selectivity result;
 
 	result = clauselist_selectivity(root, clauselist, varRelid);
 	freeList(clauselist);
@@ -75,7 +76,7 @@ restrictlist_selectivity(Query *root,
  * See clause_selectivity() for the meaning of the varRelid parameter.
  *
  * Our basic approach is to take the product of the selectivities of the
- * subclauses.  However, that's only right if the subclauses have independent
+ * subclauses.	However, that's only right if the subclauses have independent
  * probabilities, and in reality they are often NOT independent.  So,
  * we want to be smarter where we can.
 
@@ -92,7 +93,7 @@ restrictlist_selectivity(Query *root,
  * see that hisel is the fraction of the range below the high bound, while
  * losel is the fraction above the low bound; so hisel can be interpreted
  * directly as a 0..1 value but we need to convert losel to 1-losel before
- * interpreting it as a value.  Then the available range is 1-losel to hisel.)
+ * interpreting it as a value.	Then the available range is 1-losel to hisel.)
  * If the calculation yields zero or negative, however, we chicken out and
  * use the default interpretation; that probably means that one or both
  * selectivities is a default estimate rather than an actual range value.
@@ -104,9 +105,9 @@ clauselist_selectivity(Query *root,
 					   List *clauses,
 					   int varRelid)
 {
-	Selectivity			s1 = 1.0;
-	RangeQueryClause   *rqlist = NULL;
-	List			   *clist;
+	Selectivity s1 = 1.0;
+	RangeQueryClause *rqlist = NULL;
+	List	   *clist;
 
 	/*
 	 * Initial scan over clauses.  Anything that doesn't look like a
@@ -116,13 +117,13 @@ clauselist_selectivity(Query *root,
 	foreach(clist, clauses)
 	{
 		Node	   *clause = (Node *) lfirst(clist);
-		Selectivity	s2;
+		Selectivity s2;
 
 		/*
-		 * See if it looks like a restriction clause with a constant.
-		 * (If it's not a constant we can't really trust the selectivity!)
-		 * NB: for consistency of results, this fragment of code had
-		 * better match what clause_selectivity() would do.
+		 * See if it looks like a restriction clause with a constant. (If
+		 * it's not a constant we can't really trust the selectivity!) NB:
+		 * for consistency of results, this fragment of code had better
+		 * match what clause_selectivity() would do.
 		 */
 		if (varRelid != 0 || NumRelids(clause) == 1)
 		{
@@ -147,11 +148,12 @@ clauselist_selectivity(Query *root,
 														  root->rtable),
 												 attno,
 												 constval, flag);
+
 				/*
-				 * If we reach here, we have computed the same result
-				 * that clause_selectivity would, so we can just use s2
-				 * if it's the wrong oprrest.  But if it's the right
-				 * oprrest, add the clause to rqlist for later processing.
+				 * If we reach here, we have computed the same result that
+				 * clause_selectivity would, so we can just use s2 if it's
+				 * the wrong oprrest.  But if it's the right oprrest, add
+				 * the clause to rqlist for later processing.
 				 */
 				switch (oprrest)
 				{
@@ -166,7 +168,7 @@ clauselist_selectivity(Query *root,
 						s1 = s1 * s2;
 						break;
 				}
-				continue; /* drop to loop bottom */
+				continue;		/* drop to loop bottom */
 			}
 		}
 		/* Not the right form, so treat it generically. */
@@ -179,12 +181,12 @@ clauselist_selectivity(Query *root,
 	 */
 	while (rqlist != NULL)
 	{
-		RangeQueryClause   *rqnext;
+		RangeQueryClause *rqnext;
 
 		if (rqlist->have_lobound && rqlist->have_hibound)
 		{
 			/* Successfully matched a pair of range clauses */
-			Selectivity	s2 = rqlist->hibound + rqlist->lobound - 1.0;
+			Selectivity s2 = rqlist->hibound + rqlist->lobound - 1.0;
 
 			/*
 			 * A zero or slightly negative s2 should be converted into a
@@ -199,14 +201,20 @@ clauselist_selectivity(Query *root,
 			{
 				if (s2 < -0.01)
 				{
-					/* No data available --- use a default estimate that
+
+					/*
+					 * No data available --- use a default estimate that
 					 * is small, but not real small.
 					 */
 					s2 = 0.01;
 				}
 				else
 				{
-					/* It's just roundoff error; use a small positive value */
+
+					/*
+					 * It's just roundoff error; use a small positive
+					 * value
+					 */
 					s2 = 1.0e-10;
 				}
 			}
@@ -239,15 +247,15 @@ static void
 addRangeClause(RangeQueryClause **rqlist, Node *clause,
 			   int flag, bool isLTsel, Selectivity s2)
 {
-	RangeQueryClause   *rqelem;
-	Node			   *var;
-	bool				is_lobound;
+	RangeQueryClause *rqelem;
+	Node	   *var;
+	bool		is_lobound;
 
 	/* get_relattval sets flag&SEL_RIGHT if the var is on the LEFT. */
 	if (flag & SEL_RIGHT)
 	{
 		var = (Node *) get_leftop((Expr *) clause);
-		is_lobound = ! isLTsel;	/* x < something is high bound */
+		is_lobound = !isLTsel;	/* x < something is high bound */
 	}
 	else
 	{
@@ -257,23 +265,27 @@ addRangeClause(RangeQueryClause **rqlist, Node *clause,
 
 	for (rqelem = *rqlist; rqelem; rqelem = rqelem->next)
 	{
-		/* We use full equal() here because the "var" might be a function
+
+		/*
+		 * We use full equal() here because the "var" might be a function
 		 * of one or more attributes of the same relation...
 		 */
-		if (! equal(var, rqelem->var))
+		if (!equal(var, rqelem->var))
 			continue;
 		/* Found the right group to put this clause in */
 		if (is_lobound)
 		{
-			if (! rqelem->have_lobound)
+			if (!rqelem->have_lobound)
 			{
 				rqelem->have_lobound = true;
 				rqelem->lobound = s2;
 			}
 			else
 			{
-				/* We have found two similar clauses, such as
-				 * x < y AND x < z.  Keep only the more restrictive one.
+
+				/*
+				 * We have found two similar clauses, such as x < y AND x
+				 * < z.  Keep only the more restrictive one.
 				 */
 				if (rqelem->lobound > s2)
 					rqelem->lobound = s2;
@@ -281,15 +293,17 @@ addRangeClause(RangeQueryClause **rqlist, Node *clause,
 		}
 		else
 		{
-			if (! rqelem->have_hibound)
+			if (!rqelem->have_hibound)
 			{
 				rqelem->have_hibound = true;
 				rqelem->hibound = s2;
 			}
 			else
 			{
-				/* We have found two similar clauses, such as
-				 * x > y AND x > z.  Keep only the more restrictive one.
+
+				/*
+				 * We have found two similar clauses, such as x > y AND x
+				 * > z.  Keep only the more restrictive one.
 				 */
 				if (rqelem->hibound > s2)
 					rqelem->hibound = s2;
@@ -331,7 +345,7 @@ addRangeClause(RangeQueryClause **rqlist, Node *clause,
  * nestloop join's inner relation --- varRelid should then be the ID of the
  * inner relation.
  *
- * When varRelid is 0, all variables are treated as variables.  This
+ * When varRelid is 0, all variables are treated as variables.	This
  * is appropriate for ordinary join clauses and restriction clauses.
  */
 Selectivity
@@ -339,12 +353,13 @@ clause_selectivity(Query *root,
 				   Node *clause,
 				   int varRelid)
 {
-	Selectivity		s1 = 1.0;	/* default for any unhandled clause type */
+	Selectivity s1 = 1.0;		/* default for any unhandled clause type */
 
 	if (clause == NULL)
 		return s1;
 	if (IsA(clause, Var))
 	{
+
 		/*
 		 * we have a bool Var.	This is exactly equivalent to the clause:
 		 * reln.attribute = 't' so we compute the selectivity as if that
@@ -352,7 +367,7 @@ clause_selectivity(Query *root,
 		 * didn't want to have to do system cache look ups to find out all
 		 * of that info.
 		 */
-		Index	varno = ((Var *) clause)->varno;
+		Index		varno = ((Var *) clause)->varno;
 
 		if (varRelid == 0 || varRelid == (int) varno)
 			s1 = restriction_selectivity(F_EQSEL,
@@ -377,7 +392,7 @@ clause_selectivity(Query *root,
 	{
 		/* inverse of the selectivity of the underlying clause */
 		s1 = 1.0 - clause_selectivity(root,
-									  (Node*) get_notclausearg((Expr*) clause),
+							  (Node *) get_notclausearg((Expr *) clause),
 									  varRelid);
 	}
 	else if (and_clause(clause))
@@ -389,18 +404,21 @@ clause_selectivity(Query *root,
 	}
 	else if (or_clause(clause))
 	{
+
 		/*
 		 * Selectivities for an 'or' clause are computed as s1+s2 - s1*s2
-		 * to account for the probable overlap of selected tuple sets.
-		 * XXX is this too conservative?
+		 * to account for the probable overlap of selected tuple sets. XXX
+		 * is this too conservative?
 		 */
-		List   *arg;
+		List	   *arg;
+
 		s1 = 0.0;
 		foreach(arg, ((Expr *) clause)->args)
 		{
-			Selectivity	s2 = clause_selectivity(root,
+			Selectivity s2 = clause_selectivity(root,
 												(Node *) lfirst(arg),
 												varRelid);
+
 			s1 = s1 + s2 - s1 * s2;
 		}
 	}
@@ -411,17 +429,20 @@ clause_selectivity(Query *root,
 
 		if (varRelid != 0)
 		{
+
 			/*
-			 * If we are considering a nestloop join then all clauses
-			 * are restriction clauses, since we are only interested in
-			 * the one relation.
+			 * If we are considering a nestloop join then all clauses are
+			 * restriction clauses, since we are only interested in the
+			 * one relation.
 			 */
 			is_join_clause = false;
 		}
 		else
 		{
+
 			/*
-			 * Otherwise, it's a join if there's more than one relation used.
+			 * Otherwise, it's a join if there's more than one relation
+			 * used.
 			 */
 			is_join_clause = (NumRelids(clause) > 1);
 		}
@@ -432,8 +453,8 @@ clause_selectivity(Query *root,
 			RegProcedure oprjoin = get_oprjoin(opno);
 
 			/*
-			 * if the oprjoin procedure is missing for whatever reason, use a
-			 * selectivity of 0.5
+			 * if the oprjoin procedure is missing for whatever reason,
+			 * use a selectivity of 0.5
 			 */
 			if (!oprjoin)
 				s1 = (Selectivity) 0.5;
@@ -460,8 +481,8 @@ clause_selectivity(Query *root,
 			RegProcedure oprrest = get_oprrest(opno);
 
 			/*
-			 * if the oprrest procedure is missing for whatever reason, use a
-			 * selectivity of 0.5
+			 * if the oprrest procedure is missing for whatever reason,
+			 * use a selectivity of 0.5
 			 */
 			if (!oprrest)
 				s1 = (Selectivity) 0.5;
@@ -484,6 +505,7 @@ clause_selectivity(Query *root,
 	}
 	else if (is_funcclause(clause))
 	{
+
 		/*
 		 * This is not an operator, so we guess at the selectivity. THIS
 		 * IS A HACK TO GET V4 OUT THE DOOR.  FUNCS SHOULD BE ABLE TO HAVE
@@ -493,6 +515,7 @@ clause_selectivity(Query *root,
 	}
 	else if (is_subplan(clause))
 	{
+
 		/*
 		 * Just for the moment! FIX ME! - vadim 02/04/98
 		 */
diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c
index f6bdcb828b92d6c97f4691cac6d0bb01fddcd989..6ecfb2a47138d3e8e1a21af3054b087f57cef82b 100644
--- a/src/backend/optimizer/path/costsize.c
+++ b/src/backend/optimizer/path/costsize.c
@@ -19,7 +19,7 @@
  *
  * Obviously, taking constants for these values is an oversimplification,
  * but it's tough enough to get any useful estimates even at this level of
- * detail.  Note that all of these parameters are user-settable, in case
+ * detail.	Note that all of these parameters are user-settable, in case
  * the default values are drastically off for a particular platform.
  *
  * We compute two separate costs for each path:
@@ -37,12 +37,12 @@
  * will be no zero divide.)  RelOptInfos, Paths, and Plans themselves never
  * account for LIMIT.
  *
- * 
+ *
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.56 2000/04/09 04:31:36 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.57 2000/04/12 17:15:19 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -118,6 +118,7 @@ cost_seqscan(Path *path, RelOptInfo *baserel)
 	/* disk costs */
 	if (lfirsti(baserel->relids) < 0)
 	{
+
 		/*
 		 * cost of sequentially scanning a materialized temporary relation
 		 */
@@ -125,15 +126,17 @@ cost_seqscan(Path *path, RelOptInfo *baserel)
 	}
 	else
 	{
+
 		/*
 		 * The cost of reading a page sequentially is 1.0, by definition.
 		 * Note that the Unix kernel will typically do some amount of
-		 * read-ahead optimization, so that this cost is less than the true
-		 * cost of reading a page from disk.  We ignore that issue here,
-		 * but must take it into account when estimating the cost of
+		 * read-ahead optimization, so that this cost is less than the
+		 * true cost of reading a page from disk.  We ignore that issue
+		 * here, but must take it into account when estimating the cost of
 		 * non-sequential accesses!
 		 */
-		run_cost += baserel->pages;	/* sequential fetches with cost 1.0 */
+		run_cost += baserel->pages;		/* sequential fetches with cost
+										 * 1.0 */
 	}
 
 	/* CPU costs */
@@ -151,7 +154,7 @@ cost_seqscan(Path *path, RelOptInfo *baserel)
  *
  * The simplistic model that the cost is random_page_cost is what we want
  * to use for large relations; but for small ones that is a serious
- * overestimate because of the effects of caching.  This routine tries to
+ * overestimate because of the effects of caching.	This routine tries to
  * account for that.
  *
  * Unfortunately we don't have any good way of estimating the effective cache
@@ -221,12 +224,12 @@ cost_index(Path *path, Query *root,
 	Cost		cpu_per_tuple;
 	Cost		indexStartupCost;
 	Cost		indexTotalCost;
-	Selectivity	indexSelectivity;
+	Selectivity indexSelectivity;
 	double		tuples_fetched;
 	double		pages_fetched;
 
 	/* Should only be applied to base relations */
-	Assert(IsA(baserel, RelOptInfo) && IsA(index, IndexOptInfo));
+	Assert(IsA(baserel, RelOptInfo) &&IsA(index, IndexOptInfo));
 	Assert(length(baserel->relids) == 1);
 
 	if (!enable_indexscan && !is_injoin)
@@ -234,8 +237,9 @@ cost_index(Path *path, Query *root,
 
 	/*
 	 * Call index-access-method-specific code to estimate the processing
-	 * cost for scanning the index, as well as the selectivity of the index
-	 * (ie, the fraction of main-table tuples we will have to retrieve).
+	 * cost for scanning the index, as well as the selectivity of the
+	 * index (ie, the fraction of main-table tuples we will have to
+	 * retrieve).
 	 */
 	fmgr(index->amcostestimate, root, baserel, index, indexQuals,
 		 &indexStartupCost, &indexTotalCost, &indexSelectivity);
@@ -249,17 +253,18 @@ cost_index(Path *path, Query *root,
 	 *
 	 * If the number of tuples is much smaller than the number of pages in
 	 * the relation, each tuple will cost a separate nonsequential fetch.
-	 * If it is comparable or larger, then probably we will be able to avoid
-	 * some fetches.  We use a growth rate of log(#tuples/#pages + 1) ---
-	 * probably totally bogus, but intuitively it gives the right shape of
-	 * curve at least.
+	 * If it is comparable or larger, then probably we will be able to
+	 * avoid some fetches.	We use a growth rate of log(#tuples/#pages +
+	 * 1) --- probably totally bogus, but intuitively it gives the right
+	 * shape of curve at least.
 	 *
 	 * XXX if the relation has recently been "clustered" using this index,
-	 * then in fact the target tuples will be highly nonuniformly distributed,
-	 * and we will be seriously overestimating the scan cost!  Currently we
-	 * have no way to know whether the relation has been clustered, nor how
-	 * much it's been modified since the last clustering, so we ignore this
-	 * effect.  Would be nice to do better someday.
+	 * then in fact the target tuples will be highly nonuniformly
+	 * distributed, and we will be seriously overestimating the scan cost!
+	 * Currently we have no way to know whether the relation has been
+	 * clustered, nor how much it's been modified since the last
+	 * clustering, so we ignore this effect.  Would be nice to do better
+	 * someday.
 	 */
 
 	tuples_fetched = indexSelectivity * baserel->tuples;
@@ -274,8 +279,8 @@ cost_index(Path *path, Query *root,
 		pages_fetched = tuples_fetched;
 
 	/*
-	 * Now estimate one nonsequential access per page fetched,
-	 * plus appropriate CPU costs per tuple.
+	 * Now estimate one nonsequential access per page fetched, plus
+	 * appropriate CPU costs per tuple.
 	 */
 
 	/* disk costs for main table */
@@ -283,16 +288,18 @@ cost_index(Path *path, Query *root,
 
 	/* CPU costs */
 	cpu_per_tuple = cpu_tuple_cost + baserel->baserestrictcost;
+
 	/*
-	 * Normally the indexquals will be removed from the list of restriction
-	 * clauses that we have to evaluate as qpquals, so we should subtract
-	 * their costs from baserestrictcost.  For a lossy index, however, we
-	 * will have to recheck all the quals and so mustn't subtract anything.
-	 * Also, if we are doing a join then some of the indexquals are join
-	 * clauses and shouldn't be subtracted.  Rather than work out exactly
-	 * how much to subtract, we don't subtract anything in that case either.
+	 * Normally the indexquals will be removed from the list of
+	 * restriction clauses that we have to evaluate as qpquals, so we
+	 * should subtract their costs from baserestrictcost.  For a lossy
+	 * index, however, we will have to recheck all the quals and so
+	 * mustn't subtract anything. Also, if we are doing a join then some
+	 * of the indexquals are join clauses and shouldn't be subtracted.
+	 * Rather than work out exactly how much to subtract, we don't
+	 * subtract anything in that case either.
 	 */
-	if (! index->lossy && ! is_injoin)
+	if (!index->lossy && !is_injoin)
 		cpu_per_tuple -= cost_qual_eval(indexQuals);
 
 	run_cost += cpu_per_tuple * tuples_fetched;
@@ -326,7 +333,7 @@ cost_tidscan(Path *path, RelOptInfo *baserel, List *tideval)
 	path->startup_cost = startup_cost;
 	path->total_cost = startup_cost + run_cost;
 }
- 
+
 /*
  * cost_sort
  *	  Determines and returns the cost of sorting a relation.
@@ -341,7 +348,7 @@ cost_tidscan(Path *path, RelOptInfo *baserel, List *tideval)
  * If the total volume exceeds SortMem, we switch to a tape-style merge
  * algorithm.  There will still be about t*log2(t) tuple comparisons in
  * total, but we will also need to write and read each tuple once per
- * merge pass.  We expect about ceil(log6(r)) merge passes where r is the
+ * merge pass.	We expect about ceil(log6(r)) merge passes where r is the
  * number of initial runs formed (log6 because tuplesort.c uses six-tape
  * merging).  Since the average initial run should be about twice SortMem,
  * we have
@@ -385,8 +392,8 @@ cost_sort(Path *path, List *pathkeys, double tuples, int width)
 	/*
 	 * CPU costs
 	 *
-	 * Assume about two operator evals per tuple comparison
-	 * and N log2 N comparisons
+	 * Assume about two operator evals per tuple comparison and N log2 N
+	 * comparisons
 	 */
 	startup_cost += 2.0 * cpu_operator_cost * tuples * LOG2(tuples);
 
@@ -408,7 +415,7 @@ cost_sort(Path *path, List *pathkeys, double tuples, int width)
 
 	/*
 	 * Note: should we bother to assign a nonzero run_cost to reflect the
-	 * overhead of extracting tuples from the sort result?  Probably not
+	 * overhead of extracting tuples from the sort result?	Probably not
 	 * worth worrying about.
 	 */
 	path->startup_cost = startup_cost;
@@ -440,19 +447,22 @@ cost_nestloop(Path *path,
 		startup_cost += disable_cost;
 
 	/* cost of source data */
+
 	/*
-	 * NOTE: we assume that the inner path's startup_cost is paid once, not
-	 * over again on each restart.  This is certainly correct if the inner
-	 * path is materialized.  Are there any cases where it is wrong?
+	 * NOTE: we assume that the inner path's startup_cost is paid once,
+	 * not over again on each restart.	This is certainly correct if the
+	 * inner path is materialized.	Are there any cases where it is wrong?
 	 */
 	startup_cost += outer_path->startup_cost + inner_path->startup_cost;
 	run_cost += outer_path->total_cost - outer_path->startup_cost;
 	run_cost += outer_path->parent->rows *
 		(inner_path->total_cost - inner_path->startup_cost);
 
-	/* Number of tuples processed (not number emitted!).  If inner path is
+	/*
+	 * Number of tuples processed (not number emitted!).  If inner path is
 	 * an indexscan, be sure to use its estimated output row count, which
-	 * may be lower than the restriction-clause-only row count of its parent.
+	 * may be lower than the restriction-clause-only row count of its
+	 * parent.
 	 */
 	if (IsA(inner_path, IndexPath))
 		ntuples = ((IndexPath *) inner_path)->rows;
@@ -498,11 +508,12 @@ cost_mergejoin(Path *path,
 		startup_cost += disable_cost;
 
 	/* cost of source data */
+
 	/*
 	 * Note we are assuming that each source tuple is fetched just once,
-	 * which is not right in the presence of equal keys.  If we had a way of
-	 * estimating the proportion of equal keys, we could apply a correction
-	 * factor...
+	 * which is not right in the presence of equal keys.  If we had a way
+	 * of estimating the proportion of equal keys, we could apply a
+	 * correction factor...
 	 */
 	if (outersortkeys)			/* do we need to sort outer? */
 	{
@@ -537,10 +548,10 @@ cost_mergejoin(Path *path,
 	}
 
 	/*
-	 * Estimate the number of tuples to be processed in the mergejoin itself
-	 * as one per tuple in the two source relations.  This could be a drastic
-	 * underestimate if there are many equal-keyed tuples in either relation,
-	 * but we have no good way of estimating that...
+	 * Estimate the number of tuples to be processed in the mergejoin
+	 * itself as one per tuple in the two source relations.  This could be
+	 * a drastic underestimate if there are many equal-keyed tuples in
+	 * either relation, but we have no good way of estimating that...
 	 */
 	ntuples = outer_path->parent->rows + inner_path->parent->rows;
 
@@ -575,9 +586,9 @@ cost_hashjoin(Path *path,
 	Cost		cpu_per_tuple;
 	double		ntuples;
 	double		outerbytes = relation_byte_size(outer_path->parent->rows,
-												outer_path->parent->width);
+											  outer_path->parent->width);
 	double		innerbytes = relation_byte_size(inner_path->parent->rows,
-												inner_path->parent->width);
+											  inner_path->parent->width);
 	long		hashtablebytes = SortMem * 1024L;
 
 	if (!enable_hashjoin)
@@ -592,7 +603,8 @@ cost_hashjoin(Path *path,
 	startup_cost += cpu_operator_cost * inner_path->parent->rows;
 	run_cost += cpu_operator_cost * outer_path->parent->rows;
 
-	/* the number of tuple comparisons needed is the number of outer
+	/*
+	 * the number of tuple comparisons needed is the number of outer
 	 * tuples times the typical hash bucket size, which we estimate
 	 * conservatively as the inner disbursion times the inner tuple count.
 	 */
@@ -601,9 +613,9 @@ cost_hashjoin(Path *path,
 
 	/*
 	 * Estimate the number of tuples that get through the hashing filter
-	 * as one per tuple in the two source relations.  This could be a drastic
-	 * underestimate if there are many equal-keyed tuples in either relation,
-	 * but we have no good way of estimating that...
+	 * as one per tuple in the two source relations.  This could be a
+	 * drastic underestimate if there are many equal-keyed tuples in
+	 * either relation, but we have no good way of estimating that...
 	 */
 	ntuples = outer_path->parent->rows + inner_path->parent->rows;
 
@@ -614,33 +626,31 @@ cost_hashjoin(Path *path,
 	/*
 	 * if inner relation is too big then we will need to "batch" the join,
 	 * which implies writing and reading most of the tuples to disk an
-	 * extra time.  Charge one cost unit per page of I/O (correct since
-	 * it should be nice and sequential...).  Writing the inner rel counts
-	 * as startup cost, all the rest as run cost.
+	 * extra time.	Charge one cost unit per page of I/O (correct since it
+	 * should be nice and sequential...).  Writing the inner rel counts as
+	 * startup cost, all the rest as run cost.
 	 */
 	if (innerbytes > hashtablebytes)
 	{
-		double	outerpages = page_size(outer_path->parent->rows,
-									   outer_path->parent->width);
-		double	innerpages = page_size(inner_path->parent->rows,
-									   inner_path->parent->width);
+		double		outerpages = page_size(outer_path->parent->rows,
+										   outer_path->parent->width);
+		double		innerpages = page_size(inner_path->parent->rows,
+										   inner_path->parent->width);
 
 		startup_cost += innerpages;
 		run_cost += innerpages + 2 * outerpages;
 	}
 
 	/*
-	 * Bias against putting larger relation on inside.  We don't want
-	 * an absolute prohibition, though, since larger relation might have
+	 * Bias against putting larger relation on inside.	We don't want an
+	 * absolute prohibition, though, since larger relation might have
 	 * better disbursion --- and we can't trust the size estimates
-	 * unreservedly, anyway.  Instead, inflate the startup cost by
-	 * the square root of the size ratio.  (Why square root?  No real good
+	 * unreservedly, anyway.  Instead, inflate the startup cost by the
+	 * square root of the size ratio.  (Why square root?  No real good
 	 * reason, but it seems reasonable...)
 	 */
 	if (innerbytes > outerbytes && outerbytes > 0)
-	{
 		startup_cost *= sqrt(innerbytes / outerbytes);
-	}
 
 	path->startup_cost = startup_cost;
 	path->total_cost = startup_cost + run_cost;
@@ -656,7 +666,7 @@ cost_hashjoin(Path *path,
 Cost
 cost_qual_eval(List *quals)
 {
-	Cost	total = 0;
+	Cost		total = 0;
 
 	cost_qual_eval_walker((Node *) quals, &total);
 	return total;
@@ -667,10 +677,11 @@ cost_qual_eval_walker(Node *node, Cost *total)
 {
 	if (node == NULL)
 		return false;
+
 	/*
 	 * Our basic strategy is to charge one cpu_operator_cost for each
-	 * operator or function node in the given tree.  Vars and Consts
-	 * are charged zero, and so are boolean operators (AND, OR, NOT).
+	 * operator or function node in the given tree.  Vars and Consts are
+	 * charged zero, and so are boolean operators (AND, OR, NOT).
 	 * Simplistic, but a lot better than no model at all.
 	 *
 	 * Should we try to account for the possibility of short-circuit
@@ -678,7 +689,7 @@ cost_qual_eval_walker(Node *node, Cost *total)
 	 */
 	if (IsA(node, Expr))
 	{
-		Expr   *expr = (Expr *) node;
+		Expr	   *expr = (Expr *) node;
 
 		switch (expr->opType)
 		{
@@ -691,17 +702,19 @@ cost_qual_eval_walker(Node *node, Cost *total)
 			case NOT_EXPR:
 				break;
 			case SUBPLAN_EXPR:
+
 				/*
-				 * A subplan node in an expression indicates that the subplan
-				 * will be executed on each evaluation, so charge accordingly.
-				 * (We assume that sub-selects that can be executed as
-				 * InitPlans have already been removed from the expression.)
+				 * A subplan node in an expression indicates that the
+				 * subplan will be executed on each evaluation, so charge
+				 * accordingly. (We assume that sub-selects that can be
+				 * executed as InitPlans have already been removed from
+				 * the expression.)
 				 *
 				 * NOTE: this logic should agree with the estimates used by
-				 * make_subplan() in plan/subselect.c. 
+				 * make_subplan() in plan/subselect.c.
 				 */
 				{
-					SubPlan	   *subplan = (SubPlan *) expr->oper;
+					SubPlan    *subplan = (SubPlan *) expr->oper;
 					Plan	   *plan = subplan->plan;
 					Cost		subcost;
 
@@ -730,13 +743,14 @@ cost_qual_eval_walker(Node *node, Cost *total)
 		}
 		/* fall through to examine args of Expr node */
 	}
+
 	/*
-	 * expression_tree_walker doesn't know what to do with RestrictInfo nodes,
-	 * but we just want to recurse through them.
+	 * expression_tree_walker doesn't know what to do with RestrictInfo
+	 * nodes, but we just want to recurse through them.
 	 */
 	if (IsA(node, RestrictInfo))
 	{
-		RestrictInfo   *restrictinfo = (RestrictInfo *) node;
+		RestrictInfo *restrictinfo = (RestrictInfo *) node;
 
 		return cost_qual_eval_walker((Node *) restrictinfo->clause, total);
 	}
@@ -755,7 +769,7 @@ cost_qual_eval_walker(Node *node, Cost *total)
  *
  * We set the following fields of the rel node:
  *	rows: the estimated number of output tuples (after applying
- *	      restriction clauses).
+ *		  restriction clauses).
  *	width: the estimated average output tuple width in bytes.
  *	baserestrictcost: estimated cost of evaluating baserestrictinfo clauses.
  */
@@ -769,9 +783,11 @@ set_baserel_size_estimates(Query *root, RelOptInfo *rel)
 		restrictlist_selectivity(root,
 								 rel->baserestrictinfo,
 								 lfirsti(rel->relids));
+
 	/*
 	 * Force estimate to be at least one row, to make explain output look
-	 * better and to avoid possible divide-by-zero when interpolating cost.
+	 * better and to avoid possible divide-by-zero when interpolating
+	 * cost.
 	 */
 	if (rel->rows < 1.0)
 		rel->rows = 1.0;
@@ -812,10 +828,10 @@ set_joinrel_size_estimates(Query *root, RelOptInfo *rel,
 	temp = outer_rel->rows * inner_rel->rows;
 
 	/*
-	 * Apply join restrictivity.  Note that we are only considering clauses
-	 * that become restriction clauses at this join level; we are not
-	 * double-counting them because they were not considered in estimating
-	 * the sizes of the component rels.
+	 * Apply join restrictivity.  Note that we are only considering
+	 * clauses that become restriction clauses at this join level; we are
+	 * not double-counting them because they were not considered in
+	 * estimating the sizes of the component rels.
 	 */
 	temp *= restrictlist_selectivity(root,
 									 restrictlist,
@@ -823,7 +839,8 @@ set_joinrel_size_estimates(Query *root, RelOptInfo *rel,
 
 	/*
 	 * Force estimate to be at least one row, to make explain output look
-	 * better and to avoid possible divide-by-zero when interpolating cost.
+	 * better and to avoid possible divide-by-zero when interpolating
+	 * cost.
 	 */
 	if (temp < 1.0)
 		temp = 1.0;
@@ -833,8 +850,8 @@ set_joinrel_size_estimates(Query *root, RelOptInfo *rel,
 	 * We could apply set_rel_width() to compute the output tuple width
 	 * from scratch, but at present it's always just the sum of the input
 	 * widths, so why work harder than necessary?  If relnode.c is ever
-	 * taught to remove unneeded columns from join targetlists, go back
-	 * to using set_rel_width here.
+	 * taught to remove unneeded columns from join targetlists, go back to
+	 * using set_rel_width here.
 	 */
 	rel->width = outer_rel->width + inner_rel->width;
 }
@@ -859,7 +876,7 @@ set_rel_width(Query *root, RelOptInfo *rel)
  * compute_attribute_width
  *	  Given a target list entry, find the size in bytes of the attribute.
  *
- *	  If a field is variable-length, we make a default assumption.  Would be
+ *	  If a field is variable-length, we make a default assumption.	Would be
  *	  better if VACUUM recorded some stats about the average field width...
  *	  also, we have access to the atttypmod, but fail to use it...
  */
diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c
index 8c63d9e1c38326cc8adeccb2bb68c905de17bedc..98c5112f7c3807882733785388b7fdf30dba7a47 100644
--- a/src/backend/optimizer/path/indxpath.c
+++ b/src/backend/optimizer/path/indxpath.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.81 2000/03/22 22:08:33 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.82 2000/04/12 17:15:19 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -46,62 +46,63 @@
 #define is_indexable_operator(clause,opclass,relam,indexkey_on_left) \
 	(indexable_operator(clause,opclass,relam,indexkey_on_left) != InvalidOid)
 
-typedef enum {
+typedef enum
+{
 	Prefix_None, Prefix_Partial, Prefix_Exact
 } Prefix_Status;
 
 static void match_index_orclauses(RelOptInfo *rel, IndexOptInfo *index,
-								  List *restrictinfo_list);
+					  List *restrictinfo_list);
 static List *match_index_orclause(RelOptInfo *rel, IndexOptInfo *index,
-								  List *or_clauses,
-								  List *other_matching_indices);
+					 List *or_clauses,
+					 List *other_matching_indices);
 static bool match_or_subclause_to_indexkey(RelOptInfo *rel,
-										   IndexOptInfo *index,
-										   Expr *clause);
+							   IndexOptInfo *index,
+							   Expr *clause);
 static List *group_clauses_by_indexkey(RelOptInfo *rel, IndexOptInfo *index,
-									   int *indexkeys, Oid *classes,
-									   List *restrictinfo_list);
+						  int *indexkeys, Oid *classes,
+						  List *restrictinfo_list);
 static List *group_clauses_by_ikey_for_joins(RelOptInfo *rel,
-											 IndexOptInfo *index,
-											 int *indexkeys, Oid *classes,
-											 List *join_cinfo_list,
-											 List *restr_cinfo_list);
+								IndexOptInfo *index,
+								int *indexkeys, Oid *classes,
+								List *join_cinfo_list,
+								List *restr_cinfo_list);
 static bool match_clause_to_indexkey(RelOptInfo *rel, IndexOptInfo *index,
-									 int indexkey, Oid opclass,
-									 Expr *clause, bool join);
+						 int indexkey, Oid opclass,
+						 Expr *clause, bool join);
 static bool pred_test(List *predicate_list, List *restrictinfo_list,
-					  List *joininfo_list);
+		  List *joininfo_list);
 static bool one_pred_test(Expr *predicate, List *restrictinfo_list);
 static bool one_pred_clause_expr_test(Expr *predicate, Node *clause);
 static bool one_pred_clause_test(Expr *predicate, Node *clause);
 static bool clause_pred_clause_test(Expr *predicate, Node *clause);
 static void indexable_joinclauses(RelOptInfo *rel, IndexOptInfo *index,
-								  List *joininfo_list, List *restrictinfo_list,
-								  List **clausegroups, List **outerrelids);
+					  List *joininfo_list, List *restrictinfo_list,
+					  List **clausegroups, List **outerrelids);
 static List *index_innerjoin(Query *root, RelOptInfo *rel, IndexOptInfo *index,
-							 List *clausegroup_list, List *outerrelids_list);
+				List *clausegroup_list, List *outerrelids_list);
 static bool useful_for_mergejoin(RelOptInfo *rel, IndexOptInfo *index,
-								 List *joininfo_list);
+					 List *joininfo_list);
 static bool useful_for_ordering(Query *root, RelOptInfo *rel,
-								IndexOptInfo *index,
-								ScanDirection scandir);
+					IndexOptInfo *index,
+					ScanDirection scandir);
 static bool match_index_to_operand(int indexkey, Var *operand,
-								   RelOptInfo *rel, IndexOptInfo *index);
+					   RelOptInfo *rel, IndexOptInfo *index);
 static bool function_index_operand(Expr *funcOpnd, RelOptInfo *rel,
-								   IndexOptInfo *index);
+					   IndexOptInfo *index);
 static bool match_special_index_operator(Expr *clause, Oid opclass, Oid relam,
-										 bool indexkey_on_left);
+							 bool indexkey_on_left);
 static Prefix_Status like_fixed_prefix(char *patt, char **prefix);
 static Prefix_Status regex_fixed_prefix(char *patt, bool case_insensitive,
-										char **prefix);
+				   char **prefix);
 static List *prefix_quals(Var *leftop, Oid expr_op,
-						  char *prefix, Prefix_Status pstatus);
-static char *make_greater_string(const char * str, Oid datatype);
-static Oid find_operator(const char * opname, Oid datatype);
-static Datum string_to_datum(const char * str, Oid datatype);
-static Const *string_to_const(const char * str, Oid datatype);
-static bool string_lessthan(const char * str1, const char * str2,
-							Oid datatype);
+			 char *prefix, Prefix_Status pstatus);
+static char *make_greater_string(const char *str, Oid datatype);
+static Oid	find_operator(const char *opname, Oid datatype);
+static Datum string_to_datum(const char *str, Oid datatype);
+static Const *string_to_const(const char *str, Oid datatype);
+static bool string_lessthan(const char *str1, const char *str2,
+				Oid datatype);
 
 
 /*
@@ -153,34 +154,34 @@ create_index_paths(Query *root,
 		List	   *joinouterrelids;
 
 		/*
-		 * If this is a partial index, we can only use it if it passes
-		 * the predicate test.
+		 * If this is a partial index, we can only use it if it passes the
+		 * predicate test.
 		 */
 		if (index->indpred != NIL)
 			if (!pred_test(index->indpred, restrictinfo_list, joininfo_list))
 				continue;
 
 		/*
-		 * 1. Try matching the index against subclauses of restriction 'or'
-		 * clauses (ie, 'or' clauses that reference only this relation).
-		 * The restrictinfo nodes for the 'or' clauses are marked with lists
-		 * of the matching indices.  No paths are actually created now;
-		 * that will be done in orindxpath.c after all indexes for the rel
-		 * have been examined.  (We need to do it that way because we can
-		 * potentially use a different index for each subclause of an 'or',
-		 * so we can't build a path for an 'or' clause until all indexes have
-		 * been matched against it.)
+		 * 1. Try matching the index against subclauses of restriction
+		 * 'or' clauses (ie, 'or' clauses that reference only this
+		 * relation). The restrictinfo nodes for the 'or' clauses are
+		 * marked with lists of the matching indices.  No paths are
+		 * actually created now; that will be done in orindxpath.c after
+		 * all indexes for the rel have been examined.	(We need to do it
+		 * that way because we can potentially use a different index for
+		 * each subclause of an 'or', so we can't build a path for an 'or'
+		 * clause until all indexes have been matched against it.)
 		 *
 		 * We don't even think about special handling of 'or' clauses that
-		 * involve more than one relation (ie, are join clauses).
-		 * Can we do anything useful with those?
+		 * involve more than one relation (ie, are join clauses). Can we
+		 * do anything useful with those?
 		 */
 		match_index_orclauses(rel, index, restrictinfo_list);
 
 		/*
-		 * 2. If the keys of this index match any of the available non-'or'
-		 * restriction clauses, then create a path using those clauses
-		 * as indexquals.
+		 * 2. If the keys of this index match any of the available
+		 * non-'or' restriction clauses, then create a path using those
+		 * clauses as indexquals.
 		 */
 		restrictclauses = group_clauses_by_indexkey(rel,
 													index,
@@ -191,7 +192,7 @@ create_index_paths(Query *root,
 		if (restrictclauses != NIL)
 			add_path(rel, (Path *) create_index_path(root, rel, index,
 													 restrictclauses,
-													 NoMovementScanDirection));
+											   NoMovementScanDirection));
 
 		/*
 		 * 3. If this index can be used for a mergejoin, then create an
@@ -205,16 +206,17 @@ create_index_paths(Query *root,
 		if (restrictclauses == NIL)
 		{
 			if (useful_for_mergejoin(rel, index, joininfo_list) ||
-				useful_for_ordering(root, rel, index, ForwardScanDirection))
+			 useful_for_ordering(root, rel, index, ForwardScanDirection))
 				add_path(rel, (Path *)
 						 create_index_path(root, rel, index,
 										   NIL,
 										   ForwardScanDirection));
 		}
+
 		/*
-		 * Currently, backwards scan is never considered except for the case
-		 * of matching a query result ordering.  Possibly should consider
-		 * it in other places?
+		 * Currently, backwards scan is never considered except for the
+		 * case of matching a query result ordering.  Possibly should
+		 * consider it in other places?
 		 */
 		if (useful_for_ordering(root, rel, index, BackwardScanDirection))
 			add_path(rel, (Path *)
@@ -223,11 +225,11 @@ create_index_paths(Query *root,
 									   BackwardScanDirection));
 
 		/*
-		 * 4. Create an innerjoin index path for each combination of
-		 * other rels used in available join clauses.  These paths will
-		 * be considered as the inner side of nestloop joins against
-		 * those sets of other rels.  indexable_joinclauses() finds sets
-		 * of clauses that can be used with each combination of outer rels,
+		 * 4. Create an innerjoin index path for each combination of other
+		 * rels used in available join clauses.  These paths will be
+		 * considered as the inner side of nestloop joins against those
+		 * sets of other rels.	indexable_joinclauses() finds sets of
+		 * clauses that can be used with each combination of outer rels,
 		 * and index_innerjoin builds the paths themselves.  We add the
 		 * paths to the rel's innerjoin list, NOT to the result list.
 		 */
@@ -247,7 +249,7 @@ create_index_paths(Query *root,
 
 
 /****************************************************************************
- *		----  ROUTINES TO PROCESS 'OR' CLAUSES  ----
+ *		----  ROUTINES TO PROCESS 'OR' CLAUSES	----
  ****************************************************************************/
 
 
@@ -280,6 +282,7 @@ match_index_orclauses(RelOptInfo *rel,
 
 		if (restriction_is_or_clause(restrictinfo))
 		{
+
 			/*
 			 * Add this index to the subclause index list for each
 			 * subclause that it matches.
@@ -309,7 +312,7 @@ match_index_orclauses(RelOptInfo *rel,
  *		that have already been matched to subclauses within this
  *		particular 'or' clause (i.e., a list previously generated by
  *		this routine), or NIL if this routine has not previously been
- *	    run for this 'or' clause.
+ *		run for this 'or' clause.
  *
  * Returns a list of the form ((a b c) (d e f) nil (g h) ...) where
  * a,b,c are nodes of indices that match the first subclause in
@@ -326,7 +329,8 @@ match_index_orclause(RelOptInfo *rel,
 	List	   *index_list;
 	List	   *clist;
 
-	/* first time through, we create list of same length as OR clause,
+	/*
+	 * first time through, we create list of same length as OR clause,
 	 * containing an empty sublist for each subclause.
 	 */
 	if (!other_matching_indices)
@@ -374,8 +378,8 @@ match_or_subclause_to_indexkey(RelOptInfo *rel,
 							   IndexOptInfo *index,
 							   Expr *clause)
 {
-	int		indexkey = index->indexkeys[0];
-	Oid		opclass = index->classlist[0];
+	int			indexkey = index->indexkeys[0];
+	Oid			opclass = index->classlist[0];
 
 	if (and_clause((Node *) clause))
 	{
@@ -400,10 +404,10 @@ match_or_subclause_to_indexkey(RelOptInfo *rel,
  * used as indexquals.
  *
  * In the simplest case this just means making a one-element list of the
- * given opclause.  However, if the OR subclause is an AND, we have to
+ * given opclause.	However, if the OR subclause is an AND, we have to
  * scan it to find the opclause(s) that match the index.  (There should
  * be at least one, if match_or_subclause_to_indexkey succeeded, but there
- * could be more.)  Also, we apply expand_indexqual_conditions() to convert
+ * could be more.)	Also, we apply expand_indexqual_conditions() to convert
  * any special matching opclauses to indexable operators.
  *
  * The passed-in clause is not changed.
@@ -413,9 +417,9 @@ extract_or_indexqual_conditions(RelOptInfo *rel,
 								IndexOptInfo *index,
 								Expr *orsubclause)
 {
-	List   *quals = NIL;
-	int		indexkey = index->indexkeys[0];
-	Oid		opclass = index->classlist[0];
+	List	   *quals = NIL;
+	int			indexkey = index->indexkeys[0];
+	Oid			opclass = index->classlist[0];
 
 	if (and_clause((Node *) orsubclause))
 	{
@@ -514,8 +518,9 @@ group_clauses_by_indexkey(RelOptInfo *rel,
 				clausegroup = lappend(clausegroup, rinfo);
 		}
 
-		/* If no clauses match this key, we're done; we don't want to
-		 * look at keys to its right.
+		/*
+		 * If no clauses match this key, we're done; we don't want to look
+		 * at keys to its right.
 		 */
 		if (clausegroup == NIL)
 			break;
@@ -533,7 +538,7 @@ group_clauses_by_indexkey(RelOptInfo *rel,
 
 /*
  * group_clauses_by_ikey_for_joins
- *    Generates a list of join clauses that can be used with an index
+ *	  Generates a list of join clauses that can be used with an index
  *	  to scan the inner side of a nestloop join.
  *
  * This is much like group_clauses_by_indexkey(), but we consider both
@@ -593,8 +598,9 @@ group_clauses_by_ikey_for_joins(RelOptInfo *rel,
 				clausegroup = lappend(clausegroup, rinfo);
 		}
 
-		/* If no clauses match this key, we're done; we don't want to
-		 * look at keys to its right.
+		/*
+		 * If no clauses match this key, we're done; we don't want to look
+		 * at keys to its right.
 		 */
 		if (clausegroup == NIL)
 			break;
@@ -607,8 +613,8 @@ group_clauses_by_ikey_for_joins(RelOptInfo *rel,
 	} while (!DoneMatchingIndexKeys(indexkeys, index));
 
 	/*
-	 * if no join clause was matched then there ain't clauses for
-	 * joins at all.
+	 * if no join clause was matched then there ain't clauses for joins at
+	 * all.
 	 */
 	if (!jfound)
 	{
@@ -623,8 +629,8 @@ group_clauses_by_ikey_for_joins(RelOptInfo *rel,
 
 /*
  * match_clause_to_indexkey()
- *    Determines whether a restriction or join clause matches
- *    a key of an index.
+ *	  Determines whether a restriction or join clause matches
+ *	  a key of an index.
  *
  *	  To match, the clause:
 
@@ -673,43 +679,46 @@ match_clause_to_indexkey(RelOptInfo *rel,
 			   *rightop;
 
 	/* Clause must be a binary opclause. */
-	if (! is_opclause((Node *) clause))
+	if (!is_opclause((Node *) clause))
 		return false;
 	leftop = get_leftop(clause);
 	rightop = get_rightop(clause);
-	if (! leftop || ! rightop)
+	if (!leftop || !rightop)
 		return false;
 
 	if (!join)
 	{
+
 		/*
 		 * Not considering joins, so check for clauses of the form:
 		 * (indexkey operator constant) or (constant operator indexkey).
 		 * We will accept a Param as being constant.
 		 */
 
-		if ((IsA(rightop, Const) || IsA(rightop, Param)) &&
+		if ((IsA(rightop, Const) ||IsA(rightop, Param)) &&
 			match_index_to_operand(indexkey, leftop, rel, index))
 		{
 			if (is_indexable_operator(clause, opclass, index->relam, true))
 				return true;
+
 			/*
-			 * If we didn't find a member of the index's opclass,
-			 * see whether it is a "special" indexable operator.
+			 * If we didn't find a member of the index's opclass, see
+			 * whether it is a "special" indexable operator.
 			 */
 			if (match_special_index_operator(clause, opclass, index->relam,
 											 true))
 				return true;
 			return false;
 		}
-		if ((IsA(leftop, Const) || IsA(leftop, Param)) &&
+		if ((IsA(leftop, Const) ||IsA(leftop, Param)) &&
 			match_index_to_operand(indexkey, rightop, rel, index))
 		{
 			if (is_indexable_operator(clause, opclass, index->relam, false))
 				return true;
+
 			/*
-			 * If we didn't find a member of the index's opclass,
-			 * see whether it is a "special" indexable operator.
+			 * If we didn't find a member of the index's opclass, see
+			 * whether it is a "special" indexable operator.
 			 */
 			if (match_special_index_operator(clause, opclass, index->relam,
 											 false))
@@ -719,20 +728,21 @@ match_clause_to_indexkey(RelOptInfo *rel,
 	}
 	else
 	{
+
 		/*
-		 * Check for an indexqual that could be handled by a nestloop join.
-		 * We need the index key to be compared against an expression
-		 * that uses none of the indexed relation's vars.
+		 * Check for an indexqual that could be handled by a nestloop
+		 * join. We need the index key to be compared against an
+		 * expression that uses none of the indexed relation's vars.
 		 */
 		if (match_index_to_operand(indexkey, leftop, rel, index))
 		{
 			List	   *othervarnos = pull_varnos((Node *) rightop);
 			bool		isIndexable;
 
-			isIndexable = ! intMember(lfirsti(rel->relids), othervarnos);
+			isIndexable = !intMember(lfirsti(rel->relids), othervarnos);
 			freeList(othervarnos);
 			if (isIndexable &&
-				is_indexable_operator(clause, opclass, index->relam, true))
+			  is_indexable_operator(clause, opclass, index->relam, true))
 				return true;
 		}
 		else if (match_index_to_operand(indexkey, rightop, rel, index))
@@ -740,10 +750,10 @@ match_clause_to_indexkey(RelOptInfo *rel,
 			List	   *othervarnos = pull_varnos((Node *) leftop);
 			bool		isIndexable;
 
-			isIndexable = ! intMember(lfirsti(rel->relids), othervarnos);
+			isIndexable = !intMember(lfirsti(rel->relids), othervarnos);
 			freeList(othervarnos);
 			if (isIndexable &&
-				is_indexable_operator(clause, opclass, index->relam, false))
+			 is_indexable_operator(clause, opclass, index->relam, false))
 				return true;
 		}
 	}
@@ -768,7 +778,7 @@ match_clause_to_indexkey(RelOptInfo *rel,
  *
  * Returns the OID of the matching operator, or InvalidOid if no match.
  * Note that the returned OID will be different from the one in the given
- * expression if we used a binary-compatible substitution.  Also note that
+ * expression if we used a binary-compatible substitution.	Also note that
  * if indexkey_on_left is FALSE (meaning we need to commute), the returned
  * OID is *not* commuted; it can be plugged directly into the given clause.
  */
@@ -818,13 +828,14 @@ indexable_operator(Expr *clause, Oid opclass, Oid relam,
 
 		if (HeapTupleIsValid(newop))
 		{
-			Oid		new_expr_op = oprid(newop);
+			Oid			new_expr_op = oprid(newop);
 
 			if (new_expr_op != expr_op)
 			{
+
 				/*
-				 * OK, we found a binary-compatible operator of the same name;
-				 * now does it match the index?
+				 * OK, we found a binary-compatible operator of the same
+				 * name; now does it match the index?
 				 */
 				if (indexkey_on_left)
 					commuted_op = new_expr_op;
@@ -883,12 +894,12 @@ useful_for_mergejoin(RelOptInfo *rel,
 			{
 				if (restrictinfo->left_sortop == ordering[0] &&
 					match_index_to_operand(indexkeys[0],
-										   get_leftop(restrictinfo->clause),
+										get_leftop(restrictinfo->clause),
 										   rel, index))
 					return true;
 				if (restrictinfo->right_sortop == ordering[0] &&
 					match_index_to_operand(indexkeys[0],
-										   get_rightop(restrictinfo->clause),
+									   get_rightop(restrictinfo->clause),
 										   rel, index))
 					return true;
 			}
@@ -1127,7 +1138,7 @@ one_pred_clause_test(Expr *predicate, Node *clause)
  */
 
 static StrategyNumber
-BT_implic_table[BTMaxStrategyNumber][BTMaxStrategyNumber] = {
+			BT_implic_table[BTMaxStrategyNumber][BTMaxStrategyNumber] = {
 	{2, 2, 0, 0, 0},
 	{1, 2, 0, 0, 0},
 	{1, 2, 3, 4, 5},
@@ -1346,13 +1357,13 @@ clause_pred_clause_test(Expr *predicate, Node *clause)
  *	  rel's restrictinfo list.  Therefore, every clause in the group references
  *	  the current rel plus the same set of other rels (except for the restrict
  *	  clauses, which only reference the current rel).  Therefore, this set
- *    of clauses could be used as an indexqual if the relation is scanned
+ *	  of clauses could be used as an indexqual if the relation is scanned
  *	  as the inner side of a nestloop join when the outer side contains
  *	  (at least) all those "other rels".
  *
  *	  XXX Actually, given that we are considering a join that requires an
  *	  outer rel set (A,B,C), we should use all qual clauses that reference
- *	  any subset of these rels, not just the full set or none.  This is
+ *	  any subset of these rels, not just the full set or none.	This is
  *	  doable with a doubly nested loop over joininfo_list; is it worth it?
  *
  * Returns two parallel lists of the same length: the clause groups,
@@ -1430,10 +1441,11 @@ index_innerjoin(Query *root, RelOptInfo *rel, IndexOptInfo *index,
 
 		pathnode->path.pathtype = T_IndexScan;
 		pathnode->path.parent = rel;
+
 		/*
 		 * There's no point in marking the path with any pathkeys, since
-		 * it will only ever be used as the inner path of a nestloop,
-		 * and so its ordering does not matter.
+		 * it will only ever be used as the inner path of a nestloop, and
+		 * so its ordering does not matter.
 		 */
 		pathnode->path.pathkeys = NIL;
 
@@ -1441,7 +1453,8 @@ index_innerjoin(Query *root, RelOptInfo *rel, IndexOptInfo *index,
 		/* expand special operators to indexquals the executor can handle */
 		indexquals = expand_indexqual_conditions(indexquals);
 
-		/* Note that we are making a pathnode for a single-scan indexscan;
+		/*
+		 * Note that we are making a pathnode for a single-scan indexscan;
 		 * therefore, both indexid and indexqual should be single-element
 		 * lists.
 		 */
@@ -1456,14 +1469,15 @@ index_innerjoin(Query *root, RelOptInfo *rel, IndexOptInfo *index,
 
 		/*
 		 * We must compute the estimated number of output rows for the
-		 * indexscan.  This is less than rel->rows because of the additional
-		 * selectivity of the join clauses.  Since clausegroup may contain
-		 * both restriction and join clauses, we have to do a set union to
-		 * get the full set of clauses that must be considered to compute
-		 * the correct selectivity.  (We can't just nconc the two lists;
-		 * then we might have some restriction clauses appearing twice,
-		 * which'd mislead restrictlist_selectivity into double-counting
-		 * their selectivity.)
+		 * indexscan.  This is less than rel->rows because of the
+		 * additional selectivity of the join clauses.	Since clausegroup
+		 * may contain both restriction and join clauses, we have to do a
+		 * set union to get the full set of clauses that must be
+		 * considered to compute the correct selectivity.  (We can't just
+		 * nconc the two lists; then we might have some restriction
+		 * clauses appearing twice, which'd mislead
+		 * restrictlist_selectivity into double-counting their
+		 * selectivity.)
 		 */
 		pathnode->rows = rel->tuples *
 			restrictlist_selectivity(root,
@@ -1490,7 +1504,7 @@ index_innerjoin(Query *root, RelOptInfo *rel, IndexOptInfo *index,
  * match_index_to_operand()
  *	  Generalized test for a match between an index's key
  *	  and the operand on one side of a restriction or join clause.
- *    Now check for functional indices as well.
+ *	  Now check for functional indices as well.
  */
 static bool
 match_index_to_operand(int indexkey,
@@ -1500,6 +1514,7 @@ match_index_to_operand(int indexkey,
 {
 	if (index->indproc == InvalidOid)
 	{
+
 		/*
 		 * Normal index.
 		 */
@@ -1530,7 +1545,7 @@ function_index_operand(Expr *funcOpnd, RelOptInfo *rel, IndexOptInfo *index)
 	/*
 	 * sanity check, make sure we know what we're dealing with here.
 	 */
-	if (funcOpnd == NULL ||	! IsA(funcOpnd, Expr) ||
+	if (funcOpnd == NULL || !IsA(funcOpnd, Expr) ||
 		funcOpnd->opType != FUNC_EXPR ||
 		funcOpnd->oper == NULL || indexKeys == NULL)
 		return false;
@@ -1550,9 +1565,9 @@ function_index_operand(Expr *funcOpnd, RelOptInfo *rel, IndexOptInfo *index)
 	i = 0;
 	foreach(arg, funcargs)
 	{
-		Var	   *var = (Var *) lfirst(arg);
+		Var		   *var = (Var *) lfirst(arg);
 
-		if (! IsA(var, Var))
+		if (!IsA(var, Var))
 			return false;
 		if (indexKeys[i] == 0)
 			return false;
@@ -1578,10 +1593,10 @@ function_index_operand(Expr *funcOpnd, RelOptInfo *rel, IndexOptInfo *index)
  * indexscan machinery.  The key idea is that these operators allow us
  * to derive approximate indexscan qual clauses, such that any tuples
  * that pass the operator clause itself must also satisfy the simpler
- * indexscan condition(s).  Then we can use the indexscan machinery
+ * indexscan condition(s).	Then we can use the indexscan machinery
  * to avoid scanning as much of the table as we'd otherwise have to,
  * while applying the original operator as a qpqual condition to ensure
- * we deliver only the tuples we want.  (In essence, we're using a regular
+ * we deliver only the tuples we want.	(In essence, we're using a regular
  * index as if it were a lossy index.)
  *
  * An example of what we're doing is
@@ -1630,11 +1645,12 @@ match_special_index_operator(Expr *clause, Oid opclass, Oid relam,
 	char	   *patt;
 	char	   *prefix;
 
-	/* Currently, all known special operators require the indexkey
-	 * on the left, but this test could be pushed into the switch statement
-	 * if some are added that do not...
+	/*
+	 * Currently, all known special operators require the indexkey on the
+	 * left, but this test could be pushed into the switch statement if
+	 * some are added that do not...
 	 */
-	if (! indexkey_on_left)
+	if (!indexkey_on_left)
 		return false;
 
 	/* we know these will succeed */
@@ -1643,7 +1659,7 @@ match_special_index_operator(Expr *clause, Oid opclass, Oid relam,
 	expr_op = ((Oper *) clause->oper)->opno;
 
 	/* again, required for all current special ops: */
-	if (! IsA(rightop, Const) ||
+	if (!IsA(rightop, Const) ||
 		((Const *) rightop)->constisnull)
 		return false;
 	constvalue = ((Const *) rightop)->constvalue;
@@ -1657,7 +1673,8 @@ match_special_index_operator(Expr *clause, Oid opclass, Oid relam,
 			/* the right-hand const is type text for all of these */
 			patt = textout((text *) DatumGetPointer(constvalue));
 			isIndexable = like_fixed_prefix(patt, &prefix) != Prefix_None;
-			if (prefix) pfree(prefix);
+			if (prefix)
+				pfree(prefix);
 			pfree(patt);
 			break;
 
@@ -1668,7 +1685,8 @@ match_special_index_operator(Expr *clause, Oid opclass, Oid relam,
 			/* the right-hand const is type text for all of these */
 			patt = textout((text *) DatumGetPointer(constvalue));
 			isIndexable = regex_fixed_prefix(patt, false, &prefix) != Prefix_None;
-			if (prefix) pfree(prefix);
+			if (prefix)
+				pfree(prefix);
 			pfree(patt);
 			break;
 
@@ -1679,13 +1697,14 @@ match_special_index_operator(Expr *clause, Oid opclass, Oid relam,
 			/* the right-hand const is type text for all of these */
 			patt = textout((text *) DatumGetPointer(constvalue));
 			isIndexable = regex_fixed_prefix(patt, true, &prefix) != Prefix_None;
-			if (prefix) pfree(prefix);
+			if (prefix)
+				pfree(prefix);
 			pfree(patt);
 			break;
 	}
 
 	/* done if the expression doesn't look indexable */
-	if (! isIndexable)
+	if (!isIndexable)
 		return false;
 
 	/*
@@ -1699,32 +1718,32 @@ match_special_index_operator(Expr *clause, Oid opclass, Oid relam,
 		case OID_TEXT_LIKE_OP:
 		case OID_TEXT_REGEXEQ_OP:
 		case OID_TEXT_ICREGEXEQ_OP:
-			if (! op_class(find_operator(">=", TEXTOID), opclass, relam) ||
-				! op_class(find_operator("<", TEXTOID), opclass, relam))
+			if (!op_class(find_operator(">=", TEXTOID), opclass, relam) ||
+				!op_class(find_operator("<", TEXTOID), opclass, relam))
 				isIndexable = false;
 			break;
 
 		case OID_BPCHAR_LIKE_OP:
 		case OID_BPCHAR_REGEXEQ_OP:
 		case OID_BPCHAR_ICREGEXEQ_OP:
-			if (! op_class(find_operator(">=", BPCHAROID), opclass, relam) ||
-				! op_class(find_operator("<", BPCHAROID), opclass, relam))
+			if (!op_class(find_operator(">=", BPCHAROID), opclass, relam) ||
+				!op_class(find_operator("<", BPCHAROID), opclass, relam))
 				isIndexable = false;
 			break;
 
 		case OID_VARCHAR_LIKE_OP:
 		case OID_VARCHAR_REGEXEQ_OP:
 		case OID_VARCHAR_ICREGEXEQ_OP:
-			if (! op_class(find_operator(">=", VARCHAROID), opclass, relam) ||
-				! op_class(find_operator("<", VARCHAROID), opclass, relam))
+			if (!op_class(find_operator(">=", VARCHAROID), opclass, relam) ||
+				!op_class(find_operator("<", VARCHAROID), opclass, relam))
 				isIndexable = false;
 			break;
 
 		case OID_NAME_LIKE_OP:
 		case OID_NAME_REGEXEQ_OP:
 		case OID_NAME_ICREGEXEQ_OP:
-			if (! op_class(find_operator(">=", NAMEOID), opclass, relam) ||
-				! op_class(find_operator("<", NAMEOID), opclass, relam))
+			if (!op_class(find_operator(">=", NAMEOID), opclass, relam) ||
+				!op_class(find_operator("<", NAMEOID), opclass, relam))
 				isIndexable = false;
 			break;
 	}
@@ -1736,7 +1755,7 @@ match_special_index_operator(Expr *clause, Oid opclass, Oid relam,
  * expand_indexqual_conditions
  *	  Given a list of (implicitly ANDed) indexqual clauses,
  *	  expand any "special" index operators into clauses that the indexscan
- *	  machinery will know what to do with.  Clauses that were not
+ *	  machinery will know what to do with.	Clauses that were not
  *	  recognized by match_special_index_operator() must be passed through
  *	  unchanged.
  */
@@ -1749,6 +1768,7 @@ expand_indexqual_conditions(List *indexquals)
 	foreach(q, indexquals)
 	{
 		Expr	   *clause = (Expr *) lfirst(q);
+
 		/* we know these will succeed */
 		Var		   *leftop = get_leftop(clause);
 		Var		   *rightop = get_rightop(clause);
@@ -1760,11 +1780,13 @@ expand_indexqual_conditions(List *indexquals)
 
 		switch (expr_op)
 		{
-			/*
-			 * LIKE and regex operators are not members of any index opclass,
-			 * so if we find one in an indexqual list we can assume that
-			 * it was accepted by match_special_index_operator().
-			 */
+
+				/*
+				 * LIKE and regex operators are not members of any index
+				 * opclass, so if we find one in an indexqual list we can
+				 * assume that it was accepted by
+				 * match_special_index_operator().
+				 */
 			case OID_TEXT_LIKE_OP:
 			case OID_BPCHAR_LIKE_OP:
 			case OID_VARCHAR_LIKE_OP:
@@ -1776,7 +1798,8 @@ expand_indexqual_conditions(List *indexquals)
 				resultquals = nconc(resultquals,
 									prefix_quals(leftop, expr_op,
 												 prefix, pstatus));
-				if (prefix) pfree(prefix);
+				if (prefix)
+					pfree(prefix);
 				pfree(patt);
 				break;
 
@@ -1791,7 +1814,8 @@ expand_indexqual_conditions(List *indexquals)
 				resultquals = nconc(resultquals,
 									prefix_quals(leftop, expr_op,
 												 prefix, pstatus));
-				if (prefix) pfree(prefix);
+				if (prefix)
+					pfree(prefix);
 				pfree(patt);
 				break;
 
@@ -1806,7 +1830,8 @@ expand_indexqual_conditions(List *indexquals)
 				resultquals = nconc(resultquals,
 									prefix_quals(leftop, expr_op,
 												 prefix, pstatus));
-				if (prefix) pfree(prefix);
+				if (prefix)
+					pfree(prefix);
 				pfree(patt);
 				break;
 
@@ -1833,7 +1858,7 @@ like_fixed_prefix(char *patt, char **prefix)
 	int			pos,
 				match_pos;
 
-	*prefix = match = palloc(strlen(patt)+1);
+	*prefix = match = palloc(strlen(patt) + 1);
 	match_pos = 0;
 
 	for (pos = 0; patt[pos]; pos++)
@@ -1849,14 +1874,15 @@ like_fixed_prefix(char *patt, char **prefix)
 			if (patt[pos] == '\0')
 				break;
 		}
+
 		/*
-		 * NOTE: this code used to think that %% meant a literal %,
-		 * but textlike() itself does not think that, and the SQL92
-		 * spec doesn't say any such thing either.
+		 * NOTE: this code used to think that %% meant a literal %, but
+		 * textlike() itself does not think that, and the SQL92 spec
+		 * doesn't say any such thing either.
 		 */
 		match[match_pos++] = patt[pos];
 	}
-	
+
 	match[match_pos] = '\0';
 
 	/* in LIKE, an empty pattern is an exact match! */
@@ -1905,7 +1931,7 @@ regex_fixed_prefix(char *patt, bool case_insensitive,
 	}
 
 	/* OK, allocate space for pattern */
-	*prefix = match = palloc(strlen(patt)+1);
+	*prefix = match = palloc(strlen(patt) + 1);
 	match_pos = 0;
 
 	/* note start at pos 1 to skip leading ^ */
@@ -1916,9 +1942,11 @@ regex_fixed_prefix(char *patt, bool case_insensitive,
 			patt[pos] == '*' ||
 			patt[pos] == '[' ||
 			patt[pos] == '$' ||
-			/* XXX I suspect isalpha() is not an adequately locale-sensitive
-			 * test for characters that can vary under case folding?
-			 */
+
+		/*
+		 * XXX I suspect isalpha() is not an adequately locale-sensitive
+		 * test for characters that can vary under case folding?
+		 */
 			(case_insensitive && isalpha(patt[pos])))
 			break;
 		if (patt[pos] == '\\')
@@ -1932,9 +1960,9 @@ regex_fixed_prefix(char *patt, bool case_insensitive,
 
 	match[match_pos] = '\0';
 
-	if (patt[pos] == '$' && patt[pos+1] == '\0')
+	if (patt[pos] == '$' && patt[pos + 1] == '\0')
 		return Prefix_Exact;	/* pattern specifies exact match */
-	
+
 	if (match_pos > 0)
 		return Prefix_Partial;
 	return Prefix_None;
@@ -2020,7 +2048,8 @@ prefix_quals(Var *leftop, Oid expr_op,
 	result = lcons(expr, NIL);
 
 	/*
-	 * If we can create a string larger than the prefix, say "x < greaterstr".
+	 * If we can create a string larger than the prefix, say "x <
+	 * greaterstr".
 	 */
 	greaterstr = make_greater_string(prefix, datatype);
 	if (greaterstr)
@@ -2058,17 +2087,20 @@ prefix_quals(Var *leftop, Oid expr_op,
  * given "foos" and return "foot", will this actually be greater than "fooss"?
  */
 static char *
-make_greater_string(const char * str, Oid datatype)
+make_greater_string(const char *str, Oid datatype)
 {
 	char	   *workstr;
 	int			len;
 
-	/* Make a modifiable copy, which will be our return value if successful */
+	/*
+	 * Make a modifiable copy, which will be our return value if
+	 * successful
+	 */
 	workstr = pstrdup((char *) str);
 
 	while ((len = strlen(workstr)) > 0)
 	{
-		unsigned char  *lastchar = (unsigned char *) (workstr + len - 1);
+		unsigned char *lastchar = (unsigned char *) (workstr + len - 1);
 
 		/*
 		 * Try to generate a larger string by incrementing the last byte.
@@ -2077,14 +2109,15 @@ make_greater_string(const char * str, Oid datatype)
 		{
 			(*lastchar)++;
 			if (string_lessthan(str, workstr, datatype))
-				return workstr;			/* Success! */
+				return workstr; /* Success! */
 		}
+
 		/*
-		 * Truncate off the last character, which might be more than 1 byte
-		 * in MULTIBYTE case.
+		 * Truncate off the last character, which might be more than 1
+		 * byte in MULTIBYTE case.
 		 */
 #ifdef MULTIBYTE
-		len = pg_mbcliplen((const unsigned char *) workstr, len, len-1);
+		len = pg_mbcliplen((const unsigned char *) workstr, len, len - 1);
 		workstr[len] = '\0';
 #else
 		*lastchar = '\0';
@@ -2102,7 +2135,7 @@ make_greater_string(const char * str, Oid datatype)
 
 /* See if there is a binary op of the given name for the given datatype */
 static Oid
-find_operator(const char * opname, Oid datatype)
+find_operator(const char *opname, Oid datatype)
 {
 	HeapTuple	optup;
 
@@ -2122,10 +2155,12 @@ find_operator(const char * opname, Oid datatype)
  * returned value should be pfree'd if no longer needed.
  */
 static Datum
-string_to_datum(const char * str, Oid datatype)
+string_to_datum(const char *str, Oid datatype)
 {
-	/* We cheat a little by assuming that textin() will do for
-	 * bpchar and varchar constants too...
+
+	/*
+	 * We cheat a little by assuming that textin() will do for bpchar and
+	 * varchar constants too...
 	 */
 	if (datatype == NAMEOID)
 		return PointerGetDatum(namein((char *) str));
@@ -2137,7 +2172,7 @@ string_to_datum(const char * str, Oid datatype)
  * Generate a Const node of the appropriate type from a C string.
  */
 static Const *
-string_to_const(const char * str, Oid datatype)
+string_to_const(const char *str, Oid datatype)
 {
 	Datum		conval = string_to_datum(str, datatype);
 
@@ -2151,7 +2186,7 @@ string_to_const(const char * str, Oid datatype)
  * "<" operator function, to ensure we get the right result...
  */
 static bool
-string_lessthan(const char * str1, const char * str2, Oid datatype)
+string_lessthan(const char *str1, const char *str2, Oid datatype)
 {
 	Datum		datum1 = string_to_datum(str1, datatype);
 	Datum		datum2 = string_to_datum(str2, datatype);
diff --git a/src/backend/optimizer/path/joinpath.c b/src/backend/optimizer/path/joinpath.c
index 926143749682b0773b79bdce1cecafa589eb47f8..64e9443ab18610819058676ae83e386fc8d402f5 100644
--- a/src/backend/optimizer/path/joinpath.c
+++ b/src/backend/optimizer/path/joinpath.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.53 2000/02/18 23:47:19 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.54 2000/04/12 17:15:19 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -28,25 +28,27 @@
 #include "utils/lsyscache.h"
 
 static void sort_inner_and_outer(Query *root, RelOptInfo *joinrel,
-								 RelOptInfo *outerrel, RelOptInfo *innerrel,
-								 List *restrictlist, List *mergeclause_list);
+					 RelOptInfo *outerrel, RelOptInfo *innerrel,
+					 List *restrictlist, List *mergeclause_list);
 static void match_unsorted_outer(Query *root, RelOptInfo *joinrel,
-								 RelOptInfo *outerrel, RelOptInfo *innerrel,
-								 List *restrictlist, List *mergeclause_list);
+					 RelOptInfo *outerrel, RelOptInfo *innerrel,
+					 List *restrictlist, List *mergeclause_list);
+
 #ifdef NOT_USED
 static void match_unsorted_inner(Query *root, RelOptInfo *joinrel,
-								 RelOptInfo *outerrel, RelOptInfo *innerrel,
-								 List *restrictlist, List *mergeclause_list);
+					 RelOptInfo *outerrel, RelOptInfo *innerrel,
+					 List *restrictlist, List *mergeclause_list);
+
 #endif
 static void hash_inner_and_outer(Query *root, RelOptInfo *joinrel,
-								 RelOptInfo *outerrel, RelOptInfo *innerrel,
-								 List *restrictlist);
+					 RelOptInfo *outerrel, RelOptInfo *innerrel,
+					 List *restrictlist);
 static Path *best_innerjoin(List *join_paths, List *outer_relid);
 static Selectivity estimate_disbursion(Query *root, Var *var);
 static List *select_mergejoin_clauses(RelOptInfo *joinrel,
-									  RelOptInfo *outerrel,
-									  RelOptInfo *innerrel,
-									  List *restrictlist);
+						 RelOptInfo *outerrel,
+						 RelOptInfo *innerrel,
+						 List *restrictlist);
 
 
 /*
@@ -79,32 +81,33 @@ add_paths_to_joinrel(Query *root,
 													restrictlist);
 
 	/*
-	 * 1. Consider mergejoin paths where both relations must be
-	 * explicitly sorted.
+	 * 1. Consider mergejoin paths where both relations must be explicitly
+	 * sorted.
 	 */
 	sort_inner_and_outer(root, joinrel, outerrel, innerrel,
 						 restrictlist, mergeclause_list);
 
 	/*
-	 * 2. Consider paths where the outer relation need not be
-	 * explicitly sorted. This includes both nestloops and
-	 * mergejoins where the outer path is already ordered.
+	 * 2. Consider paths where the outer relation need not be explicitly
+	 * sorted. This includes both nestloops and mergejoins where the outer
+	 * path is already ordered.
 	 */
 	match_unsorted_outer(root, joinrel, outerrel, innerrel,
 						 restrictlist, mergeclause_list);
 
 #ifdef NOT_USED
+
 	/*
-	 * 3. Consider paths where the inner relation need not be
-	 * explicitly sorted.  This includes mergejoins only
-	 * (nestloops were already built in match_unsorted_outer).
+	 * 3. Consider paths where the inner relation need not be explicitly
+	 * sorted.	This includes mergejoins only (nestloops were already
+	 * built in match_unsorted_outer).
 	 *
-	 * Diked out as redundant 2/13/2000 -- tgl.  There isn't any
-	 * really significant difference between the inner and outer
-	 * side of a mergejoin, so match_unsorted_inner creates no paths
-	 * that aren't equivalent to those made by match_unsorted_outer
-	 * when add_paths_to_joinrel() is invoked with the two rels given
-	 * in the other order.
+	 * Diked out as redundant 2/13/2000 -- tgl.  There isn't any really
+	 * significant difference between the inner and outer side of a
+	 * mergejoin, so match_unsorted_inner creates no paths that aren't
+	 * equivalent to those made by match_unsorted_outer when
+	 * add_paths_to_joinrel() is invoked with the two rels given in the
+	 * other order.
 	 */
 	match_unsorted_inner(root, joinrel, outerrel, innerrel,
 						 restrictlist, mergeclause_list);
@@ -144,31 +147,31 @@ sort_inner_and_outer(Query *root,
 
 	/*
 	 * Each possible ordering of the available mergejoin clauses will
-	 * generate a differently-sorted result path at essentially the
-	 * same cost.  We have no basis for choosing one over another at
-	 * this level of joining, but some sort orders may be more useful
-	 * than others for higher-level mergejoins.  Generating a path here
-	 * for *every* permutation of mergejoin clauses doesn't seem like
-	 * a winning strategy, however; the cost in planning time is too high.
+	 * generate a differently-sorted result path at essentially the same
+	 * cost.  We have no basis for choosing one over another at this level
+	 * of joining, but some sort orders may be more useful than others for
+	 * higher-level mergejoins.  Generating a path here for *every*
+	 * permutation of mergejoin clauses doesn't seem like a winning
+	 * strategy, however; the cost in planning time is too high.
 	 *
 	 * For now, we generate one path for each mergejoin clause, listing that
-	 * clause first and the rest in random order.  This should allow at least
-	 * a one-clause mergejoin without re-sorting against any other possible
-	 * mergejoin partner path.  But if we've not guessed the right ordering
-	 * of secondary clauses, we may end up evaluating clauses as qpquals when
-	 * they could have been done as mergeclauses.  We need to figure out a
-	 * better way.  (Two possible approaches: look at all the relevant index
-	 * relations to suggest plausible sort orders, or make just one output
-	 * path and somehow mark it as having a sort-order that can be rearranged
-	 * freely.)
+	 * clause first and the rest in random order.  This should allow at
+	 * least a one-clause mergejoin without re-sorting against any other
+	 * possible mergejoin partner path.  But if we've not guessed the
+	 * right ordering of secondary clauses, we may end up evaluating
+	 * clauses as qpquals when they could have been done as mergeclauses.
+	 * We need to figure out a better way.	(Two possible approaches: look
+	 * at all the relevant index relations to suggest plausible sort
+	 * orders, or make just one output path and somehow mark it as having
+	 * a sort-order that can be rearranged freely.)
 	 */
 	foreach(i, mergeclause_list)
 	{
-		RestrictInfo   *restrictinfo = lfirst(i);
-		List		   *curclause_list;
-		List		   *outerkeys;
-		List		   *innerkeys;
-		List		   *merge_pathkeys;
+		RestrictInfo *restrictinfo = lfirst(i);
+		List	   *curclause_list;
+		List	   *outerkeys;
+		List	   *innerkeys;
+		List	   *merge_pathkeys;
 
 		/* Make a mergeclause list with this guy first. */
 		if (i != mergeclause_list)
@@ -176,13 +179,14 @@ sort_inner_and_outer(Query *root,
 								   lremove(restrictinfo,
 										   listCopy(mergeclause_list)));
 		else
-			curclause_list = mergeclause_list; /* no work at first one... */
+			curclause_list = mergeclause_list;	/* no work at first one... */
 
-		/* Build sort pathkeys for both sides.
+		/*
+		 * Build sort pathkeys for both sides.
 		 *
-		 * Note: it's possible that the cheapest paths will already be
-		 * sorted properly.  create_mergejoin_path will detect that case
-		 * and suppress an explicit sort step, so we needn't do so here.
+		 * Note: it's possible that the cheapest paths will already be sorted
+		 * properly.  create_mergejoin_path will detect that case and
+		 * suppress an explicit sort step, so we needn't do so here.
 		 */
 		outerkeys = make_pathkeys_for_mergeclauses(root,
 												   curclause_list,
@@ -198,8 +202,8 @@ sort_inner_and_outer(Query *root,
 		/*
 		 * And now we can make the path.  We only consider the cheapest-
 		 * total-cost input paths, since we are assuming here that a sort
-		 * is required.  We will consider cheapest-startup-cost input paths
-		 * later, and only if they don't need a sort.
+		 * is required.  We will consider cheapest-startup-cost input
+		 * paths later, and only if they don't need a sort.
 		 */
 		add_path(joinrel, (Path *)
 				 create_mergejoin_path(joinrel,
@@ -225,7 +229,7 @@ sort_inner_and_outer(Query *root,
  * inner path, one on the cheapest-startup-cost inner path (if different),
  * and one on the best inner-indexscan path (if any).
  *
- * We also consider mergejoins if mergejoin clauses are available.  We have
+ * We also consider mergejoins if mergejoin clauses are available.	We have
  * two ways to generate the inner path for a mergejoin: sort the cheapest
  * inner path, or use an inner path that is already suitably ordered for the
  * merge.  If we have several mergeclauses, it could be that there is no inner
@@ -255,8 +259,8 @@ match_unsorted_outer(Query *root,
 	List	   *i;
 
 	/*
-	 * Get the best innerjoin indexpath (if any) for this outer rel.
-	 * It's the same for all outer paths.
+	 * Get the best innerjoin indexpath (if any) for this outer rel. It's
+	 * the same for all outer paths.
 	 */
 	bestinnerjoin = best_innerjoin(innerrel->innerjoin, outerrel->relids);
 
@@ -274,8 +278,8 @@ match_unsorted_outer(Query *root,
 
 		/*
 		 * The result will have this sort order (even if it is implemented
-		 * as a nestloop, and even if some of the mergeclauses are implemented
-		 * by qpquals rather than as true mergeclauses):
+		 * as a nestloop, and even if some of the mergeclauses are
+		 * implemented by qpquals rather than as true mergeclauses):
 		 */
 		merge_pathkeys = build_join_pathkeys(outerpath->pathkeys,
 											 joinrel->targetlist,
@@ -318,11 +322,12 @@ match_unsorted_outer(Query *root,
 		/* Compute the required ordering of the inner path */
 		innersortkeys = make_pathkeys_for_mergeclauses(root,
 													   mergeclauses,
-													   innerrel->targetlist);
+												   innerrel->targetlist);
 
 		/*
-		 * Generate a mergejoin on the basis of sorting the cheapest inner.
-		 * Since a sort will be needed, only cheapest total cost matters.
+		 * Generate a mergejoin on the basis of sorting the cheapest
+		 * inner. Since a sort will be needed, only cheapest total cost
+		 * matters.
 		 */
 		add_path(joinrel, (Path *)
 				 create_mergejoin_path(joinrel,
@@ -335,11 +340,11 @@ match_unsorted_outer(Query *root,
 									   innersortkeys));
 
 		/*
-		 * Look for presorted inner paths that satisfy the mergeclause list
-		 * or any truncation thereof.  Here, we consider both cheap startup
-		 * cost and cheap total cost.
+		 * Look for presorted inner paths that satisfy the mergeclause
+		 * list or any truncation thereof.	Here, we consider both cheap
+		 * startup cost and cheap total cost.
 		 */
-		trialsortkeys = listCopy(innersortkeys); /* modifiable copy */
+		trialsortkeys = listCopy(innersortkeys);		/* modifiable copy */
 		cheapest_startup_inner = NULL;
 		cheapest_total_inner = NULL;
 		num_mergeclauses = length(mergeclauses);
@@ -349,8 +354,9 @@ match_unsorted_outer(Query *root,
 			Path	   *innerpath;
 			List	   *newclauses = NIL;
 
-			/* Look for an inner path ordered well enough to merge with
-			 * the first 'clausecnt' mergeclauses.  NB: trialsortkeys list
+			/*
+			 * Look for an inner path ordered well enough to merge with
+			 * the first 'clausecnt' mergeclauses.	NB: trialsortkeys list
 			 * is modified destructively, which is why we made a copy...
 			 */
 			trialsortkeys = ltruncate(clausecnt, trialsortkeys);
@@ -391,14 +397,16 @@ match_unsorted_outer(Query *root,
 				/* Found a cheap (or even-cheaper) sorted path */
 				if (innerpath != cheapest_total_inner)
 				{
-					/* Avoid rebuilding clause list if we already made one;
-					 * saves memory in big join trees...
+
+					/*
+					 * Avoid rebuilding clause list if we already made
+					 * one; saves memory in big join trees...
 					 */
 					if (newclauses == NIL)
 					{
 						if (clausecnt < num_mergeclauses)
 							newclauses = ltruncate(clausecnt,
-												   listCopy(mergeclauses));
+												 listCopy(mergeclauses));
 						else
 							newclauses = mergeclauses;
 					}
@@ -461,11 +469,12 @@ match_unsorted_inner(Query *root,
 		/* Compute the required ordering of the outer path */
 		outersortkeys = make_pathkeys_for_mergeclauses(root,
 													   mergeclauses,
-													   outerrel->targetlist);
+												   outerrel->targetlist);
 
 		/*
-		 * Generate a mergejoin on the basis of sorting the cheapest outer.
-		 * Since a sort will be needed, only cheapest total cost matters.
+		 * Generate a mergejoin on the basis of sorting the cheapest
+		 * outer. Since a sort will be needed, only cheapest total cost
+		 * matters.
 		 */
 		merge_pathkeys = build_join_pathkeys(outersortkeys,
 											 joinrel->targetlist,
@@ -479,10 +488,11 @@ match_unsorted_inner(Query *root,
 									   mergeclauses,
 									   outersortkeys,
 									   NIL));
+
 		/*
 		 * Now generate mergejoins based on already-sufficiently-ordered
-		 * outer paths.  There's likely to be some redundancy here with paths
-		 * already generated by merge_unsorted_outer ... but since
+		 * outer paths.  There's likely to be some redundancy here with
+		 * paths already generated by merge_unsorted_outer ... but since
 		 * merge_unsorted_outer doesn't consider all permutations of the
 		 * mergeclause list, it may fail to notice that this particular
 		 * innerpath could have been used with this outerpath.
@@ -491,7 +501,8 @@ match_unsorted_inner(Query *root,
 														outersortkeys,
 														TOTAL_COST);
 		if (totalouterpath == NULL)
-			continue;			/* there won't be a startup-cost path either */
+			continue;			/* there won't be a startup-cost path
+								 * either */
 
 		merge_pathkeys = build_join_pathkeys(totalouterpath->pathkeys,
 											 joinrel->targetlist,
@@ -552,8 +563,8 @@ hash_inner_and_outer(Query *root,
 	List	   *i;
 
 	/*
-	 * Scan the join's restrictinfo list to find hashjoinable clauses
-	 * that are usable with this pair of sub-relations.  Since we currently
+	 * Scan the join's restrictinfo list to find hashjoinable clauses that
+	 * are usable with this pair of sub-relations.	Since we currently
 	 * accept only var-op-var clauses as hashjoinable, we need only check
 	 * the membership of the vars to determine whether a particular clause
 	 * can be used with this pair of sub-relations.  This code would need
@@ -568,7 +579,7 @@ hash_inner_and_outer(Query *root,
 				   *right,
 				   *inner;
 		List	   *hashclauses;
-		Selectivity	innerdisbursion;
+		Selectivity innerdisbursion;
 
 		if (restrictinfo->hashjoinoperator == InvalidOid)
 			continue;			/* not hashjoinable */
@@ -595,9 +606,9 @@ hash_inner_and_outer(Query *root,
 		innerdisbursion = estimate_disbursion(root, inner);
 
 		/*
-		 * We consider both the cheapest-total-cost and cheapest-startup-cost
-		 * outer paths.  There's no need to consider any but the cheapest-
-		 * total-cost inner path, however.
+		 * We consider both the cheapest-total-cost and
+		 * cheapest-startup-cost outer paths.  There's no need to consider
+		 * any but the cheapest- total-cost inner path, however.
 		 */
 		add_path(joinrel, (Path *)
 				 create_hashjoin_path(joinrel,
@@ -644,7 +655,8 @@ best_innerjoin(List *join_paths, Relids outer_relids)
 
 		Assert(IsA(path, IndexPath));
 
-		/* path->joinrelids is the set of base rels that must be part of
+		/*
+		 * path->joinrelids is the set of base rels that must be part of
 		 * outer_relids in order to use this inner path, because those
 		 * rels are used in the index join quals of this inner path.
 		 */
@@ -661,7 +673,7 @@ best_innerjoin(List *join_paths, Relids outer_relids)
  *
  * We use a default of 0.1 if we can't figure out anything better.
  * This will typically discourage use of a hash rather strongly,
- * if the inner relation is large.  We do not want to hash unless
+ * if the inner relation is large.	We do not want to hash unless
  * we know that the inner rel is well-dispersed (or the alternatives
  * seem much worse).
  */
@@ -670,7 +682,7 @@ estimate_disbursion(Query *root, Var *var)
 {
 	Oid			relid;
 
-	if (! IsA(var, Var))
+	if (!IsA(var, Var))
 		return 0.1;
 
 	relid = getrelid(var->varno, root->rtable);
@@ -690,7 +702,7 @@ estimate_disbursion(Query *root, Var *var)
  * Since we currently allow only plain Vars as the left and right sides
  * of mergejoin clauses, this test is relatively simple.  This routine
  * would need to be upgraded to support more-complex expressions
- * as sides of mergejoins.  In theory, we could allow arbitrarily complex
+ * as sides of mergejoins.	In theory, we could allow arbitrarily complex
  * expressions in mergejoins, so long as one side uses only vars from one
  * sub-relation and the other side uses only vars from the other.
  */
diff --git a/src/backend/optimizer/path/joinrels.c b/src/backend/optimizer/path/joinrels.c
index e872b67623acc3b22bee6bc04dfc375c0387ab61..09003eb9fa852d5448b8ca94000cc0644a5a70aa 100644
--- a/src/backend/optimizer/path/joinrels.c
+++ b/src/backend/optimizer/path/joinrels.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.43 2000/02/07 04:40:59 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.44 2000/04/12 17:15:20 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -22,7 +22,7 @@
 
 
 static RelOptInfo *make_join_rel(Query *root, RelOptInfo *rel1,
-								 RelOptInfo *rel2);
+			  RelOptInfo *rel2);
 
 
 /*
@@ -44,22 +44,23 @@ make_rels_by_joins(Query *root, int level)
 	/*
 	 * First, consider left-sided and right-sided plans, in which rels of
 	 * exactly level-1 member relations are joined against base relations.
-	 * We prefer to join using join clauses, but if we find a rel of level-1
-	 * members that has no join clauses, we will generate Cartesian-product
-	 * joins against all base rels not already contained in it.
+	 * We prefer to join using join clauses, but if we find a rel of
+	 * level-1 members that has no join clauses, we will generate
+	 * Cartesian-product joins against all base rels not already contained
+	 * in it.
 	 *
 	 * In the first pass (level == 2), we try to join each base rel to each
 	 * base rel that appears later in base_rel_list.  (The mirror-image
-	 * joins are handled automatically by make_join_rel.)  In later passes,
-	 * we try to join rels of size level-1 from join_rel_list to each
-	 * base rel in base_rel_list.
+	 * joins are handled automatically by make_join_rel.)  In later
+	 * passes, we try to join rels of size level-1 from join_rel_list to
+	 * each base rel in base_rel_list.
 	 *
 	 * We assume that the rels already present in join_rel_list appear in
 	 * decreasing order of level (number of members).  This should be true
 	 * since we always add new higher-level rels to the front of the list.
 	 */
 	if (level == 2)
-		r = root->base_rel_list;	/* level-1 is base rels */
+		r = root->base_rel_list;/* level-1 is base rels */
 	else
 		r = root->join_rel_list;
 	for (; r != NIL; r = lnext(r))
@@ -68,21 +69,23 @@ make_rels_by_joins(Query *root, int level)
 		int			old_level = length(old_rel->relids);
 		List	   *other_rels;
 
-		if (old_level != level-1)
+		if (old_level != level - 1)
 			break;
 
 		if (level == 2)
-			other_rels = lnext(r); /* only consider remaining base rels */
+			other_rels = lnext(r);		/* only consider remaining base
+										 * rels */
 		else
-			other_rels = root->base_rel_list; /* consider all base rels */
+			other_rels = root->base_rel_list;	/* consider all base rels */
 
 		if (old_rel->joininfo != NIL)
 		{
+
 			/*
-			 * Note that if all available join clauses for this rel require
-			 * more than one other rel, we will fail to make any joins against
-			 * it here.  That's OK; it'll be considered by "bushy plan" join
-			 * code in a higher-level pass.
+			 * Note that if all available join clauses for this rel
+			 * require more than one other rel, we will fail to make any
+			 * joins against it here.  That's OK; it'll be considered by
+			 * "bushy plan" join code in a higher-level pass.
 			 */
 			make_rels_by_clause_joins(root,
 									  old_rel,
@@ -90,6 +93,7 @@ make_rels_by_joins(Query *root, int level)
 		}
 		else
 		{
+
 			/*
 			 * Oops, we have a relation that is not joined to any other
 			 * relation.  Cartesian product time.
@@ -103,10 +107,11 @@ make_rels_by_joins(Query *root, int level)
 	/*
 	 * Now, consider "bushy plans" in which relations of k base rels are
 	 * joined to relations of level-k base rels, for 2 <= k <= level-2.
-	 * The previous loop left r pointing to the first rel of level level-2.
+	 * The previous loop left r pointing to the first rel of level
+	 * level-2.
 	 *
-	 * We only consider bushy-plan joins for pairs of rels where there is
-	 * a suitable join clause, in order to avoid unreasonable growth of
+	 * We only consider bushy-plan joins for pairs of rels where there is a
+	 * suitable join clause, in order to avoid unreasonable growth of
 	 * planning time.
 	 */
 	for (; r != NIL; r = lnext(r))
@@ -115,8 +120,9 @@ make_rels_by_joins(Query *root, int level)
 		int			old_level = length(old_rel->relids);
 		List	   *r2;
 
-		/* We can quit once past the halfway point (make_join_rel took care
-		 * of making the opposite-direction joins)
+		/*
+		 * We can quit once past the halfway point (make_join_rel took
+		 * care of making the opposite-direction joins)
 		 */
 		if (old_level * 2 < level)
 			break;
@@ -137,8 +143,10 @@ make_rels_by_joins(Query *root, int level)
 			{
 				List	   *i;
 
-				/* OK, we can build a rel of the right level from this pair of
-				 * rels.  Do so if there is at least one usable join clause.
+				/*
+				 * OK, we can build a rel of the right level from this
+				 * pair of rels.  Do so if there is at least one usable
+				 * join clause.
 				 */
 				foreach(i, old_rel->joininfo)
 				{
@@ -192,7 +200,7 @@ make_rels_by_clause_joins(Query *root,
 
 		foreach(j, other_rels)
 		{
-			RelOptInfo   *other_rel = (RelOptInfo *) lfirst(j);
+			RelOptInfo *other_rel = (RelOptInfo *) lfirst(j);
 
 			if (is_subseti(unjoined_relids, other_rel->relids))
 				result = make_join_rel(root, old_rel, other_rel);
@@ -251,8 +259,8 @@ make_rels_by_clauseless_joins(Query *root,
 static RelOptInfo *
 make_join_rel(Query *root, RelOptInfo *rel1, RelOptInfo *rel2)
 {
-	RelOptInfo	   *joinrel;
-	List		   *restrictlist;
+	RelOptInfo *joinrel;
+	List	   *restrictlist;
 
 	/*
 	 * Find or build the join RelOptInfo, and compute the restrictlist
diff --git a/src/backend/optimizer/path/orindxpath.c b/src/backend/optimizer/path/orindxpath.c
index e2ae3f0577a8fcd29efcedf9ba15f7eac81b6dfd..85e96d6b86ccb1df9d238f6f84096bcc995cd77a 100644
--- a/src/backend/optimizer/path/orindxpath.c
+++ b/src/backend/optimizer/path/orindxpath.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.38 2000/03/22 22:08:33 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.39 2000/04/12 17:15:20 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -27,14 +27,14 @@
 
 
 static void best_or_subclause_indices(Query *root, RelOptInfo *rel,
-									  List *subclauses, List *indices,
-									  IndexPath *pathnode);
+						  List *subclauses, List *indices,
+						  IndexPath *pathnode);
 static void best_or_subclause_index(Query *root, RelOptInfo *rel,
-									Expr *subclause, List *indices,
-									List **retIndexQual,
-									Oid *retIndexid,
-									Cost *retStartupCost,
-									Cost *retTotalCost);
+						Expr *subclause, List *indices,
+						List **retIndexQual,
+						Oid *retIndexid,
+						Cost *retStartupCost,
+						Cost *retTotalCost);
 
 
 /*
@@ -61,8 +61,8 @@ create_or_index_paths(Query *root,
 		/*
 		 * Check to see if this clause is an 'or' clause, and, if so,
 		 * whether or not each of the subclauses within the 'or' clause
-		 * has been matched by an index.  The information used was
-		 * saved by create_index_paths().
+		 * has been matched by an index.  The information used was saved
+		 * by create_index_paths().
 		 */
 		if (restriction_is_or_clause(clausenode) &&
 			clausenode->subclauseindices)
@@ -80,6 +80,7 @@ create_or_index_paths(Query *root,
 			}
 			if (all_indexable)
 			{
+
 				/*
 				 * OK, build an IndexPath for this OR clause, using the
 				 * best available index for each subclause.
@@ -88,19 +89,23 @@ create_or_index_paths(Query *root,
 
 				pathnode->path.pathtype = T_IndexScan;
 				pathnode->path.parent = rel;
+
 				/*
-				 * This is an IndexScan, but the overall result will consist
-				 * of tuples extracted in multiple passes (one for each
-				 * subclause of the OR), so the result cannot be claimed
-				 * to have any particular ordering.
+				 * This is an IndexScan, but the overall result will
+				 * consist of tuples extracted in multiple passes (one for
+				 * each subclause of the OR), so the result cannot be
+				 * claimed to have any particular ordering.
 				 */
 				pathnode->path.pathkeys = NIL;
 
-				/* We don't actually care what order the index scans in ... */
+				/*
+				 * We don't actually care what order the index scans in
+				 * ...
+				 */
 				pathnode->indexscandir = NoMovementScanDirection;
 
 				/* This isn't a nestloop innerjoin, so: */
-				pathnode->joinrelids = NIL;	/* no join clauses here */
+				pathnode->joinrelids = NIL;		/* no join clauses here */
 				pathnode->rows = rel->rows;
 
 				best_or_subclause_indices(root,
@@ -125,7 +130,7 @@ create_or_index_paths(Query *root,
  * This routine also creates the indexqual and indexid lists that will
  * be needed by the executor.  The indexqual list has one entry for each
  * scan of the base rel, which is a sublist of indexqual conditions to
- * apply in that scan.  The implicit semantics are AND across each sublist
+ * apply in that scan.	The implicit semantics are AND across each sublist
  * of quals, and OR across the toplevel list (note that the executor
  * takes care not to return any single tuple more than once).  The indexid
  * list gives the OID of the index to be used in each scan.
@@ -181,7 +186,7 @@ best_or_subclause_indices(Query *root,
 
 		pathnode->indexqual = lappend(pathnode->indexqual, best_indexqual);
 		pathnode->indexid = lappendi(pathnode->indexid, best_indexid);
-		if (slist == subclauses)		/* first scan? */
+		if (slist == subclauses)/* first scan? */
 			pathnode->path.startup_cost = best_startup_cost;
 		pathnode->path.total_cost += best_total_cost;
 
diff --git a/src/backend/optimizer/path/pathkeys.c b/src/backend/optimizer/path/pathkeys.c
index d5fbf82eb50e268fb630dc10e82d5da86630aa8a..580675a85b70b05c24e3496b81983c952a1da258 100644
--- a/src/backend/optimizer/path/pathkeys.c
+++ b/src/backend/optimizer/path/pathkeys.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/pathkeys.c,v 1.20 2000/02/18 23:47:19 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/pathkeys.c,v 1.21 2000/04/12 17:15:20 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -28,7 +28,7 @@
 static PathKeyItem *makePathKeyItem(Node *key, Oid sortop);
 static List *make_canonical_pathkey(Query *root, PathKeyItem *item);
 static Var *find_indexkey_var(Query *root, RelOptInfo *rel,
-							  AttrNumber varattno);
+				  AttrNumber varattno);
 
 
 /*--------------------
@@ -42,8 +42,8 @@ static Var *find_indexkey_var(Query *root, RelOptInfo *rel,
  *	of scanning the relation and the resulting ordering of the tuples.
  *	Sequential scan Paths have NIL pathkeys, indicating no known ordering.
  *	Index scans have Path.pathkeys that represent the chosen index's ordering,
- *  if any.  A single-key index would create a pathkey with a single sublist,
- *	e.g. ( (tab1.indexkey1/sortop1) ).  A multi-key index generates a sublist
+ *	if any.  A single-key index would create a pathkey with a single sublist,
+ *	e.g. ( (tab1.indexkey1/sortop1) ).	A multi-key index generates a sublist
  *	per key, e.g. ( (tab1.indexkey1/sortop1) (tab1.indexkey2/sortop2) ) which
  *	shows major sort by indexkey1 (ordering by sortop1) and minor sort by
  *	indexkey2 with sortop2.
@@ -56,10 +56,10 @@ static Var *find_indexkey_var(Query *root, RelOptInfo *rel,
  *	ordering operators used.
  *
  *	Things get more interesting when we consider joins.  Suppose we do a
- *	mergejoin between A and B using the mergeclause A.X = B.Y.  The output
+ *	mergejoin between A and B using the mergeclause A.X = B.Y.	The output
  *	of the mergejoin is sorted by X --- but it is also sorted by Y.  We
  *	represent this fact by listing both keys in a single pathkey sublist:
- *	( (A.X/xsortop B.Y/ysortop) ).  This pathkey asserts that the major
+ *	( (A.X/xsortop B.Y/ysortop) ).	This pathkey asserts that the major
  *	sort order of the Path can be taken to be *either* A.X or B.Y.
  *	They are equal, so they are both primary sort keys.  By doing this,
  *	we allow future joins to use either var as a pre-sorted key, so upper
@@ -120,12 +120,12 @@ static Var *find_indexkey_var(Query *root, RelOptInfo *rel,
  *	We did implement pathkeys just as described above, and found that the
  *	planner spent a huge amount of time comparing pathkeys, because the
  *	representation of pathkeys as unordered lists made it expensive to decide
- *	whether two were equal or not.  So, we've modified the representation
+ *	whether two were equal or not.	So, we've modified the representation
  *	as described next.
  *
  *	If we scan the WHERE clause for equijoin clauses (mergejoinable clauses)
  *	during planner startup, we can construct lists of equivalent pathkey items
- *	for the query.  There could be more than two items per equivalence set;
+ *	for the query.	There could be more than two items per equivalence set;
  *	for example, WHERE A.X = B.Y AND B.Y = C.Z AND D.R = E.S creates the
  *	equivalence sets { A.X B.Y C.Z } and { D.R E.S } (plus associated sortops).
  *	Any pathkey item that belongs to an equivalence set implies that all the
@@ -147,20 +147,20 @@ static Var *find_indexkey_var(Query *root, RelOptInfo *rel,
  *	equivalence set, we instantly add all the other vars equivalenced to it,
  *	whether they appear yet in the pathkey's relation or not.  And we also
  *	mandate that the pathkey sublist appear in the same order as the
- *	equivalence set it comes from.  (In practice, we simply return a pointer
+ *	equivalence set it comes from.	(In practice, we simply return a pointer
  *	to the relevant equivalence set without building any new sublist at all.)
  *	This makes comparing pathkeys very simple and fast, and saves a lot of
  *	work and memory space for pathkey construction as well.
  *
  *	Note that pathkey sublists having just one item still exist, and are
- *	not expected to be equal() to any equivalence set.  This occurs when
+ *	not expected to be equal() to any equivalence set.	This occurs when
  *	we describe a sort order that involves a var that's not mentioned in
  *	any equijoin clause of the WHERE.  We could add singleton sets containing
  *	such vars to the query's list of equivalence sets, but there's little
  *	point in doing so.
  *
  *	By the way, it's OK and even useful for us to build equivalence sets
- *	that mention multiple vars from the same relation.  For example, if
+ *	that mention multiple vars from the same relation.	For example, if
  *	we have WHERE A.X = A.Y and we are scanning A using an index on X,
  *	we can legitimately conclude that the path is sorted by Y as well;
  *	and this could be handy if Y is the variable used in other join clauses
@@ -179,7 +179,7 @@ static Var *find_indexkey_var(Query *root, RelOptInfo *rel,
 static PathKeyItem *
 makePathKeyItem(Node *key, Oid sortop)
 {
-	PathKeyItem	   *item = makeNode(PathKeyItem);
+	PathKeyItem *item = makeNode(PathKeyItem);
 
 	item->key = key;
 	item->sortop = sortop;
@@ -219,11 +219,13 @@ add_equijoined_keys(Query *root, RestrictInfo *restrictinfo)
 	/* We might see a clause X=X; don't make a single-element list from it */
 	if (equal(item1, item2))
 		return;
+
 	/*
-	 * Our plan is to make a two-element set, then sweep through the existing
-	 * equijoin sets looking for matches to item1 or item2.  When we find one,
-	 * we remove that set from equi_key_list and union it into our new set.
-	 * When done, we add the new set to the front of equi_key_list.
+	 * Our plan is to make a two-element set, then sweep through the
+	 * existing equijoin sets looking for matches to item1 or item2.  When
+	 * we find one, we remove that set from equi_key_list and union it
+	 * into our new set. When done, we add the new set to the front of
+	 * equi_key_list.
 	 *
 	 * This is a standard UNION-FIND problem, for which there exist better
 	 * data structures than simple lists.  If this code ever proves to be
@@ -240,8 +242,11 @@ add_equijoined_keys(Query *root, RestrictInfo *restrictinfo)
 		{
 			/* Found a set to merge into our new set */
 			newset = LispUnion(newset, curset);
-			/* Remove old set from equi_key_list.  NOTE this does not change
-			 * lnext(cursetlink), so the outer foreach doesn't break.
+
+			/*
+			 * Remove old set from equi_key_list.  NOTE this does not
+			 * change lnext(cursetlink), so the outer foreach doesn't
+			 * break.
 			 */
 			root->equi_key_list = lremove(curset, root->equi_key_list);
 			freeList(curset);	/* might as well recycle old cons cells */
@@ -256,7 +261,7 @@ add_equijoined_keys(Query *root, RestrictInfo *restrictinfo)
  *	  Given a PathKeyItem, find the equi_key_list subset it is a member of,
  *	  if any.  If so, return a pointer to that sublist, which is the
  *	  canonical representation (for this query) of that PathKeyItem's
- *	  equivalence set.  If it is not found, return a single-element list
+ *	  equivalence set.	If it is not found, return a single-element list
  *	  containing the PathKeyItem (when the item has no equivalence peers,
  *	  we just allow it to be a standalone list).
  *
@@ -293,13 +298,13 @@ canonicalize_pathkeys(Query *root, List *pathkeys)
 
 	foreach(i, pathkeys)
 	{
-		List		   *pathkey = (List *) lfirst(i);
-		PathKeyItem	   *item;
+		List	   *pathkey = (List *) lfirst(i);
+		PathKeyItem *item;
 
 		/*
-		 * It's sufficient to look at the first entry in the sublist;
-		 * if there are more entries, they're already part of an
-		 * equivalence set by definition.
+		 * It's sufficient to look at the first entry in the sublist; if
+		 * there are more entries, they're already part of an equivalence
+		 * set by definition.
 		 */
 		Assert(pathkey != NIL);
 		item = (PathKeyItem *) lfirst(pathkey);
@@ -319,12 +324,12 @@ canonicalize_pathkeys(Query *root, List *pathkeys)
  *	  one is "better" than the other.
  *
  *	  A pathkey can be considered better than another if it is a superset:
- *	  it contains all the keys of the other plus more.  For example, either
+ *	  it contains all the keys of the other plus more.	For example, either
  *	  ((A) (B)) or ((A B)) is better than ((A)).
  *
  *	  Because we actually only expect to see canonicalized pathkey sublists,
  *	  we don't have to do the full two-way-subset-inclusion test on each
- *	  pair of sublists that is implied by the above statement.  Instead we
+ *	  pair of sublists that is implied by the above statement.	Instead we
  *	  just do an equal().  In the normal case where multi-element sublists
  *	  are pointers into the root's equi_key_list, equal() will be very fast:
  *	  it will recognize pointer equality when the sublists are the same,
@@ -345,23 +350,25 @@ compare_pathkeys(List *keys1, List *keys2)
 		List	   *subkey1 = lfirst(key1);
 		List	   *subkey2 = lfirst(key2);
 
-		/* We will never have two subkeys where one is a subset of the other,
-		 * because of the canonicalization explained above.  Either they are
-		 * equal or they ain't.
+		/*
+		 * We will never have two subkeys where one is a subset of the
+		 * other, because of the canonicalization explained above.	Either
+		 * they are equal or they ain't.
 		 */
-		if (! equal(subkey1, subkey2))
-			return PATHKEYS_DIFFERENT; /* no need to keep looking */
+		if (!equal(subkey1, subkey2))
+			return PATHKEYS_DIFFERENT;	/* no need to keep looking */
 	}
 
-	/* If we reached the end of only one list, the other is longer and
-	 * therefore not a subset.  (We assume the additional sublist(s)
-	 * of the other list are not NIL --- no pathkey list should ever have
-	 * a NIL sublist.)
+	/*
+	 * If we reached the end of only one list, the other is longer and
+	 * therefore not a subset.	(We assume the additional sublist(s) of
+	 * the other list are not NIL --- no pathkey list should ever have a
+	 * NIL sublist.)
 	 */
 	if (key1 == NIL && key2 == NIL)
 		return PATHKEYS_EQUAL;
 	if (key1 != NIL)
-		return PATHKEYS_BETTER1; /* key1 is longer */
+		return PATHKEYS_BETTER1;/* key1 is longer */
 	return PATHKEYS_BETTER2;	/* key2 is longer */
 }
 
@@ -375,8 +382,8 @@ pathkeys_contained_in(List *keys1, List *keys2)
 {
 	switch (compare_pathkeys(keys1, keys2))
 	{
-		case PATHKEYS_EQUAL:
-		case PATHKEYS_BETTER2:
+			case PATHKEYS_EQUAL:
+			case PATHKEYS_BETTER2:
 			return true;
 		default:
 			break;
@@ -448,7 +455,7 @@ get_cheapest_fractional_path_for_pathkeys(List *paths,
 		 * do that first.
 		 */
 		if (matched_path != NULL &&
-			compare_fractional_path_costs(matched_path, path, fraction) <= 0)
+		compare_fractional_path_costs(matched_path, path, fraction) <= 0)
 			continue;
 
 		if (pathkeys_contained_in(pathkeys, path->pathkeys))
@@ -469,7 +476,7 @@ get_cheapest_fractional_path_for_pathkeys(List *paths,
  *	  its "ordering" field, and we will return NIL.)
  *
  * If 'scandir' is BackwardScanDirection, attempt to build pathkeys
- * representing a backwards scan of the index.  Return NIL if can't do it.
+ * representing a backwards scan of the index.	Return NIL if can't do it.
  */
 List *
 build_index_pathkeys(Query *root,
@@ -527,7 +534,7 @@ build_index_pathkeys(Query *root,
 		/* Normal non-functional index */
 		while (*indexkeys != 0 && *ordering != InvalidOid)
 		{
-			Var		*relvar = find_indexkey_var(root, rel, *indexkeys);
+			Var		   *relvar = find_indexkey_var(root, rel, *indexkeys);
 
 			sortop = *ordering;
 			if (ScanDirectionIsBackward(scandir))
@@ -569,9 +576,9 @@ find_indexkey_var(Query *root, RelOptInfo *rel, AttrNumber varattno)
 
 	foreach(temp, rel->targetlist)
 	{
-		Var	   *tle_var = get_expr(lfirst(temp));
+		Var		   *tle_var = get_expr(lfirst(temp));
 
-		if (IsA(tle_var, Var) && tle_var->varattno == varattno)
+		if (IsA(tle_var, Var) &&tle_var->varattno == varattno)
 			return tle_var;
 	}
 
@@ -606,11 +613,12 @@ build_join_pathkeys(List *outer_pathkeys,
 					List *join_rel_tlist,
 					List *equi_key_list)
 {
+
 	/*
 	 * This used to be quite a complex bit of code, but now that all
-	 * pathkey sublists start out life canonicalized, we don't have to
-	 * do a darn thing here!  The inner-rel vars we used to need to add
-	 * are *already* part of the outer pathkey!
+	 * pathkey sublists start out life canonicalized, we don't have to do
+	 * a darn thing here!  The inner-rel vars we used to need to add are
+	 * *already* part of the outer pathkey!
 	 *
 	 * I'd remove the routine entirely, but maybe someday we'll need it...
 	 */
@@ -644,16 +652,17 @@ make_pathkeys_for_sortclauses(List *sortclauses,
 
 	foreach(i, sortclauses)
 	{
-		SortClause	   *sortcl = (SortClause *) lfirst(i);
-		Node		   *sortkey;
-		PathKeyItem	   *pathkey;
+		SortClause *sortcl = (SortClause *) lfirst(i);
+		Node	   *sortkey;
+		PathKeyItem *pathkey;
 
 		sortkey = get_sortgroupclause_expr(sortcl, tlist);
 		pathkey = makePathKeyItem(sortkey, sortcl->sortop);
+
 		/*
 		 * The pathkey becomes a one-element sublist, for now;
-		 * canonicalize_pathkeys() might replace it with a longer
-		 * sublist later.
+		 * canonicalize_pathkeys() might replace it with a longer sublist
+		 * later.
 		 */
 		pathkeys = lappend(pathkeys, lcons(pathkey, NIL));
 	}
@@ -691,28 +700,28 @@ find_mergeclauses_for_pathkeys(List *pathkeys, List *restrictinfos)
 
 	foreach(i, pathkeys)
 	{
-		List		   *pathkey = lfirst(i);
-		RestrictInfo   *matched_restrictinfo = NULL;
-		List		   *j;
+		List	   *pathkey = lfirst(i);
+		RestrictInfo *matched_restrictinfo = NULL;
+		List	   *j;
 
 		/*
-		 * We can match any of the keys in this pathkey sublist,
-		 * since they're all equivalent.  And we can match against
-		 * either left or right side of any mergejoin clause we haven't
-		 * used yet.  For the moment we use a dumb "greedy" algorithm
-		 * with no backtracking.  Is it worth being any smarter to
-		 * make a longer list of usable mergeclauses?  Probably not.
+		 * We can match any of the keys in this pathkey sublist, since
+		 * they're all equivalent.  And we can match against either left
+		 * or right side of any mergejoin clause we haven't used yet.  For
+		 * the moment we use a dumb "greedy" algorithm with no
+		 * backtracking.  Is it worth being any smarter to make a longer
+		 * list of usable mergeclauses?  Probably not.
 		 */
 		foreach(j, pathkey)
 		{
-			PathKeyItem	   *keyitem = lfirst(j);
-			Node		   *key = keyitem->key;
-			Oid				keyop = keyitem->sortop;
-			List		   *k;
+			PathKeyItem *keyitem = lfirst(j);
+			Node	   *key = keyitem->key;
+			Oid			keyop = keyitem->sortop;
+			List	   *k;
 
 			foreach(k, restrictinfos)
 			{
-				RestrictInfo   *restrictinfo = lfirst(k);
+				RestrictInfo *restrictinfo = lfirst(k);
 
 				Assert(restrictinfo->mergejoinoperator != InvalidOid);
 
@@ -720,7 +729,7 @@ find_mergeclauses_for_pathkeys(List *pathkeys, List *restrictinfos)
 					  equal(key, get_leftop(restrictinfo->clause))) ||
 					 (keyop == restrictinfo->right_sortop &&
 					  equal(key, get_rightop(restrictinfo->clause)))) &&
-					! member(restrictinfo, mergeclauses))
+					!member(restrictinfo, mergeclauses))
 				{
 					matched_restrictinfo = restrictinfo;
 					break;
@@ -732,11 +741,12 @@ find_mergeclauses_for_pathkeys(List *pathkeys, List *restrictinfos)
 
 		/*
 		 * If we didn't find a mergeclause, we're done --- any additional
-		 * sort-key positions in the pathkeys are useless.  (But we can
+		 * sort-key positions in the pathkeys are useless.	(But we can
 		 * still mergejoin if we found at least one mergeclause.)
 		 */
-		if (! matched_restrictinfo)
+		if (!matched_restrictinfo)
 			break;
+
 		/*
 		 * If we did find a usable mergeclause for this sort-key position,
 		 * add it to result list.
@@ -756,7 +766,7 @@ find_mergeclauses_for_pathkeys(List *pathkeys, List *restrictinfos)
  * 'mergeclauses' is a list of RestrictInfos for mergejoin clauses
  *			that will be used in a merge join.
  * 'tlist' is a relation target list for either the inner or outer
- *			side of the proposed join rel.  (Not actually needed anymore)
+ *			side of the proposed join rel.	(Not actually needed anymore)
  *
  * Returns a pathkeys list that can be applied to the indicated relation.
  *
@@ -785,24 +795,26 @@ make_pathkeys_for_mergeclauses(Query *root,
 		/*
 		 * Find the key and sortop needed for this mergeclause.
 		 *
-		 * Both sides of the mergeclause should appear in one of the
-		 * query's pathkey equivalence classes, so it doesn't matter
-		 * which one we use here.
+		 * Both sides of the mergeclause should appear in one of the query's
+		 * pathkey equivalence classes, so it doesn't matter which one we
+		 * use here.
 		 */
 		key = (Node *) get_leftop(restrictinfo->clause);
 		sortop = restrictinfo->left_sortop;
+
 		/*
-		 * Find pathkey sublist for this sort item.  We expect to find
-		 * the canonical set including the mergeclause's left and right
-		 * sides; if we get back just the one item, something is rotten.
+		 * Find pathkey sublist for this sort item.  We expect to find the
+		 * canonical set including the mergeclause's left and right sides;
+		 * if we get back just the one item, something is rotten.
 		 */
 		item = makePathKeyItem(key, sortop);
 		pathkey = make_canonical_pathkey(root, item);
 		Assert(length(pathkey) > 1);
+
 		/*
-		 * Since the item we just made is not in the returned canonical set,
-		 * we can free it --- this saves a useful amount of storage in a
-		 * big join tree.
+		 * Since the item we just made is not in the returned canonical
+		 * set, we can free it --- this saves a useful amount of storage
+		 * in a big join tree.
 		 */
 		pfree(item);
 
diff --git a/src/backend/optimizer/path/tidpath.c b/src/backend/optimizer/path/tidpath.c
index 1e7dc43473b24f638a02263ae750c575ffb144b8..7824e0e3d2f9815511806b17888abce7bf152b83 100644
--- a/src/backend/optimizer/path/tidpath.c
+++ b/src/backend/optimizer/path/tidpath.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/tidpath.c,v 1.5 2000/02/15 20:49:17 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/tidpath.c,v 1.6 2000/04/12 17:15:20 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -37,30 +37,34 @@
 #include "utils/lsyscache.h"
 
 static void create_tidscan_joinpaths(RelOptInfo *rel);
-static List	*TidqualFromRestrictinfo(List *relids, List *restrictinfo);
-static bool	isEvaluable(int varno, Node *node);
-static Node	*TidequalClause(int varno, Expr *node);
-static List	*TidqualFromExpr(int varno, Expr *expr);
+static List *TidqualFromRestrictinfo(List *relids, List *restrictinfo);
+static bool isEvaluable(int varno, Node *node);
+static Node *TidequalClause(int varno, Expr *node);
+static List *TidqualFromExpr(int varno, Expr *expr);
 
 static
-bool isEvaluable(int varno, Node *node)
+bool
+isEvaluable(int varno, Node *node)
 {
-	List	*lst;
-	Expr	*expr;
+	List	   *lst;
+	Expr	   *expr;
 
-	if (IsA(node, Const))		return true;
-	if (IsA(node, Param))		return true;
+	if (IsA(node, Const))
+		return true;
+	if (IsA(node, Param))
+		return true;
 	if (IsA(node, Var))
 	{
-		Var	*var = (Var *)node;
+		Var		   *var = (Var *) node;
 
 		if (var->varno == varno)
 			return false;
 		return true;
 	}
-	if (!is_funcclause(node))	return false;
-	expr = (Expr *)node;
-	foreach (lst, expr->args)
+	if (!is_funcclause(node))
+		return false;
+	expr = (Expr *) node;
+	foreach(lst, expr->args)
 	{
 		if (!isEvaluable(varno, lfirst(lst)))
 			return false;
@@ -72,53 +76,60 @@ bool isEvaluable(int varno, Node *node)
 /*
  *	The 2nd parameter should be an opclause
  *	Extract the right node if the opclause is CTID= ....
- *	  or    the left  node if the opclause is ....=CTID
+ *	  or	the left  node if the opclause is ....=CTID
  */
 static
-Node *TidequalClause(int varno, Expr *node)
+Node *
+TidequalClause(int varno, Expr *node)
 {
-	Node	*rnode = 0, *arg1, *arg2, *arg;
-	Oper	*oper;
-	Var	*var;
-	Const	*aconst;
-	Param	*param;
-	Expr	*expr;
+	Node	   *rnode = 0,
+			   *arg1,
+			   *arg2,
+			   *arg;
+	Oper	   *oper;
+	Var		   *var;
+	Const	   *aconst;
+	Param	   *param;
+	Expr	   *expr;
 
-	if (!node->oper)		return rnode;
-	if (!node->args)		return rnode;
-	if (length(node->args) != 2)	return rnode;
-        oper = (Oper *) node->oper;
+	if (!node->oper)
+		return rnode;
+	if (!node->args)
+		return rnode;
+	if (length(node->args) != 2)
+		return rnode;
+	oper = (Oper *) node->oper;
 	if (oper->opno != TIDEqualOperator)
 		return rnode;
 	arg1 = lfirst(node->args);
 	arg2 = lsecond(node->args);
 
-	arg = (Node *)0;
+	arg = (Node *) 0;
 	if (IsA(arg1, Var))
 	{
 		var = (Var *) arg1;
 		if (var->varno == varno &&
-		    var->varattno == SelfItemPointerAttributeNumber &&
-		    var->vartype == TIDOID)
+			var->varattno == SelfItemPointerAttributeNumber &&
+			var->vartype == TIDOID)
 			arg = arg2;
 		else if (var->varnoold == varno &&
-		    	var->varoattno == SelfItemPointerAttributeNumber &&
-		    	var->vartype == TIDOID)
+				 var->varoattno == SelfItemPointerAttributeNumber &&
+				 var->vartype == TIDOID)
 			arg = arg2;
 	}
 	if ((!arg) && IsA(arg2, Var))
 	{
 		var = (Var *) arg2;
 		if (var->varno == varno &&
-		    var->varattno == SelfItemPointerAttributeNumber &&
-		    var->vartype == TIDOID)
+			var->varattno == SelfItemPointerAttributeNumber &&
+			var->vartype == TIDOID)
 			arg = arg1;
 	}
 	if (!arg)
 		return rnode;
 	switch (nodeTag(arg))
 	{
-	 	case T_Const:
+		case T_Const:
 			aconst = (Const *) arg;
 			if (aconst->consttype != TIDOID)
 				return rnode;
@@ -126,27 +137,29 @@ Node *TidequalClause(int varno, Expr *node)
 				return rnode;
 			rnode = arg;
 			break;
-	 	case T_Param:
+		case T_Param:
 			param = (Param *) arg;
 			if (param->paramtype != TIDOID)
 				return rnode;
 			rnode = arg;
 			break;
-	 	case T_Var:
+		case T_Var:
 			var = (Var *) arg;
 			if (var->varno == varno ||
-			    var->vartype != TIDOID)
+				var->vartype != TIDOID)
 				return rnode;
 			rnode = arg;
 			break;
-	 	case T_Expr:
+		case T_Expr:
 			expr = (Expr *) arg;
-			if (expr->typeOid != TIDOID)	return rnode;
-			if (expr->opType != FUNC_EXPR)	return rnode;
-			if (isEvaluable(varno, (Node *)expr))
+			if (expr->typeOid != TIDOID)
+				return rnode;
+			if (expr->opType != FUNC_EXPR)
+				return rnode;
+			if (isEvaluable(varno, (Node *) expr))
 				rnode = arg;
 			break;
-	 	default:
+		default:
 			break;
 	}
 	return rnode;
@@ -160,43 +173,43 @@ Node *TidequalClause(int varno, Expr *node)
  *	When the expr node is an and_clause,we return the list of
  *	CTID values if we could extract the CTID values from a member
  *	node.
- */ 
+ */
 static
-List *TidqualFromExpr(int varno, Expr *expr)
+List *
+TidqualFromExpr(int varno, Expr *expr)
 {
-	List	*rlst = NIL, *lst, *frtn;
-	Node	*node = (Node *) expr, *rnode;
+	List	   *rlst = NIL,
+			   *lst,
+			   *frtn;
+	Node	   *node = (Node *) expr,
+			   *rnode;
 
 	if (is_opclause(node))
 	{
 		rnode = TidequalClause(varno, expr);
 		if (rnode)
-		{
 			rlst = lcons(rnode, rlst);
-		} 
 	}
 	else if (and_clause(node))
 	{
-		foreach (lst, expr->args)
+		foreach(lst, expr->args)
 		{
 			node = lfirst(lst);
-			if (!IsA(node, Expr))	
+			if (!IsA(node, Expr))
 				continue;
-			rlst = TidqualFromExpr(varno, (Expr *)node);
+			rlst = TidqualFromExpr(varno, (Expr *) node);
 			if (rlst)
 				break;
 		}
 	}
 	else if (or_clause(node))
 	{
-		foreach (lst, expr->args)
+		foreach(lst, expr->args)
 		{
 			node = lfirst(lst);
 			if (IsA(node, Expr) &&
-			    (frtn = TidqualFromExpr(varno, (Expr *)node)) )
-			{
+				(frtn = TidqualFromExpr(varno, (Expr *) node)))
 				rlst = nconc(rlst, frtn);
-			}
 			else
 			{
 				if (rlst)
@@ -207,24 +220,26 @@ List *TidqualFromExpr(int varno, Expr *expr)
 		}
 	}
 	return rlst;
-} 
+}
 
 static List *
 TidqualFromRestrictinfo(List *relids, List *restrictinfo)
 {
-	List	*lst, *rlst = NIL;
-	int	varno;
-	Node	*node;
-	Expr	*expr;
+	List	   *lst,
+			   *rlst = NIL;
+	int			varno;
+	Node	   *node;
+	Expr	   *expr;
 
 	if (length(relids) != 1)
 		return NIL;
 	varno = lfirsti(relids);
-	foreach (lst, restrictinfo)
+	foreach(lst, restrictinfo)
 	{
 		node = lfirst(lst);
-		if (!IsA(node, RestrictInfo))	continue;
-		expr = ((RestrictInfo *)node)->clause;
+		if (!IsA(node, RestrictInfo))
+			continue;
+		expr = ((RestrictInfo *) node)->clause;
 		rlst = TidqualFromExpr(varno, expr);
 		if (rlst)
 			break;
@@ -241,20 +256,20 @@ TidqualFromRestrictinfo(List *relids, List *restrictinfo)
 static void
 create_tidscan_joinpaths(RelOptInfo *rel)
 {
-	List		*rlst = NIL,
-				*lst;
+	List	   *rlst = NIL,
+			   *lst;
 
-	foreach (lst, rel->joininfo)
+	foreach(lst, rel->joininfo)
 	{
 		JoinInfo   *joininfo = (JoinInfo *) lfirst(lst);
-		List		*restinfo,
-					*tideval;
+		List	   *restinfo,
+				   *tideval;
 
 		restinfo = joininfo->jinfo_restrictinfo;
 		tideval = TidqualFromRestrictinfo(rel->relids, restinfo);
 		if (length(tideval) == 1)
 		{
-			TidPath		*pathnode = makeNode(TidPath);
+			TidPath    *pathnode = makeNode(TidPath);
 
 			pathnode->path.pathtype = T_TidScan;
 			pathnode->path.parent = rel;
@@ -278,9 +293,9 @@ create_tidscan_joinpaths(RelOptInfo *rel)
 void
 create_tidscan_paths(Query *root, RelOptInfo *rel)
 {
-	List	*tideval = TidqualFromRestrictinfo(rel->relids,
-											   rel->baserestrictinfo);
-	
+	List	   *tideval = TidqualFromRestrictinfo(rel->relids,
+												  rel->baserestrictinfo);
+
 	if (tideval)
 		add_path(rel, (Path *) create_tidscan_path(rel, tideval));
 	create_tidscan_joinpaths(rel);
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
index 3fab7f08b877d8922b5bde4df5456104407cd093..9cd8a11159a1266f8c2517ac0f4143d20e229152 100644
--- a/src/backend/optimizer/plan/createplan.c
+++ b/src/backend/optimizer/plan/createplan.c
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.88 2000/04/04 01:21:47 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.89 2000/04/12 17:15:21 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -32,15 +32,15 @@
 
 
 static List *switch_outer(List *clauses);
-static int set_tlist_sort_info(List *tlist, List *pathkeys);
+static int	set_tlist_sort_info(List *tlist, List *pathkeys);
 static Scan *create_scan_node(Query *root, Path *best_path, List *tlist);
 static Join *create_join_node(Query *root, JoinPath *best_path, List *tlist);
 static SeqScan *create_seqscan_node(Path *best_path, List *tlist,
 					List *scan_clauses);
 static IndexScan *create_indexscan_node(Query *root, IndexPath *best_path,
-										List *tlist, List *scan_clauses);
+					  List *tlist, List *scan_clauses);
 static TidScan *create_tidscan_node(TidPath *best_path, List *tlist,
-					  List *scan_clauses); 
+					List *scan_clauses);
 static NestLoop *create_nestloop_node(NestPath *best_path, List *tlist,
 					 List *clauses, Plan *outer_node, List *outer_tlist,
 					 Plan *inner_node, List *inner_tlist);
@@ -52,16 +52,16 @@ static HashJoin *create_hashjoin_node(HashPath *best_path, List *tlist,
 					 Plan *inner_node, List *inner_tlist);
 static List *fix_indxqual_references(List *indexquals, IndexPath *index_path);
 static List *fix_indxqual_sublist(List *indexqual, int baserelid, Oid relam,
-								  Form_pg_index index);
+					 Form_pg_index index);
 static Node *fix_indxqual_operand(Node *node, int baserelid,
-								  Form_pg_index index,
-								  Oid *opclass);
+					 Form_pg_index index,
+					 Oid *opclass);
 static IndexScan *make_indexscan(List *qptlist, List *qpqual, Index scanrelid,
-								 List *indxid, List *indxqual,
-								 List *indxqualorig,
-								 ScanDirection indexscandir);
+			   List *indxid, List *indxqual,
+			   List *indxqualorig,
+			   ScanDirection indexscandir);
 static TidScan *make_tidscan(List *qptlist, List *qpqual, Index scanrelid,
-                        List *tideval);
+			 List *tideval);
 static NestLoop *make_nestloop(List *qptlist, List *qpqual, Plan *lefttree,
 			  Plan *righttree);
 static HashJoin *make_hashjoin(List *tlist, List *qpqual,
@@ -166,8 +166,8 @@ create_scan_node(Query *root, Path *best_path, List *tlist)
 
 		case T_TidScan:
 			node = (Scan *) create_tidscan_node((TidPath *) best_path,
-												  tlist,
-												  scan_clauses);
+												tlist,
+												scan_clauses);
 			break;
 
 		default:
@@ -242,6 +242,7 @@ create_join_node(Query *root, JoinPath *best_path, List *tlist)
 	}
 
 #ifdef NOT_USED
+
 	/*
 	 * * Expensive function pullups may have pulled local predicates *
 	 * into this path node.  Put them in the qpqual of the plan node. *
@@ -250,7 +251,7 @@ create_join_node(Query *root, JoinPath *best_path, List *tlist)
 	if (get_loc_restrictinfo(best_path) != NIL)
 		set_qpqual((Plan) retval,
 				   nconc(get_qpqual((Plan) retval),
-						 get_actual_clauses(get_loc_restrictinfo(best_path))));
+				   get_actual_clauses(get_loc_restrictinfo(best_path))));
 #endif
 
 	return retval;
@@ -345,17 +346,17 @@ create_indexscan_node(Query *root,
 	 * for lossy indices the indxqual predicates need to be double-checked
 	 * after the index fetches the best-guess tuples.
 	 *
-	 * Since the indexquals were generated from the restriction clauses
-	 * given by scan_clauses, there will normally be some duplications
-	 * between the lists.  We get rid of the duplicates, then add back
-	 * if lossy.
+	 * Since the indexquals were generated from the restriction clauses given
+	 * by scan_clauses, there will normally be some duplications between
+	 * the lists.  We get rid of the duplicates, then add back if lossy.
 	 */
 	if (length(indxqual) > 1)
 	{
+
 		/*
 		 * Build an expression representation of the indexqual, expanding
-		 * the implicit OR and AND semantics of the first- and second-level
-		 * lists.
+		 * the implicit OR and AND semantics of the first- and
+		 * second-level lists.
 		 */
 		List	   *orclauses = NIL;
 		List	   *orclause;
@@ -374,8 +375,11 @@ create_indexscan_node(Query *root,
 	}
 	else if (indxqual != NIL)
 	{
-		/* Here, we can simply treat the first sublist as an independent
-		 * set of qual expressions, since there is no top-level OR behavior.
+
+		/*
+		 * Here, we can simply treat the first sublist as an independent
+		 * set of qual expressions, since there is no top-level OR
+		 * behavior.
 		 */
 		List	   *indxqual_list = lfirst(indxqual);
 
@@ -387,8 +391,9 @@ create_indexscan_node(Query *root,
 	else
 		qpqual = scan_clauses;
 
-	/* The executor needs a copy with the indexkey on the left of each clause
-	 * and with index attr numbers substituted for table ones.
+	/*
+	 * The executor needs a copy with the indexkey on the left of each
+	 * clause and with index attr numbers substituted for table ones.
 	 */
 	fixed_indxqual = fix_indxqual_references(indxqual, best_path);
 
@@ -410,11 +415,11 @@ create_indexscan_node(Query *root,
 static TidScan *
 make_tidscan(List *qptlist,
 			 List *qpqual,
-			 Index scanrelid,	
+			 Index scanrelid,
 			 List *tideval)
 {
-	TidScan	*node = makeNode(TidScan);
-	Plan	*plan = &node->scan.plan;
+	TidScan    *node = makeNode(TidScan);
+	Plan	   *plan = &node->scan.plan;
 
 	/* cost should be inserted by caller */
 	plan->state = (EState *) NULL;
@@ -423,7 +428,8 @@ make_tidscan(List *qptlist,
 	plan->lefttree = NULL;
 	plan->righttree = NULL;
 	node->scan.scanrelid = scanrelid;
-	node->tideval = copyObject(tideval); /* XXX do we really need a copy? */
+	node->tideval = copyObject(tideval);		/* XXX do we really need a
+												 * copy? */
 	node->needRescan = false;
 	node->scan.scanstate = (CommonScanState *) NULL;
 
@@ -438,8 +444,8 @@ make_tidscan(List *qptlist,
 static TidScan *
 create_tidscan_node(TidPath *best_path, List *tlist, List *scan_clauses)
 {
-	TidScan	*scan_node;
-	Index	scan_relid;
+	TidScan    *scan_node;
+	Index		scan_relid;
 
 	/* there should be exactly one base rel involved... */
 	Assert(length(best_path->path.parent->relids) == 1);
@@ -452,7 +458,7 @@ create_tidscan_node(TidPath *best_path, List *tlist, List *scan_clauses)
 							 best_path->tideval);
 
 	if (best_path->unjoined_relids)
-		scan_node->needRescan = true; 
+		scan_node->needRescan = true;
 
 	copy_path_costsize(&scan_node->scan.plan, &best_path->path);
 
@@ -467,7 +473,7 @@ create_tidscan_node(TidPath *best_path, List *tlist, List *scan_clauses)
  * once we have changed a Var node to refer to a subplan output rather than
  * the original relation, it is no longer equal() to an unmodified Var node
  * for the same var.  So, we cannot easily compare reference-adjusted qual
- * clauses to clauses that have not been adjusted.  Fortunately, that
+ * clauses to clauses that have not been adjusted.	Fortunately, that
  * doesn't seem to be necessary; all the decisions are made before we do
  * the reference adjustments.
  *
@@ -493,6 +499,7 @@ create_nestloop_node(NestPath *best_path,
 
 	if (IsA(inner_node, IndexScan))
 	{
+
 		/*
 		 * An index is being used to reduce the number of tuples scanned
 		 * in the inner relation.  If there are join clauses being used
@@ -522,12 +529,13 @@ create_nestloop_node(NestPath *best_path,
 		{
 			Index		innerrel = innerscan->scan.scanrelid;
 
-			/* Remove redundant tests from my clauses, if possible.
-			 * Note we must compare against indxqualorig not the "fixed"
-			 * indxqual (which has index attnos instead of relation attnos,
-			 * and may have been commuted as well).
+			/*
+			 * Remove redundant tests from my clauses, if possible. Note
+			 * we must compare against indxqualorig not the "fixed"
+			 * indxqual (which has index attnos instead of relation
+			 * attnos, and may have been commuted as well).
 			 */
-			if (length(indxqualorig) == 1) /* single indexscan? */
+			if (length(indxqualorig) == 1)		/* single indexscan? */
 				clauses = set_difference(clauses, lfirst(indxqualorig));
 
 			/* only refs to outer vars get changed in the inner indexqual */
@@ -549,17 +557,20 @@ create_nestloop_node(NestPath *best_path,
 	}
 	else if (IsA(inner_node, TidScan))
 	{
-		List	*inner_tideval = ((TidScan *) inner_node)->tideval;
-		TidScan	*innerscan = (TidScan *) inner_node; 
+		List	   *inner_tideval = ((TidScan *) inner_node)->tideval;
+		TidScan    *innerscan = (TidScan *) inner_node;
+
 		((TidScan *) inner_node)->tideval = join_references(inner_tideval, outer_tlist, inner_tlist, innerscan->scan.scanrelid);
-	} 
+	}
 	else if (IsA_Join(inner_node))
 	{
+
 		/*
 		 * Materialize the inner join for speed reasons.
 		 *
 		 * XXX It is probably *not* always fastest to materialize an inner
-		 * join --- how can we estimate whether this is a good thing to do?
+		 * join --- how can we estimate whether this is a good thing to
+		 * do?
 		 */
 		inner_node = (Plan *) make_noname(inner_tlist,
 										  NIL,
@@ -595,9 +606,9 @@ create_mergejoin_node(MergePath *best_path,
 	mergeclauses = get_actual_clauses(best_path->path_mergeclauses);
 
 	/*
-	 * Remove the mergeclauses from the list of join qual clauses,
-	 * leaving the list of quals that must be checked as qpquals.
-	 * Set those clauses to contain INNER/OUTER var references.
+	 * Remove the mergeclauses from the list of join qual clauses, leaving
+	 * the list of quals that must be checked as qpquals. Set those
+	 * clauses to contain INNER/OUTER var references.
 	 */
 	qpqual = join_references(set_difference(clauses, mergeclauses),
 							 outer_tlist,
@@ -655,16 +666,16 @@ create_hashjoin_node(HashPath *best_path,
 
 	/*
 	 * NOTE: there will always be exactly one hashclause in the list
-	 * best_path->path_hashclauses (cf. hash_inner_and_outer()).
-	 * We represent it as a list anyway, for convenience with routines
-	 * that want to work on lists of clauses.
+	 * best_path->path_hashclauses (cf. hash_inner_and_outer()). We
+	 * represent it as a list anyway, for convenience with routines that
+	 * want to work on lists of clauses.
 	 */
 	hashclauses = get_actual_clauses(best_path->path_hashclauses);
 
 	/*
-	 * Remove the hashclauses from the list of join qual clauses,
-	 * leaving the list of quals that must be checked as qpquals.
-	 * Set those clauses to contain INNER/OUTER var references.
+	 * Remove the hashclauses from the list of join qual clauses, leaving
+	 * the list of quals that must be checked as qpquals. Set those
+	 * clauses to contain INNER/OUTER var references.
 	 */
 	qpqual = join_references(set_difference(clauses, hashclauses),
 							 outer_tlist,
@@ -779,7 +790,7 @@ fix_indxqual_references(List *indexquals, IndexPath *index_path)
  *
  * For each qual clause, commute if needed to put the indexkey operand on the
  * left, and then change its varno.  (We do not need to change the other side
- * of the clause.)  Also change the operator if necessary.
+ * of the clause.)	Also change the operator if necessary.
  */
 static List *
 fix_indxqual_sublist(List *indexqual, int baserelid, Oid relam,
@@ -803,14 +814,16 @@ fix_indxqual_sublist(List *indexqual, int baserelid, Oid relam,
 			length(clause->args) != 2)
 			elog(ERROR, "fix_indxqual_sublist: indexqual clause is not binary opclause");
 
-		/* Which side is the indexkey on?
+		/*
+		 * Which side is the indexkey on?
 		 *
 		 * get_relattval sets flag&SEL_RIGHT if the indexkey is on the LEFT.
 		 */
 		get_relattval((Node *) clause, baserelid,
 					  &relid, &attno, &constval, &flag);
 
-		/* Make a copy that will become the fixed clause.
+		/*
+		 * Make a copy that will become the fixed clause.
 		 *
 		 * We used to try to do a shallow copy here, but that fails if there
 		 * is a subplan in the arguments of the opclause.  So just do a
@@ -822,18 +835,19 @@ fix_indxqual_sublist(List *indexqual, int baserelid, Oid relam,
 		if ((flag & SEL_RIGHT) == 0)
 			CommuteClause(newclause);
 
-		/* Now, determine which index attribute this is,
-		 * change the indexkey operand as needed,
-		 * and get the index opclass.
+		/*
+		 * Now, determine which index attribute this is, change the
+		 * indexkey operand as needed, and get the index opclass.
 		 */
 		lfirst(newclause->args) = fix_indxqual_operand(lfirst(newclause->args),
 													   baserelid,
 													   index,
 													   &opclass);
 
-		/* Substitute the appropriate operator if the expression operator
-		 * is merely binary-compatible with the index.  This shouldn't fail,
-		 * since indxpath.c found it before...
+		/*
+		 * Substitute the appropriate operator if the expression operator
+		 * is merely binary-compatible with the index.	This shouldn't
+		 * fail, since indxpath.c found it before...
 		 */
 		newopno = indexable_operator(newclause, opclass, relam, true);
 		if (newopno == InvalidOid)
@@ -861,12 +875,14 @@ fix_indxqual_operand(Node *node, int baserelid, Form_pg_index index,
 				if (index->indkey[pos] == varatt)
 				{
 					Node	   *newnode = copyObject(node);
+
 					((Var *) newnode)->varattno = pos + 1;
 					*opclass = index->indclass[pos];
 					return newnode;
 				}
 			}
 		}
+
 		/*
 		 * Oops, this Var isn't the indexkey!
 		 */
@@ -876,13 +892,13 @@ fix_indxqual_operand(Node *node, int baserelid, Form_pg_index index,
 	/*
 	 * Else, it must be a func expression representing a functional index.
 	 *
-	 * Currently, there is no need for us to do anything here for
-	 * functional indexes.  If nodeIndexscan.c sees a func clause as the left
-	 * or right-hand toplevel operand of an indexqual, it assumes that that is
-	 * a reference to the functional index's value and makes the appropriate
-	 * substitution.  (It would be cleaner to make the substitution here, I
-	 * think --- suspect this issue if a join clause involving a function call
-	 * misbehaves...)
+	 * Currently, there is no need for us to do anything here for functional
+	 * indexes.  If nodeIndexscan.c sees a func clause as the left or
+	 * right-hand toplevel operand of an indexqual, it assumes that that
+	 * is a reference to the functional index's value and makes the
+	 * appropriate substitution.  (It would be cleaner to make the
+	 * substitution here, I think --- suspect this issue if a join clause
+	 * involving a function call misbehaves...)
 	 */
 
 	/* indclass[0] is the only class of a functional index */
@@ -915,6 +931,7 @@ switch_outer(List *clauses)
 		Assert(op && IsA(op, Var));
 		if (var_is_outer(op))
 		{
+
 			/*
 			 * Duplicate just enough of the structure to allow commuting
 			 * the clause without changing the original list.  Could use
@@ -954,21 +971,21 @@ set_tlist_sort_info(List *tlist, List *pathkeys)
 
 	foreach(i, pathkeys)
 	{
-		List		   *keysublist = (List *) lfirst(i);
-		PathKeyItem	   *pathkey = NULL;
-		Resdom		   *resdom = NULL;
-		List		   *j;
+		List	   *keysublist = (List *) lfirst(i);
+		PathKeyItem *pathkey = NULL;
+		Resdom	   *resdom = NULL;
+		List	   *j;
 
 		/*
 		 * We can sort by any one of the sort key items listed in this
-		 * sublist.  For now, we take the first one that corresponds to
-		 * an available Var in the tlist.
+		 * sublist.  For now, we take the first one that corresponds to an
+		 * available Var in the tlist.
 		 *
 		 * XXX if we have a choice, is there any way of figuring out which
 		 * might be cheapest to execute?  (For example, int4lt is likely
-		 * much cheaper to execute than numericlt, but both might appear in
-		 * the same pathkey sublist...)  Not clear that we ever will have
-		 * a choice in practice, so it may not matter.
+		 * much cheaper to execute than numericlt, but both might appear
+		 * in the same pathkey sublist...)	Not clear that we ever will
+		 * have a choice in practice, so it may not matter.
 		 */
 		foreach(j, keysublist)
 		{
@@ -982,12 +999,12 @@ set_tlist_sort_info(List *tlist, List *pathkeys)
 			elog(ERROR, "set_tlist_sort_info: cannot find tlist item to sort");
 
 		/*
-		 * The resdom might be already marked as a sort key, if the pathkeys
-		 * contain duplicate entries.  (This can happen in scenarios where
-		 * multiple mergejoinable clauses mention the same var, for example.)
-		 * In that case the current pathkey is essentially a no-op, because
-		 * only one value can be seen within any subgroup where it would be
-		 * consulted.  We can ignore it.
+		 * The resdom might be already marked as a sort key, if the
+		 * pathkeys contain duplicate entries.	(This can happen in
+		 * scenarios where multiple mergejoinable clauses mention the same
+		 * var, for example.) In that case the current pathkey is
+		 * essentially a no-op, because only one value can be seen within
+		 * any subgroup where it would be consulted.  We can ignore it.
 		 */
 		if (resdom->reskey == 0)
 		{
@@ -1195,7 +1212,9 @@ make_hash(List *tlist, Var *hashkey, Plan *lefttree)
 	Plan	   *plan = &node->plan;
 
 	copy_plan_costsize(plan, lefttree);
-	/* For plausibility, make startup & total costs equal total cost of
+
+	/*
+	 * For plausibility, make startup & total costs equal total cost of
 	 * input plan; this only affects EXPLAIN display not decisions.
 	 */
 	plan->startup_cost = plan->total_cost;
@@ -1237,7 +1256,7 @@ make_sort(List *tlist, Oid nonameid, Plan *lefttree, int keycount)
 	Plan	   *plan = &node->plan;
 	Path		sort_path;		/* dummy for result of cost_sort */
 
-	copy_plan_costsize(plan, lefttree);	/* only care about copying size */
+	copy_plan_costsize(plan, lefttree); /* only care about copying size */
 	cost_sort(&sort_path, NIL, lefttree->plan_rows, lefttree->plan_width);
 	plan->startup_cost = sort_path.startup_cost + lefttree->total_cost;
 	plan->total_cost = sort_path.total_cost + lefttree->total_cost;
@@ -1262,9 +1281,11 @@ make_material(List *tlist,
 	Plan	   *plan = &node->plan;
 
 	copy_plan_costsize(plan, lefttree);
-	/* For plausibility, make startup & total costs equal total cost of
-	 * input plan; this only affects EXPLAIN display not decisions.
-	 * XXX shouldn't we charge some additional cost for materialization?
+
+	/*
+	 * For plausibility, make startup & total costs equal total cost of
+	 * input plan; this only affects EXPLAIN display not decisions. XXX
+	 * shouldn't we charge some additional cost for materialization?
 	 */
 	plan->startup_cost = plan->total_cost;
 	plan->state = (EState *) NULL;
@@ -1285,18 +1306,21 @@ make_agg(List *tlist, List *qual, Plan *lefttree)
 	Plan	   *plan = &node->plan;
 
 	copy_plan_costsize(plan, lefttree);
+
 	/*
-	 * Charge one cpu_operator_cost per aggregate function per input tuple.
+	 * Charge one cpu_operator_cost per aggregate function per input
+	 * tuple.
 	 */
 	plan->total_cost += cpu_operator_cost * plan->plan_rows *
 		(length(pull_agg_clause((Node *) tlist)) +
 		 length(pull_agg_clause((Node *) qual)));
+
 	/*
 	 * We will produce a single output tuple if the input is not a Group,
 	 * and a tuple per group otherwise.  For now, estimate the number of
-	 * groups as 10% of the number of tuples --- bogus, but how to do better?
-	 * (Note we assume the input Group node is in "tuplePerGroup" mode,
-	 * so it didn't reduce its row count already.)
+	 * groups as 10% of the number of tuples --- bogus, but how to do
+	 * better? (Note we assume the input Group node is in "tuplePerGroup"
+	 * mode, so it didn't reduce its row count already.)
 	 */
 	if (IsA(lefttree, Group))
 		plan->plan_rows *= 0.1;
@@ -1326,19 +1350,21 @@ make_group(List *tlist,
 	Plan	   *plan = &node->plan;
 
 	copy_plan_costsize(plan, lefttree);
+
 	/*
-	 * Charge one cpu_operator_cost per comparison per input tuple.
-	 * We assume all columns get compared at most of the tuples.
+	 * Charge one cpu_operator_cost per comparison per input tuple. We
+	 * assume all columns get compared at most of the tuples.
 	 */
 	plan->total_cost += cpu_operator_cost * plan->plan_rows * ngrp;
+
 	/*
-	 * If tuplePerGroup (which is named exactly backwards) is true,
-	 * we will return all the input tuples, so the input node's row count
-	 * is OK.  Otherwise, we'll return only one tuple from each group.
-	 * For now, estimate the number of groups as 10% of the number of
-	 * tuples --- bogus, but how to do better?
+	 * If tuplePerGroup (which is named exactly backwards) is true, we
+	 * will return all the input tuples, so the input node's row count is
+	 * OK.	Otherwise, we'll return only one tuple from each group. For
+	 * now, estimate the number of groups as 10% of the number of tuples
+	 * --- bogus, but how to do better?
 	 */
-	if (! tuplePerGroup)
+	if (!tuplePerGroup)
 		plan->plan_rows *= 0.1;
 
 	plan->state = (EState *) NULL;
@@ -1369,11 +1395,13 @@ make_unique(List *tlist, Plan *lefttree, List *distinctList)
 	List	   *slitem;
 
 	copy_plan_costsize(plan, lefttree);
+
 	/*
-	 * Charge one cpu_operator_cost per comparison per input tuple.
-	 * We assume all columns get compared at most of the tuples.
+	 * Charge one cpu_operator_cost per comparison per input tuple. We
+	 * assume all columns get compared at most of the tuples.
 	 */
 	plan->total_cost += cpu_operator_cost * plan->plan_rows * numCols;
+
 	/*
 	 * As for Group, we make the unsupported assumption that there will be
 	 * 10% as many tuples out as in.
@@ -1388,14 +1416,17 @@ make_unique(List *tlist, Plan *lefttree, List *distinctList)
 	node->nonameid = _NONAME_RELATION_ID_;
 	node->keycount = 0;
 
-	/* convert SortClause list into array of attr indexes, as wanted by exec */
+	/*
+	 * convert SortClause list into array of attr indexes, as wanted by
+	 * exec
+	 */
 	Assert(numCols > 0);
 	uniqColIdx = (AttrNumber *) palloc(sizeof(AttrNumber) * numCols);
 
 	foreach(slitem, distinctList)
 	{
-		SortClause	   *sortcl = (SortClause *) lfirst(slitem);
-		TargetEntry	   *tle = get_sortgroupclause_tle(sortcl, tlist);
+		SortClause *sortcl = (SortClause *) lfirst(slitem);
+		TargetEntry *tle = get_sortgroupclause_tle(sortcl, tlist);
 
 		uniqColIdx[keyno++] = tle->resdom->resno;
 	}
diff --git a/src/backend/optimizer/plan/initsplan.c b/src/backend/optimizer/plan/initsplan.c
index 6b6f3971719d05b0eefec89cb022a6daa29c7998..207981b527f5265e10986a22cf57674912be5985 100644
--- a/src/backend/optimizer/plan/initsplan.c
+++ b/src/backend/optimizer/plan/initsplan.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.45 2000/02/15 20:49:18 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.46 2000/04/12 17:15:21 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -30,7 +30,7 @@
 
 static void add_restrict_and_join_to_rel(Query *root, Node *clause);
 static void add_join_info_to_rels(Query *root, RestrictInfo *restrictinfo,
-								  Relids join_relids);
+					  Relids join_relids);
 static void add_vars_to_targetlist(Query *root, List *vars);
 static void check_mergejoinable(RestrictInfo *restrictinfo);
 static void check_hashjoinable(RestrictInfo *restrictinfo);
@@ -83,7 +83,7 @@ add_vars_to_targetlist(Query *root, List *vars)
  *
  *	  If we have a range variable in the FROM clause that does not appear
  *	  in the target list nor qualifications, we must add it to the base
- *	  relation list so that it will be joined.  For instance, "select f.x
+ *	  relation list so that it will be joined.	For instance, "select f.x
  *	  from foo f, foo f2" is a join of f and f2.  Note that if we have
  *	  "select foo.x from foo f", it also gets turned into a join (between
  *	  foo as foo and foo as f).
@@ -106,13 +106,15 @@ add_missing_rels_to_query(Query *root)
 		{
 			RelOptInfo *rel = get_base_rel(root, varno);
 
-			/* If the rel isn't otherwise referenced, give it a dummy
+			/*
+			 * If the rel isn't otherwise referenced, give it a dummy
 			 * targetlist consisting of its own OID.
 			 */
 			if (rel->targetlist == NIL)
 			{
 				Var		   *var = makeVar(varno, ObjectIdAttributeNumber,
 										  OIDOID, -1, 0);
+
 				add_var_to_tlist(rel, var);
 			}
 		}
@@ -142,14 +144,14 @@ add_restrict_and_join_to_rels(Query *root, List *clauses)
 	List	   *clause;
 
 	foreach(clause, clauses)
-		add_restrict_and_join_to_rel(root, (Node*) lfirst(clause));
+		add_restrict_and_join_to_rel(root, (Node *) lfirst(clause));
 }
 
 /*
  * add_restrict_and_join_to_rel
  *	  Add clause information to either the 'RestrictInfo' or 'JoinInfo' field
  *	  (depending on whether the clause is a join) of each base relation
- *	  mentioned in the clause.  A RestrictInfo node is created and added to
+ *	  mentioned in the clause.	A RestrictInfo node is created and added to
  *	  the appropriate list for each rel.  Also, if the clause uses a
  *	  mergejoinable operator, enter the left- and right-side expressions
  *	  into the query's lists of equijoined vars.
@@ -175,6 +177,7 @@ add_restrict_and_join_to_rel(Query *root, Node *clause)
 
 	if (length(relids) == 1)
 	{
+
 		/*
 		 * There is only one relation participating in 'clause', so
 		 * 'clause' must be a restriction clause for that relation.
@@ -183,21 +186,24 @@ add_restrict_and_join_to_rel(Query *root, Node *clause)
 
 		rel->baserestrictinfo = lcons(restrictinfo,
 									  rel->baserestrictinfo);
+
 		/*
 		 * Check for a "mergejoinable" clause even though it's not a join
-		 * clause.  This is so that we can recognize that "a.x = a.y" makes
-		 * x and y eligible to be considered equal, even when they belong
-		 * to the same rel.  Without this, we would not recognize that
-		 * "a.x = a.y AND a.x = b.z AND a.y = c.q" allows us to consider
-		 * z and q equal after their rels are joined.
+		 * clause.	This is so that we can recognize that "a.x = a.y"
+		 * makes x and y eligible to be considered equal, even when they
+		 * belong to the same rel.	Without this, we would not recognize
+		 * that "a.x = a.y AND a.x = b.z AND a.y = c.q" allows us to
+		 * consider z and q equal after their rels are joined.
 		 */
 		check_mergejoinable(restrictinfo);
 	}
 	else
 	{
+
 		/*
 		 * 'clause' is a join clause, since there is more than one atom in
-		 * the relid list.  Set additional RestrictInfo fields for joining.
+		 * the relid list.	Set additional RestrictInfo fields for
+		 * joining.
 		 *
 		 * We need the merge info whether or not mergejoin is enabled (for
 		 * constructing equijoined-var lists), but we don't bother setting
@@ -206,16 +212,19 @@ add_restrict_and_join_to_rel(Query *root, Node *clause)
 		check_mergejoinable(restrictinfo);
 		if (enable_hashjoin)
 			check_hashjoinable(restrictinfo);
+
 		/*
-		 * Add clause to the join lists of all the relevant
-		 * relations.  (If, perchance, 'clause' contains NO vars, then
-		 * nothing will happen...)
+		 * Add clause to the join lists of all the relevant relations.
+		 * (If, perchance, 'clause' contains NO vars, then nothing will
+		 * happen...)
 		 */
 		add_join_info_to_rels(root, restrictinfo, relids);
+
 		/*
-		 * Add vars used in the join clause to targetlists of member relations,
-		 * so that they will be emitted by the plan nodes that scan those
-		 * relations (else they won't be available at the join node!).
+		 * Add vars used in the join clause to targetlists of member
+		 * relations, so that they will be emitted by the plan nodes that
+		 * scan those relations (else they won't be available at the join
+		 * node!).
 		 */
 		add_vars_to_targetlist(root, vars);
 	}
@@ -267,7 +276,7 @@ add_join_info_to_rels(Query *root, RestrictInfo *restrictinfo,
 		joininfo = find_joininfo_node(get_base_rel(root, cur_relid),
 									  unjoined_relids);
 		joininfo->jinfo_restrictinfo = lcons(restrictinfo,
-											 joininfo->jinfo_restrictinfo);
+										   joininfo->jinfo_restrictinfo);
 	}
 }
 
@@ -296,16 +305,16 @@ check_mergejoinable(RestrictInfo *restrictinfo)
 				leftOp,
 				rightOp;
 
-	if (! is_opclause((Node *) clause))
+	if (!is_opclause((Node *) clause))
 		return;
 
 	left = get_leftop(clause);
 	right = get_rightop(clause);
 
 	/* caution: is_opclause accepts more than I do, so check it */
-	if (! right)
+	if (!right)
 		return;					/* unary opclauses need not apply */
-	if (!IsA(left, Var) || !IsA(right, Var))
+	if (!IsA(left, Var) ||!IsA(right, Var))
 		return;
 
 	opno = ((Oper *) clause->oper)->opno;
@@ -339,16 +348,16 @@ check_hashjoinable(RestrictInfo *restrictinfo)
 			   *right;
 	Oid			opno;
 
-	if (! is_opclause((Node *) clause))
+	if (!is_opclause((Node *) clause))
 		return;
 
 	left = get_leftop(clause);
 	right = get_rightop(clause);
 
 	/* caution: is_opclause accepts more than I do, so check it */
-	if (! right)
+	if (!right)
 		return;					/* unary opclauses need not apply */
-	if (!IsA(left, Var) || !IsA(right, Var))
+	if (!IsA(left, Var) ||!IsA(right, Var))
 		return;
 
 	opno = ((Oper *) clause->oper)->opno;
@@ -356,7 +365,5 @@ check_hashjoinable(RestrictInfo *restrictinfo)
 	if (op_hashjoinable(opno,
 						left->vartype,
 						right->vartype))
-	{
 		restrictinfo->hashjoinoperator = opno;
-	}
 }
diff --git a/src/backend/optimizer/plan/planmain.c b/src/backend/optimizer/plan/planmain.c
index 4377359ddcc0ce50bbb73804cd15897d220be637..0e05c945380cdc6ded1f537355dde034869562dc 100644
--- a/src/backend/optimizer/plan/planmain.c
+++ b/src/backend/optimizer/plan/planmain.c
@@ -14,7 +14,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.54 2000/03/24 21:40:43 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.55 2000/04/12 17:15:22 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -31,7 +31,7 @@
 
 
 static Plan *subplanner(Query *root, List *flat_tlist, List *qual,
-						double tuple_fraction);
+		   double tuple_fraction);
 
 
 /*--------------------
@@ -55,12 +55,12 @@ static Plan *subplanner(Query *root, List *flat_tlist, List *qual,
  * Query field and not a passed parameter is that the low-level routines
  * in indxpath.c need to see it.)  The pathkeys value passed to query_planner
  * has not yet been "canonicalized", since the necessary info does not get
- * computed until subplanner() scans the qual clauses.  We canonicalize it
+ * computed until subplanner() scans the qual clauses.	We canonicalize it
  * inside subplanner() as soon as that task is done.  The output value
  * will be in canonical form as well.
  *
  * tuple_fraction is interpreted as follows:
- *    0 (or less): expect all tuples to be retrieved (normal case)
+ *	  0 (or less): expect all tuples to be retrieved (normal case)
  *	  0 < tuple_fraction < 1: expect the given fraction of tuples available
  *		from the plan to be retrieved
  *	  tuple_fraction >= 1: tuple_fraction is the absolute number of tuples
@@ -91,7 +91,7 @@ query_planner(Query *root,
 		if (root->commandType != CMD_SELECT)
 			elog(ERROR, "Empty range table for non-SELECT query");
 
-		root->query_pathkeys = NIL; /* signal unordered result */
+		root->query_pathkeys = NIL;		/* signal unordered result */
 
 		/* Make childless Result node to evaluate given tlist. */
 		return (Plan *) make_result(tlist, (Node *) qual, (Plan *) NULL);
@@ -115,8 +115,8 @@ query_planner(Query *root,
 	 *
 	 * All subplan nodes will have "flat" (var-only) tlists.
 	 *
-	 * This implies that all expression evaluations are done at the root
-	 * of the plan tree.  Once upon a time there was code to try to push
+	 * This implies that all expression evaluations are done at the root of
+	 * the plan tree.  Once upon a time there was code to try to push
 	 * expensive function calls down to lower plan nodes, but that's dead
 	 * code and has been for a long time...
 	 */
@@ -132,9 +132,10 @@ query_planner(Query *root,
 	 */
 	if (constant_qual)
 	{
+
 		/*
-		 * The result node will also be responsible for evaluating
-		 * the originally requested tlist.
+		 * The result node will also be responsible for evaluating the
+		 * originally requested tlist.
 		 */
 		subplan = (Plan *) make_result(tlist,
 									   (Node *) constant_qual,
@@ -142,9 +143,11 @@ query_planner(Query *root,
 	}
 	else
 	{
+
 		/*
 		 * Replace the toplevel plan node's flattened target list with the
-		 * targetlist given by my caller, so that expressions are evaluated.
+		 * targetlist given by my caller, so that expressions are
+		 * evaluated.
 		 */
 		subplan->targetlist = tlist;
 	}
@@ -180,8 +183,9 @@ subplanner(Query *root,
 	 * Initialize the targetlist and qualification, adding entries to
 	 * base_rel_list as relation references are found (e.g., in the
 	 * qualification, the targetlist, etc.).  Restrict and join clauses
-	 * are added to appropriate lists belonging to the mentioned relations,
-	 * and we also build lists of equijoined keys for pathkey construction.
+	 * are added to appropriate lists belonging to the mentioned
+	 * relations, and we also build lists of equijoined keys for pathkey
+	 * construction.
 	 */
 	root->base_rel_list = NIL;
 	root->join_rel_list = NIL;
@@ -192,9 +196,9 @@ subplanner(Query *root,
 	add_missing_rels_to_query(root);
 
 	/*
-	 * We should now have all the pathkey equivalence sets built,
-	 * so it's now possible to convert the requested query_pathkeys
-	 * to canonical form.
+	 * We should now have all the pathkey equivalence sets built, so it's
+	 * now possible to convert the requested query_pathkeys to canonical
+	 * form.
 	 */
 	root->query_pathkeys = canonicalize_pathkeys(root, root->query_pathkeys);
 
@@ -203,20 +207,22 @@ subplanner(Query *root,
 	 */
 	final_rel = make_one_rel(root);
 
-	if (! final_rel)
+	if (!final_rel)
 	{
+
 		/*
 		 * We expect to end up here for a trivial INSERT ... VALUES query
-		 * (which will have a target relation, so it gets past query_planner's
-		 * check for empty range table; but the target rel is unreferenced
-		 * and not marked inJoinSet, so we find there is nothing to join).
-		 * 
+		 * (which will have a target relation, so it gets past
+		 * query_planner's check for empty range table; but the target rel
+		 * is unreferenced and not marked inJoinSet, so we find there is
+		 * nothing to join).
+		 *
 		 * It's also possible to get here if the query was rewritten by the
-		 * rule processor (creating rangetable entries not marked inJoinSet)
-		 * but the rules either did nothing or were simplified to nothing
-		 * by constant-expression folding.  So, don't complain.
+		 * rule processor (creating rangetable entries not marked
+		 * inJoinSet) but the rules either did nothing or were simplified
+		 * to nothing by constant-expression folding.  So, don't complain.
 		 */
-		root->query_pathkeys = NIL; /* signal unordered result */
+		root->query_pathkeys = NIL;		/* signal unordered result */
 
 		/* Make childless Result node to evaluate given tlist. */
 		return (Plan *) make_result(flat_tlist, (Node *) qual, (Plan *) NULL);
@@ -246,16 +252,16 @@ subplanner(Query *root,
 #endif
 
 	/*
-	 * Now that we have an estimate of the final rel's size, we can convert
-	 * a tuple_fraction specified as an absolute count (ie, a LIMIT option)
-	 * into a fraction of the total tuples.
+	 * Now that we have an estimate of the final rel's size, we can
+	 * convert a tuple_fraction specified as an absolute count (ie, a
+	 * LIMIT option) into a fraction of the total tuples.
 	 */
 	if (tuple_fraction >= 1.0)
 		tuple_fraction /= final_rel->rows;
 
 	/*
 	 * Determine the cheapest path, independently of any ordering
-	 * considerations.  We do, however, take into account whether the
+	 * considerations.	We do, however, take into account whether the
 	 * whole plan is expected to be evaluated or not.
 	 */
 	if (tuple_fraction <= 0.0 || tuple_fraction >= 1.0)
@@ -271,8 +277,8 @@ subplanner(Query *root,
 	/*
 	 * Select the best path and create a subplan to execute it.
 	 *
-	 * If no special sort order is wanted, or if the cheapest path is
-	 * already appropriately ordered, we use the cheapest path found above.
+	 * If no special sort order is wanted, or if the cheapest path is already
+	 * appropriately ordered, we use the cheapest path found above.
 	 */
 	if (root->query_pathkeys == NIL ||
 		pathkeys_contained_in(root->query_pathkeys,
@@ -284,7 +290,8 @@ subplanner(Query *root,
 
 	/*
 	 * Otherwise, look to see if we have an already-ordered path that is
-	 * cheaper than doing an explicit sort on the cheapest-total-cost path.
+	 * cheaper than doing an explicit sort on the cheapest-total-cost
+	 * path.
 	 */
 	cheapestpath = final_rel->cheapest_total_path;
 	presortedpath =
@@ -310,11 +317,11 @@ subplanner(Query *root,
 	}
 
 	/*
-	 * Nothing for it but to sort the cheapest-total-cost path --- but we let
-	 * the caller do that.  union_planner has to be able to add a sort node
-	 * anyway, so no need for extra code here.  (Furthermore, the given
-	 * pathkeys might involve something we can't compute here, such as an
-	 * aggregate function...)
+	 * Nothing for it but to sort the cheapest-total-cost path --- but we
+	 * let the caller do that.	union_planner has to be able to add a sort
+	 * node anyway, so no need for extra code here.  (Furthermore, the
+	 * given pathkeys might involve something we can't compute here, such
+	 * as an aggregate function...)
 	 */
 	root->query_pathkeys = cheapestpath->pathkeys;
 	return create_plan(root, cheapestpath);
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index b8871d5801e35c0c69e92c67a8768cc0bdb0408e..a92d439ee52a6ac93c5878a956d425611c431708 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.78 2000/03/21 05:12:01 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.79 2000/04/12 17:15:22 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -38,10 +38,10 @@
 
 
 static List *make_subplanTargetList(Query *parse, List *tlist,
-									AttrNumber **groupColIdx);
+					   AttrNumber **groupColIdx);
 static Plan *make_groupplan(List *group_tlist, bool tuplePerGroup,
-							List *groupClause, AttrNumber *grpColIdx,
-							bool is_presorted, Plan *subplan);
+			   List *groupClause, AttrNumber *grpColIdx,
+			   bool is_presorted, Plan *subplan);
 static Plan *make_sortplan(List *tlist, List *sortcls, Plan *plannode);
 
 /*****************************************************************************
@@ -64,7 +64,7 @@ planner(Query *parse)
 	transformKeySetQuery(parse);
 
 	/* primary planning entry point (may recurse for subplans) */
-	result_plan = subquery_planner(parse, -1.0 /* default case */);
+	result_plan = subquery_planner(parse, -1.0 /* default case */ );
 
 	Assert(PlannerQueryLevel == 1);
 
@@ -110,21 +110,22 @@ planner(Query *parse)
 Plan *
 subquery_planner(Query *parse, double tuple_fraction)
 {
+
 	/*
 	 * A HAVING clause without aggregates is equivalent to a WHERE clause
-	 * (except it can only refer to grouped fields).  If there are no
-	 * aggs anywhere in the query, then we don't want to create an Agg
-	 * plan node, so merge the HAVING condition into WHERE.  (We used to
+	 * (except it can only refer to grouped fields).  If there are no aggs
+	 * anywhere in the query, then we don't want to create an Agg plan
+	 * node, so merge the HAVING condition into WHERE.	(We used to
 	 * consider this an error condition, but it seems to be legal SQL.)
 	 */
-	if (parse->havingQual != NULL && ! parse->hasAggs)
+	if (parse->havingQual != NULL && !parse->hasAggs)
 	{
 		if (parse->qual == NULL)
 			parse->qual = parse->havingQual;
 		else
 			parse->qual = (Node *) make_andclause(lappend(lcons(parse->qual,
 																NIL),
-														  parse->havingQual));
+													 parse->havingQual));
 		parse->havingQual = NULL;
 	}
 
@@ -144,8 +145,8 @@ subquery_planner(Query *parse, double tuple_fraction)
 	/*
 	 * Canonicalize the qual, and convert it to implicit-AND format.
 	 *
-	 * XXX Is there any value in re-applying eval_const_expressions
-	 * after canonicalize_qual?
+	 * XXX Is there any value in re-applying eval_const_expressions after
+	 * canonicalize_qual?
 	 */
 	parse->qual = (Node *) canonicalize_qual((Expr *) parse->qual, true);
 #ifdef OPTIMIZER_DEBUG
@@ -169,15 +170,17 @@ subquery_planner(Query *parse, double tuple_fraction)
 
 		if (parse->groupClause != NIL)
 		{
+
 			/*
-			 * Check for ungrouped variables passed to subplans.
-			 * Note we do NOT do this for subplans in WHERE; it's legal
-			 * there because WHERE is evaluated pre-GROUP.
+			 * Check for ungrouped variables passed to subplans. Note we
+			 * do NOT do this for subplans in WHERE; it's legal there
+			 * because WHERE is evaluated pre-GROUP.
 			 *
-			 * An interesting fine point: if we reassigned a HAVING qual
-			 * into WHERE above, then we will accept references to ungrouped
-			 * vars from subplans in the HAVING qual.  This is not entirely
-			 * consistent, but it doesn't seem particularly harmful...
+			 * An interesting fine point: if we reassigned a HAVING qual into
+			 * WHERE above, then we will accept references to ungrouped
+			 * vars from subplans in the HAVING qual.  This is not
+			 * entirely consistent, but it doesn't seem particularly
+			 * harmful...
 			 */
 			check_subplans_for_ungrouped_vars((Node *) parse->targetList,
 											  parse);
@@ -218,8 +221,8 @@ subquery_planner(Query *parse, double tuple_fraction)
  * tuple_fraction is the fraction of tuples we expect will be retrieved
  *
  * tuple_fraction is interpreted as follows:
- *    < 0: determine fraction by inspection of query (normal case)
- *    0: expect all tuples to be retrieved
+ *	  < 0: determine fraction by inspection of query (normal case)
+ *	  0: expect all tuples to be retrieved
  *	  0 < tuple_fraction < 1: expect the given fraction of tuples available
  *		from the plan to be retrieved
  *	  tuple_fraction >= 1: tuple_fraction is the absolute number of tuples
@@ -251,13 +254,18 @@ union_planner(Query *parse,
 									  parse->commandType,
 									  parse->resultRelation,
 									  parse->rtable);
+
 		/*
-		 * We leave current_pathkeys NIL indicating we do not know sort order.
-		 * Actually, for a normal UNION we have done an explicit sort; ought
-		 * to change interface to plan_union_queries to pass that info back!
+		 * We leave current_pathkeys NIL indicating we do not know sort
+		 * order. Actually, for a normal UNION we have done an explicit
+		 * sort; ought to change interface to plan_union_queries to pass
+		 * that info back!
 		 */
 
-		/* Calculate pathkeys that represent grouping/ordering requirements */
+		/*
+		 * Calculate pathkeys that represent grouping/ordering
+		 * requirements
+		 */
 		group_pathkeys = make_pathkeys_for_sortclauses(parse->groupClause,
 													   tlist);
 		sort_pathkeys = make_pathkeys_for_sortclauses(parse->sortClause,
@@ -280,13 +288,13 @@ union_planner(Query *parse,
 													rt_index);
 
 		/*
-		 * Fix up outer target list.  NOTE: unlike the case for non-inherited
-		 * query, we pass the unfixed tlist to subplans, which do their own
-		 * fixing.  But we still want to fix the outer target list afterwards.
-		 * I *think* this is correct --- doing the fix before recursing is
-		 * definitely wrong, because preprocess_targetlist() will do the
-		 * wrong thing if invoked twice on the same list. Maybe that is a bug?
-		 * tgl 6/6/99
+		 * Fix up outer target list.  NOTE: unlike the case for
+		 * non-inherited query, we pass the unfixed tlist to subplans,
+		 * which do their own fixing.  But we still want to fix the outer
+		 * target list afterwards. I *think* this is correct --- doing the
+		 * fix before recursing is definitely wrong, because
+		 * preprocess_targetlist() will do the wrong thing if invoked
+		 * twice on the same list. Maybe that is a bug? tgl 6/6/99
 		 */
 		tlist = preprocess_targetlist(tlist,
 									  parse->commandType,
@@ -295,12 +303,16 @@ union_planner(Query *parse,
 
 		if (parse->rowMark != NULL)
 			elog(ERROR, "SELECT FOR UPDATE is not supported for inherit queries");
+
 		/*
-		 * We leave current_pathkeys NIL indicating we do not know sort order
-		 * of the Append-ed results.
+		 * We leave current_pathkeys NIL indicating we do not know sort
+		 * order of the Append-ed results.
 		 */
 
-		/* Calculate pathkeys that represent grouping/ordering requirements */
+		/*
+		 * Calculate pathkeys that represent grouping/ordering
+		 * requirements
+		 */
 		group_pathkeys = make_pathkeys_for_sortclauses(parse->groupClause,
 													   tlist);
 		sort_pathkeys = make_pathkeys_for_sortclauses(parse->sortClause,
@@ -358,7 +370,10 @@ union_planner(Query *parse,
 		 */
 		sub_tlist = make_subplanTargetList(parse, tlist, &groupColIdx);
 
-		/* Calculate pathkeys that represent grouping/ordering requirements */
+		/*
+		 * Calculate pathkeys that represent grouping/ordering
+		 * requirements
+		 */
 		group_pathkeys = make_pathkeys_for_sortclauses(parse->groupClause,
 													   tlist);
 		sort_pathkeys = make_pathkeys_for_sortclauses(parse->sortClause,
@@ -368,11 +383,12 @@ union_planner(Query *parse,
 		 * Figure out whether we need a sorted result from query_planner.
 		 *
 		 * If we have a GROUP BY clause, then we want a result sorted
-		 * properly for grouping.  Otherwise, if there is an ORDER BY clause,
-		 * we want to sort by the ORDER BY clause.  (Note: if we have both,
-		 * and ORDER BY is a superset of GROUP BY, it would be tempting to
-		 * request sort by ORDER BY --- but that might just leave us failing
-		 * to exploit an available sort order at all.  Needs more thought...)
+		 * properly for grouping.  Otherwise, if there is an ORDER BY
+		 * clause, we want to sort by the ORDER BY clause.	(Note: if we
+		 * have both, and ORDER BY is a superset of GROUP BY, it would be
+		 * tempting to request sort by ORDER BY --- but that might just
+		 * leave us failing to exploit an available sort order at all.
+		 * Needs more thought...)
 		 */
 		if (parse->groupClause)
 			parse->query_pathkeys = group_pathkeys;
@@ -382,15 +398,16 @@ union_planner(Query *parse,
 			parse->query_pathkeys = NIL;
 
 		/*
-		 * Figure out whether we expect to retrieve all the tuples that the
-		 * plan can generate, or to stop early due to a LIMIT or other
-		 * factors.  If the caller passed a value >= 0, believe that value,
-		 * else do our own examination of the query context.
+		 * Figure out whether we expect to retrieve all the tuples that
+		 * the plan can generate, or to stop early due to a LIMIT or other
+		 * factors.  If the caller passed a value >= 0, believe that
+		 * value, else do our own examination of the query context.
 		 */
 		if (tuple_fraction < 0.0)
 		{
 			/* Initial assumption is we need all the tuples */
 			tuple_fraction = 0.0;
+
 			/*
 			 * Check for a LIMIT clause.
 			 */
@@ -430,33 +447,37 @@ union_planner(Query *parse,
 				}
 				else
 				{
+
 					/*
-					 * COUNT is a PARAM ... don't know exactly what the limit
-					 * will be, but for lack of a better idea assume 10%
-					 * of the plan's result is wanted.
+					 * COUNT is a PARAM ... don't know exactly what the
+					 * limit will be, but for lack of a better idea assume
+					 * 10% of the plan's result is wanted.
 					 */
 					tuple_fraction = 0.10;
 				}
 			}
+
 			/*
 			 * Check for a retrieve-into-portal, ie DECLARE CURSOR.
 			 *
 			 * We have no real idea how many tuples the user will ultimately
-			 * FETCH from a cursor, but it seems a good bet that he doesn't
-			 * want 'em all.  Optimize for 10% retrieval (you gotta better
-			 * number?)
+			 * FETCH from a cursor, but it seems a good bet that he
+			 * doesn't want 'em all.  Optimize for 10% retrieval (you
+			 * gotta better number?)
 			 */
 			if (parse->isPortal)
 				tuple_fraction = 0.10;
 		}
+
 		/*
 		 * Adjust tuple_fraction if we see that we are going to apply
 		 * grouping/aggregation/etc.  This is not overridable by the
-		 * caller, since it reflects plan actions that this routine
-		 * will certainly take, not assumptions about context.
+		 * caller, since it reflects plan actions that this routine will
+		 * certainly take, not assumptions about context.
 		 */
 		if (parse->groupClause)
 		{
+
 			/*
 			 * In GROUP BY mode, we have the little problem that we don't
 			 * really know how many input tuples will be needed to make a
@@ -464,33 +485,42 @@ union_planner(Query *parse,
 			 * input count.  For lack of a better idea, assume 25% of the
 			 * input data will be processed if there is any output limit.
 			 * However, if the caller gave us a fraction rather than an
-			 * absolute count, we can keep using that fraction (which amounts
-			 * to assuming that all the groups are about the same size).
+			 * absolute count, we can keep using that fraction (which
+			 * amounts to assuming that all the groups are about the same
+			 * size).
 			 */
 			if (tuple_fraction >= 1.0)
 				tuple_fraction = 0.25;
+
 			/*
 			 * If both GROUP BY and ORDER BY are specified, we will need
 			 * two levels of sort --- and, therefore, certainly need to
 			 * read all the input tuples --- unless ORDER BY is a subset
 			 * of GROUP BY.  (Although we are comparing non-canonicalized
 			 * pathkeys here, it should be OK since they will both contain
-			 * only single-element sublists at this point.  See pathkeys.c.)
+			 * only single-element sublists at this point.	See
+			 * pathkeys.c.)
 			 */
 			if (parse->groupClause && parse->sortClause &&
-				! pathkeys_contained_in(sort_pathkeys, group_pathkeys))
+				!pathkeys_contained_in(sort_pathkeys, group_pathkeys))
 				tuple_fraction = 0.0;
 		}
 		else if (parse->hasAggs)
 		{
-			/* Ungrouped aggregate will certainly want all the input tuples. */
+
+			/*
+			 * Ungrouped aggregate will certainly want all the input
+			 * tuples.
+			 */
 			tuple_fraction = 0.0;
 		}
 		else if (parse->distinctClause)
 		{
+
 			/*
 			 * SELECT DISTINCT, like GROUP, will absorb an unpredictable
-			 * number of input tuples per output tuple.  Handle the same way.
+			 * number of input tuples per output tuple.  Handle the same
+			 * way.
 			 */
 			if (tuple_fraction >= 1.0)
 				tuple_fraction = 0.25;
@@ -502,14 +532,15 @@ union_planner(Query *parse,
 									(List *) parse->qual,
 									tuple_fraction);
 
-		/* query_planner returns actual sort order (which is not
+		/*
+		 * query_planner returns actual sort order (which is not
 		 * necessarily what we requested) in query_pathkeys.
 		 */
 		current_pathkeys = parse->query_pathkeys;
 	}
 
 	/* query_planner returns NULL if it thinks plan is bogus */
-	if (! result_plan)
+	if (!result_plan)
 		elog(ERROR, "union_planner: failed to create plan");
 
 	/*
@@ -539,9 +570,9 @@ union_planner(Query *parse,
 
 		/*
 		 * If there are aggregates then the Group node should just return
-		 * the same set of vars as the subplan did (but we can exclude
-		 * any GROUP BY expressions).  If there are no aggregates
-		 * then the Group node had better compute the final tlist.
+		 * the same set of vars as the subplan did (but we can exclude any
+		 * GROUP BY expressions).  If there are no aggregates then the
+		 * Group node had better compute the final tlist.
 		 */
 		if (parse->hasAggs)
 			group_tlist = flatten_tlist(result_plan->targetlist);
@@ -549,8 +580,8 @@ union_planner(Query *parse,
 			group_tlist = tlist;
 
 		/*
-		 * Figure out whether the path result is already ordered the way we
-		 * need it --- if so, no need for an explicit sort step.
+		 * Figure out whether the path result is already ordered the way
+		 * we need it --- if so, no need for an explicit sort step.
 		 */
 		if (pathkeys_contained_in(group_pathkeys, current_pathkeys))
 		{
@@ -559,7 +590,9 @@ union_planner(Query *parse,
 		}
 		else
 		{
-			/* We will need to do an explicit sort by the GROUP BY clause.
+
+			/*
+			 * We will need to do an explicit sort by the GROUP BY clause.
 			 * make_groupplan will do the work, but set current_pathkeys
 			 * to indicate the resulting order.
 			 */
@@ -594,10 +627,8 @@ union_planner(Query *parse,
 	 */
 	if (parse->sortClause)
 	{
-		if (! pathkeys_contained_in(sort_pathkeys, current_pathkeys))
-		{
+		if (!pathkeys_contained_in(sort_pathkeys, current_pathkeys))
 			result_plan = make_sortplan(tlist, parse->sortClause, result_plan);
-		}
 	}
 
 	/*
@@ -633,7 +664,7 @@ union_planner(Query *parse,
  * we want to pass this targetlist to the subplan:
  *		a,b,c,d,a+b
  * where the a+b target will be used by the Sort/Group steps, and the
- * other targets will be used for computing the final results.  (In the
+ * other targets will be used for computing the final results.	(In the
  * above example we could theoretically suppress the a and b targets and
  * use only a+b, but it's not really worth the trouble.)
  *
@@ -675,8 +706,9 @@ make_subplanTargetList(Query *parse,
 
 	/*
 	 * If grouping, create sub_tlist entries for all GROUP BY expressions
-	 * (GROUP BY items that are simple Vars should be in the list already),
-	 * and make an array showing where the group columns are in the sub_tlist.
+	 * (GROUP BY items that are simple Vars should be in the list
+	 * already), and make an array showing where the group columns are in
+	 * the sub_tlist.
 	 */
 	numCols = length(parse->groupClause);
 	if (numCols > 0)
@@ -690,10 +722,10 @@ make_subplanTargetList(Query *parse,
 
 		foreach(gl, parse->groupClause)
 		{
-			GroupClause	   *grpcl = (GroupClause *) lfirst(gl);
-			Node		   *groupexpr = get_sortgroupclause_expr(grpcl, tlist);
-			TargetEntry	   *te = NULL;
-			List		   *sl;
+			GroupClause *grpcl = (GroupClause *) lfirst(gl);
+			Node	   *groupexpr = get_sortgroupclause_expr(grpcl, tlist);
+			TargetEntry *te = NULL;
+			List	   *sl;
 
 			/* Find or make a matching sub_tlist entry */
 			foreach(sl, sub_tlist)
@@ -702,7 +734,7 @@ make_subplanTargetList(Query *parse,
 				if (equal(groupexpr, te->expr))
 					break;
 			}
-			if (! sl)
+			if (!sl)
 			{
 				te = makeTargetEntry(makeResdom(length(sub_tlist) + 1,
 												exprType(groupexpr),
@@ -739,8 +771,9 @@ make_groupplan(List *group_tlist,
 {
 	int			numCols = length(groupClause);
 
-	if (! is_presorted)
+	if (!is_presorted)
 	{
+
 		/*
 		 * The Sort node always just takes a copy of the subplan's tlist
 		 * plus ordering information.  (This might seem inefficient if the
@@ -755,14 +788,14 @@ make_groupplan(List *group_tlist,
 
 		foreach(gl, groupClause)
 		{
-			GroupClause	   *grpcl = (GroupClause *) lfirst(gl);
-			TargetEntry	   *te = nth(grpColIdx[keyno]-1, sort_tlist);
-			Resdom		   *resdom = te->resdom;
+			GroupClause *grpcl = (GroupClause *) lfirst(gl);
+			TargetEntry *te = nth(grpColIdx[keyno] - 1, sort_tlist);
+			Resdom	   *resdom = te->resdom;
 
 			/*
-			 * Check for the possibility of duplicate group-by clauses --- the
-			 * parser should have removed 'em, but the Sort executor will get
-			 * terribly confused if any get through!
+			 * Check for the possibility of duplicate group-by clauses ---
+			 * the parser should have removed 'em, but the Sort executor
+			 * will get terribly confused if any get through!
 			 */
 			if (resdom->reskey == 0)
 			{
@@ -808,8 +841,8 @@ make_sortplan(List *tlist, List *sortcls, Plan *plannode)
 
 		/*
 		 * Check for the possibility of duplicate order-by clauses --- the
-		 * parser should have removed 'em, but the executor will get terribly
-		 * confused if any get through!
+		 * parser should have removed 'em, but the executor will get
+		 * terribly confused if any get through!
 		 */
 		if (resdom->reskey == 0)
 		{
diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c
index 756333e005957ce4d1c96822a17766a8a956c448..a72fa0e74f00f578baa9e5d5e1fdff619ff7ebe2 100644
--- a/src/backend/optimizer/plan/setrefs.c
+++ b/src/backend/optimizer/plan/setrefs.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.61 2000/04/04 01:21:47 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.62 2000/04/12 17:15:22 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -24,13 +24,15 @@
 #include "optimizer/tlist.h"
 #include "optimizer/var.h"
 
-typedef struct {
+typedef struct
+{
 	List	   *outer_tlist;
 	List	   *inner_tlist;
 	Index		acceptable_rel;
 } join_references_context;
 
-typedef struct {
+typedef struct
+{
 	Index		subvarno;
 	List	   *subplanTargetList;
 } replace_vars_with_subplan_refs_context;
@@ -38,12 +40,12 @@ typedef struct {
 static void set_join_references(Join *join);
 static void set_uppernode_references(Plan *plan, Index subvarno);
 static Node *join_references_mutator(Node *node,
-									 join_references_context *context);
+						join_references_context *context);
 static Node *replace_vars_with_subplan_refs(Node *node,
-											Index subvarno,
-											List *subplanTargetList);
+							   Index subvarno,
+							   List *subplanTargetList);
 static Node *replace_vars_with_subplan_refs_mutator(Node *node,
-					replace_vars_with_subplan_refs_context *context);
+						replace_vars_with_subplan_refs_context *context);
 static bool fix_opids_walker(Node *node, void *context);
 
 /*****************************************************************************
@@ -56,7 +58,7 @@ static bool fix_opids_walker(Node *node, void *context);
  * set_plan_references
  *	  This is the final processing pass of the planner/optimizer.  The plan
  *	  tree is complete; we just have to adjust some representational details
- *	  for the convenience of the executor.  We update Vars in upper plan nodes
+ *	  for the convenience of the executor.	We update Vars in upper plan nodes
  *	  to refer to the outputs of their subplans, and we compute regproc OIDs
  *	  for operators (ie, we look up the function that implements each op).
  *	  We must also build lists of all the subplan nodes present in each
@@ -74,7 +76,8 @@ set_plan_references(Plan *plan)
 	if (plan == NULL)
 		return;
 
-	/* We must rebuild the plan's list of subplan nodes, since we are
+	/*
+	 * We must rebuild the plan's list of subplan nodes, since we are
 	 * copying/mutating its expression trees.
 	 */
 	plan->subPlan = NIL;
@@ -92,10 +95,10 @@ set_plan_references(Plan *plan)
 			fix_opids((Node *) ((IndexScan *) plan)->indxqualorig);
 			plan->subPlan =
 				nconc(plan->subPlan,
-					  pull_subplans((Node *) ((IndexScan *) plan)->indxqual));
+				 pull_subplans((Node *) ((IndexScan *) plan)->indxqual));
 			plan->subPlan =
 				nconc(plan->subPlan,
-					  pull_subplans((Node *) ((IndexScan *) plan)->indxqualorig));
+			 pull_subplans((Node *) ((IndexScan *) plan)->indxqualorig));
 			break;
 		case T_NestLoop:
 			set_join_references((Join *) plan);
@@ -105,24 +108,26 @@ set_plan_references(Plan *plan)
 			fix_opids((Node *) ((MergeJoin *) plan)->mergeclauses);
 			plan->subPlan =
 				nconc(plan->subPlan,
-					  pull_subplans((Node *) ((MergeJoin *) plan)->mergeclauses));
+			 pull_subplans((Node *) ((MergeJoin *) plan)->mergeclauses));
 			break;
 		case T_HashJoin:
 			set_join_references((Join *) plan);
 			fix_opids((Node *) ((HashJoin *) plan)->hashclauses);
 			plan->subPlan =
 				nconc(plan->subPlan,
-					  pull_subplans((Node *) ((HashJoin *) plan)->hashclauses));
+			   pull_subplans((Node *) ((HashJoin *) plan)->hashclauses));
 			break;
 		case T_Material:
 		case T_Sort:
 		case T_Unique:
 		case T_Hash:
-			/* These plan types don't actually bother to evaluate their
+
+			/*
+			 * These plan types don't actually bother to evaluate their
 			 * targetlists or quals (because they just return their
 			 * unmodified input tuples).  The optimizer is lazy about
-			 * creating really valid targetlists for them.  Best to
-			 * just leave the targetlist alone.
+			 * creating really valid targetlists for them.	Best to just
+			 * leave the targetlist alone.
 			 */
 			break;
 		case T_Agg:
@@ -130,7 +135,9 @@ set_plan_references(Plan *plan)
 			set_uppernode_references(plan, (Index) 0);
 			break;
 		case T_Result:
-			/* Result may or may not have a subplan; no need to fix up
+
+			/*
+			 * Result may or may not have a subplan; no need to fix up
 			 * subplan references if it hasn't got one...
 			 *
 			 * XXX why does Result use a different subvarno from Agg/Group?
@@ -144,9 +151,7 @@ set_plan_references(Plan *plan)
 			break;
 		case T_Append:
 			foreach(pl, ((Append *) plan)->appendplans)
-			{
 				set_plan_references((Plan *) lfirst(pl));
-			}
 			break;
 		case T_TidScan:
 			/* nothing special */
@@ -158,8 +163,8 @@ set_plan_references(Plan *plan)
 	}
 
 	/*
-	 * For all plan types, fix operators in targetlist and qual expressions,
-	 * and find subplans therein.
+	 * For all plan types, fix operators in targetlist and qual
+	 * expressions, and find subplans therein.
 	 */
 	fix_opids((Node *) plan->targetlist);
 	fix_opids((Node *) plan->qual);
@@ -176,20 +181,21 @@ set_plan_references(Plan *plan)
 	 * NOTE: it is essential that we recurse into subplans AFTER we set
 	 * subplan references in this plan's tlist and quals.  If we did the
 	 * reference-adjustments bottom-up, then we would fail to match this
-	 * plan's var nodes against the already-modified nodes of the subplans.
+	 * plan's var nodes against the already-modified nodes of the
+	 * subplans.
 	 */
 	set_plan_references(plan->lefttree);
 	set_plan_references(plan->righttree);
 	foreach(pl, plan->initPlan)
 	{
-		SubPlan	   *sp = (SubPlan *) lfirst(pl);
+		SubPlan    *sp = (SubPlan *) lfirst(pl);
 
 		Assert(IsA(sp, SubPlan));
 		set_plan_references(sp->plan);
 	}
 	foreach(pl, plan->subPlan)
 	{
-		SubPlan	   *sp = (SubPlan *) lfirst(pl);
+		SubPlan    *sp = (SubPlan *) lfirst(pl);
 
 		Assert(IsA(sp, SubPlan));
 		set_plan_references(sp->plan);
@@ -325,9 +331,10 @@ join_references_mutator(Node *node,
 			newvar->varattno = resdom->resno;
 			return (Node *) newvar;
 		}
+
 		/*
-		 * Var not in either tlist --- either raise an error,
-		 * or return the Var unmodified.
+		 * Var not in either tlist --- either raise an error, or return
+		 * the Var unmodified.
 		 */
 		if (var->varno != context->acceptable_rel)
 			elog(ERROR, "join_references: variable not in subplan target lists");
@@ -370,7 +377,7 @@ replace_vars_with_subplan_refs(Node *node,
 
 static Node *
 replace_vars_with_subplan_refs_mutator(Node *node,
-							 replace_vars_with_subplan_refs_context *context)
+						 replace_vars_with_subplan_refs_context *context)
 {
 	if (node == NULL)
 		return NULL;
@@ -414,7 +421,7 @@ fix_opids(Node *node)
 }
 
 static bool
-fix_opids_walker (Node *node, void *context)
+fix_opids_walker(Node *node, void *context)
 {
 	if (node == NULL)
 		return false;
diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c
index b77d8b586f60a95bfe31946a9597559b27ffadf3..3493bfda24569bd2339821f758cbff49004dc11f 100644
--- a/src/backend/optimizer/plan/subselect.c
+++ b/src/backend/optimizer/plan/subselect.c
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.34 2000/04/04 01:21:47 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.35 2000/04/12 17:15:22 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -82,19 +82,19 @@ replace_var(Var *var)
 	varlevel = PlannerQueryLevel - var->varlevelsup;
 
 	/*
-	 * If there's already a PlannerParamVar entry for this same Var,
-	 * just use it.  NOTE: in situations involving UNION or inheritance,
-	 * it is possible for the same varno/varlevel to refer to different RTEs
-	 * in different parts of the parsetree, so that different fields might
-	 * end up sharing the same Param number.  As long as we check the vartype
-	 * as well, I believe that this sort of aliasing will cause no trouble.
-	 * The correct field should get stored into the Param slot at execution
-	 * in each part of the tree.
+	 * If there's already a PlannerParamVar entry for this same Var, just
+	 * use it.	NOTE: in situations involving UNION or inheritance, it is
+	 * possible for the same varno/varlevel to refer to different RTEs in
+	 * different parts of the parsetree, so that different fields might
+	 * end up sharing the same Param number.  As long as we check the
+	 * vartype as well, I believe that this sort of aliasing will cause no
+	 * trouble. The correct field should get stored into the Param slot at
+	 * execution in each part of the tree.
 	 */
 	i = 0;
 	foreach(ppv, PlannerParamVar)
 	{
-		Var	   *pvar = lfirst(ppv);
+		Var		   *pvar = lfirst(ppv);
 
 		if (pvar->varno == var->varno &&
 			pvar->varattno == var->varattno &&
@@ -104,7 +104,7 @@ replace_var(Var *var)
 		i++;
 	}
 
-	if (! ppv)
+	if (!ppv)
 	{
 		/* Nope, so make a new one */
 		i = new_param(var, varlevel);
@@ -137,23 +137,25 @@ make_subplan(SubLink *slink)
 	PlannerQueryLevel++;		/* we become child */
 
 	/*
-	 * For an EXISTS subplan, tell lower-level planner to expect that
-	 * only the first tuple will be retrieved.  For ALL and ANY subplans,
-	 * we will be able to stop evaluating if the test condition fails,
-	 * so very often not all the tuples will be retrieved; for lack of a
-	 * better idea, specify 50% retrieval.  For EXPR and MULTIEXPR subplans,
-	 * use default behavior (we're only expecting one row out, anyway).
+	 * For an EXISTS subplan, tell lower-level planner to expect that only
+	 * the first tuple will be retrieved.  For ALL and ANY subplans, we
+	 * will be able to stop evaluating if the test condition fails, so
+	 * very often not all the tuples will be retrieved; for lack of a
+	 * better idea, specify 50% retrieval.	For EXPR and MULTIEXPR
+	 * subplans, use default behavior (we're only expecting one row out,
+	 * anyway).
 	 *
 	 * NOTE: if you change these numbers, also change cost_qual_eval_walker()
 	 * in path/costsize.c.
 	 *
-	 * XXX If an ALL/ANY subplan is uncorrelated, we may decide to materialize
-	 * its result below.  In that case it would've been better to specify
-	 * full retrieval.  At present, however, we can only detect correlation
-	 * or lack of it after we've made the subplan :-(.  Perhaps detection
-	 * of correlation should be done as a separate step.  Meanwhile, we don't
-	 * want to be too optimistic about the percentage of tuples retrieved,
-	 * for fear of selecting a plan that's bad for the materialization case.
+	 * XXX If an ALL/ANY subplan is uncorrelated, we may decide to
+	 * materialize its result below.  In that case it would've been better
+	 * to specify full retrieval.  At present, however, we can only detect
+	 * correlation or lack of it after we've made the subplan :-(. Perhaps
+	 * detection of correlation should be done as a separate step.
+	 * Meanwhile, we don't want to be too optimistic about the percentage
+	 * of tuples retrieved, for fear of selecting a plan that's bad for
+	 * the materialization case.
 	 */
 	if (slink->subLinkType == EXISTS_SUBLINK)
 		tuple_fraction = 1.0;	/* just like a LIMIT 1 */
@@ -167,8 +169,8 @@ make_subplan(SubLink *slink)
 
 	/*
 	 * Assign subPlan, extParam and locParam to plan nodes. At the moment,
-	 * SS_finalize_plan doesn't handle initPlan-s and so we assign them
-	 * to the topmost plan node and take care about its extParam too.
+	 * SS_finalize_plan doesn't handle initPlan-s and so we assign them to
+	 * the topmost plan node and take care about its extParam too.
 	 */
 	(void) SS_finalize_plan(plan);
 	plan->initPlan = PlannerInitPlan;
@@ -206,8 +208,8 @@ make_subplan(SubLink *slink)
 
 	/*
 	 * Un-correlated or undirect correlated plans of EXISTS, EXPR, or
-	 * MULTIEXPR types can be used as initPlans.  For EXISTS or EXPR,
-	 * we just produce a Param referring to the result of evaluating the
+	 * MULTIEXPR types can be used as initPlans.  For EXISTS or EXPR, we
+	 * just produce a Param referring to the result of evaluating the
 	 * initPlan.  For MULTIEXPR, we must build an AND or OR-clause of the
 	 * individual comparison operators, using the appropriate lefthand
 	 * side expressions and Params for the initPlan's target items.
@@ -228,6 +230,7 @@ make_subplan(SubLink *slink)
 	else if (node->parParam == NIL && slink->subLinkType == EXPR_SUBLINK)
 	{
 		TargetEntry *te = lfirst(plan->targetlist);
+
 		/* need a var node just to pass to new_param()... */
 		Var		   *var = makeVar(0, 0, te->resdom->restype,
 								  te->resdom->restypmod, 0);
@@ -247,14 +250,15 @@ make_subplan(SubLink *slink)
 		int			i = 0;
 
 		/*
-		 * Convert oper list of Opers into a list of Exprs, using
-		 * lefthand arguments and Params representing inside results.
+		 * Convert oper list of Opers into a list of Exprs, using lefthand
+		 * arguments and Params representing inside results.
 		 */
 		foreach(lst, slink->oper)
 		{
 			Oper	   *oper = (Oper *) lfirst(lst);
 			Node	   *lefthand = nth(i, slink->lefthand);
 			TargetEntry *te = nth(i, plan->targetlist);
+
 			/* need a var node just to pass to new_param()... */
 			Var		   *var = makeVar(0, 0, te->resdom->restype,
 									  te->resdom->restypmod, 0);
@@ -273,7 +277,9 @@ make_subplan(SubLink *slink)
 			tup = get_operator_tuple(oper->opno);
 			Assert(HeapTupleIsValid(tup));
 			opform = (Form_pg_operator) GETSTRUCT(tup);
-			/* Note: we use make_operand in case runtime type conversion
+
+			/*
+			 * Note: we use make_operand in case runtime type conversion
 			 * function calls must be inserted for this operator!
 			 */
 			left = make_operand("", lefthand,
@@ -304,15 +310,16 @@ make_subplan(SubLink *slink)
 		int			i = 0;
 
 		/*
-		 * We can't convert subplans of ALL_SUBLINK or ANY_SUBLINK types to
-		 * initPlans, even when they are uncorrelated or undirect correlated,
-		 * because we need to scan the output of the subplan for each outer
-		 * tuple.  However, we have the option to tack a MATERIAL node onto
-		 * the top of an uncorrelated/undirect correlated subplan, which lets
-		 * us do the work of evaluating the subplan only once.  We do this
-		 * if the subplan's top plan node is anything more complicated than
-		 * a plain sequential scan, and we do it even for seqscan if the
-		 * qual appears selective enough to eliminate many tuples.
+		 * We can't convert subplans of ALL_SUBLINK or ANY_SUBLINK types
+		 * to initPlans, even when they are uncorrelated or undirect
+		 * correlated, because we need to scan the output of the subplan
+		 * for each outer tuple.  However, we have the option to tack a
+		 * MATERIAL node onto the top of an uncorrelated/undirect
+		 * correlated subplan, which lets us do the work of evaluating the
+		 * subplan only once.  We do this if the subplan's top plan node
+		 * is anything more complicated than a plain sequential scan, and
+		 * we do it even for seqscan if the qual appears selective enough
+		 * to eliminate many tuples.
 		 */
 		if (node->parParam == NIL)
 		{
@@ -336,10 +343,12 @@ make_subplan(SubLink *slink)
 					break;
 				case T_Material:
 				case T_Sort:
-					/* Don't add another Material node if there's one already,
-					 * nor if the top node is a Sort, since Sort materializes
-					 * its output anyway.  (I doubt either case can happen in
-					 * practice for a subplan, but...)
+
+					/*
+					 * Don't add another Material node if there's one
+					 * already, nor if the top node is a Sort, since Sort
+					 * materializes its output anyway.	(I doubt either
+					 * case can happen in practice for a subplan, but...)
 					 */
 					use_material = false;
 					break;
@@ -359,7 +368,7 @@ make_subplan(SubLink *slink)
 		/*
 		 * Make expression of SUBPLAN type
 		 */
-		expr->typeOid = BOOLOID; /* bogus, but we don't really care */
+		expr->typeOid = BOOLOID;/* bogus, but we don't really care */
 		expr->opType = SUBPLAN_EXPR;
 		expr->oper = (Node *) node;
 
@@ -371,17 +380,20 @@ make_subplan(SubLink *slink)
 			Var		   *var = nth(lfirsti(lst), PlannerParamVar);
 
 			var = (Var *) copyObject(var);
-			/* Must fix absolute-level varlevelsup from the
-			 * PlannerParamVar entry.  But since var is at current
-			 * subplan level, this is easy:
+
+			/*
+			 * Must fix absolute-level varlevelsup from the
+			 * PlannerParamVar entry.  But since var is at current subplan
+			 * level, this is easy:
 			 */
 			var->varlevelsup = 0;
 			args = lappend(args, var);
 		}
 		expr->args = args;
+
 		/*
-		 * Convert oper list of Opers into a list of Exprs, using
-		 * lefthand arguments and Consts representing inside results.
+		 * Convert oper list of Opers into a list of Exprs, using lefthand
+		 * arguments and Consts representing inside results.
 		 */
 		foreach(lst, slink->oper)
 		{
@@ -395,8 +407,8 @@ make_subplan(SubLink *slink)
 					   *right;
 
 			/*
-			 * XXX really ought to fill in constlen and constbyval correctly,
-			 * but right now ExecEvalExpr won't look at them...
+			 * XXX really ought to fill in constlen and constbyval
+			 * correctly, but right now ExecEvalExpr won't look at them...
 			 */
 			con = makeConst(te->resdom->restype, 0, 0, true, 0, 0, 0);
 
@@ -404,7 +416,9 @@ make_subplan(SubLink *slink)
 			tup = get_operator_tuple(oper->opno);
 			Assert(HeapTupleIsValid(tup));
 			opform = (Form_pg_operator) GETSTRUCT(tup);
-			/* Note: we use make_operand in case runtime type conversion
+
+			/*
+			 * Note: we use make_operand in case runtime type conversion
 			 * function calls must be inserted for this operator!
 			 */
 			left = make_operand("", lefthand,
@@ -450,9 +464,10 @@ set_unioni(List *l1, List *l2)
  * check in make_subplan to see whether a subselect has any subselects.
  */
 
-typedef struct finalize_primnode_results {
-	List	*subplans;			/* List of subplans found in expr */
-	List	*paramids;			/* List of PARAM_EXEC paramids found */
+typedef struct finalize_primnode_results
+{
+	List	   *subplans;		/* List of subplans found in expr */
+	List	   *paramids;		/* List of PARAM_EXEC paramids found */
 } finalize_primnode_results;
 
 static bool
@@ -464,16 +479,16 @@ finalize_primnode(Node *node, finalize_primnode_results *results)
 	{
 		if (((Param *) node)->paramkind == PARAM_EXEC)
 		{
-			int		paramid = (int) ((Param *) node)->paramid;
+			int			paramid = (int) ((Param *) node)->paramid;
 
-			if (! intMember(paramid, results->paramids))
+			if (!intMember(paramid, results->paramids))
 				results->paramids = lconsi(paramid, results->paramids);
 		}
 		return false;			/* no more to do here */
 	}
 	if (is_subplan(node))
 	{
-		SubPlan	   *subplan = (SubPlan *) ((Expr *) node)->oper;
+		SubPlan    *subplan = (SubPlan *) ((Expr *) node)->oper;
 		List	   *lst;
 
 		/* Add subplan to subplans list */
@@ -486,7 +501,7 @@ finalize_primnode(Node *node, finalize_primnode_results *results)
 
 			/* note varlevelsup is absolute level number */
 			if (var->varlevelsup < PlannerQueryLevel &&
-				! intMember(paramid, results->paramids))
+				!intMember(paramid, results->paramids))
 				results->paramids = lconsi(paramid, results->paramids);
 		}
 		/* fall through to recurse into subplan args */
@@ -533,7 +548,7 @@ Node *
 SS_process_sublinks(Node *expr)
 {
 	/* No setup needed for tree walk, so away we go */
-    return process_sublinks_mutator(expr, NULL);
+	return process_sublinks_mutator(expr, NULL);
 }
 
 static Node *
@@ -543,25 +558,26 @@ process_sublinks_mutator(Node *node, void *context)
 		return NULL;
 	if (IsA(node, SubLink))
 	{
-		SubLink	   *sublink = (SubLink *) node;
+		SubLink    *sublink = (SubLink *) node;
 
-		/* First, scan the lefthand-side expressions, if any.
-		 * This is a tad klugy since we modify the input SubLink node,
-		 * but that should be OK (make_subplan does it too!)
+		/*
+		 * First, scan the lefthand-side expressions, if any. This is a
+		 * tad klugy since we modify the input SubLink node, but that
+		 * should be OK (make_subplan does it too!)
 		 */
 		sublink->lefthand = (List *)
 			process_sublinks_mutator((Node *) sublink->lefthand, context);
 		/* Now build the SubPlan node and make the expr to return */
 		return make_subplan(sublink);
 	}
+
 	/*
 	 * Note that we will never see a SubPlan expression in the input
-	 * (since this is the very routine that creates 'em to begin with).
-	 * So the code in expression_tree_mutator() that might do
-	 * inappropriate things with SubPlans or SubLinks will not be
-	 * exercised.
+	 * (since this is the very routine that creates 'em to begin with). So
+	 * the code in expression_tree_mutator() that might do inappropriate
+	 * things with SubPlans or SubLinks will not be exercised.
 	 */
-	Assert(! is_subplan(node));
+	Assert(!is_subplan(node));
 
 	return expression_tree_mutator(node,
 								   process_sublinks_mutator,
@@ -581,12 +597,13 @@ SS_finalize_plan(Plan *plan)
 
 	results.subplans = NIL;		/* initialize lists to NIL */
 	results.paramids = NIL;
+
 	/*
 	 * When we call finalize_primnode, results.paramids lists are
-	 * automatically merged together.  But when recursing to self,
-	 * we have to do it the hard way.  We want the paramids list
-	 * to include params in subplans as well as at this level.
-	 * (We don't care about finding subplans of subplans, though.)
+	 * automatically merged together.  But when recursing to self, we have
+	 * to do it the hard way.  We want the paramids list to include params
+	 * in subplans as well as at this level. (We don't care about finding
+	 * subplans of subplans, though.)
 	 */
 
 	/* Find params and subplans in targetlist and qual */
@@ -604,13 +621,15 @@ SS_finalize_plan(Plan *plan)
 		case T_Append:
 			foreach(lst, ((Append *) plan)->appendplans)
 				results.paramids = set_unioni(results.paramids,
-								SS_finalize_plan((Plan *) lfirst(lst)));
+								 SS_finalize_plan((Plan *) lfirst(lst)));
 			break;
 
 		case T_IndexScan:
 			finalize_primnode((Node *) ((IndexScan *) plan)->indxqual,
 							  &results);
-			/* we need not look at indxqualorig, since it will have the
+
+			/*
+			 * we need not look at indxqualorig, since it will have the
 			 * same param references as indxqual, and we aren't really
 			 * concerned yet about having a complete subplan list.
 			 */
@@ -633,7 +652,7 @@ SS_finalize_plan(Plan *plan)
 
 		case T_TidScan:
 			finalize_primnode((Node *) ((TidScan *) plan)->tideval,
-							&results);
+							  &results);
 			break;
 
 		case T_Agg:
diff --git a/src/backend/optimizer/prep/prepqual.c b/src/backend/optimizer/prep/prepqual.c
index 5f92c545ccea0e3db2949661f0c7cb427d47342b..fae694dc264dcfd297945e20703938ffd3c550a4 100644
--- a/src/backend/optimizer/prep/prepqual.c
+++ b/src/backend/optimizer/prep/prepqual.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepqual.c,v 1.23 2000/02/27 19:45:44 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepqual.c,v 1.24 2000/04/12 17:15:23 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -33,7 +33,7 @@ static Expr *and_normalize(List *andlist);
 static Expr *qual_cleanup(Expr *qual);
 static List *remove_duplicates(List *list);
 static void count_bool_nodes(Expr *qual, double *nodes,
-							 double *cnfnodes, double *dnfnodes);
+				 double *cnfnodes, double *dnfnodes);
 
 /*****************************************************************************
  *
@@ -71,7 +71,7 @@ static void count_bool_nodes(Expr *qual, double *nodes,
  *
  * If 'removeAndFlag' is true then it removes explicit AND at the top level,
  * producing a list of implicitly-ANDed conditions.  Otherwise, a regular
- * boolean expression is returned.  Since most callers pass 'true', we
+ * boolean expression is returned.	Since most callers pass 'true', we
  * prefer to declare the result as List *, not Expr *.
  *
  * XXX This code could be much smarter, at the cost of also being slower,
@@ -95,12 +95,14 @@ canonicalize_qual(Expr *qual, bool removeAndFlag)
 	if (qual == NULL)
 		return NIL;
 
-	/* Flatten AND and OR groups throughout the tree.
-	 * This improvement is always worthwhile, so do it unconditionally.
+	/*
+	 * Flatten AND and OR groups throughout the tree. This improvement is
+	 * always worthwhile, so do it unconditionally.
 	 */
 	qual = flatten_andors(qual);
 
-	/* Push down NOTs.  We do this only in the top-level boolean
+	/*
+	 * Push down NOTs.	We do this only in the top-level boolean
 	 * expression, without examining arguments of operators/functions.
 	 * Even so, it might not be a win if we are unable to find negators
 	 * for all the operators involved; perhaps we should compare before-
@@ -109,21 +111,24 @@ canonicalize_qual(Expr *qual, bool removeAndFlag)
 	newqual = find_nots(qual);
 
 	/*
-	 * Choose whether to convert to CNF, or DNF, or leave well enough alone.
+	 * Choose whether to convert to CNF, or DNF, or leave well enough
+	 * alone.
 	 *
 	 * We make an approximate estimate of the number of bottom-level nodes
 	 * that will appear in the CNF and DNF forms of the query.
 	 */
 	count_bool_nodes(newqual, &nodes, &cnfnodes, &dnfnodes);
+
 	/*
 	 * First heuristic is to forget about *both* normal forms if there are
 	 * a huge number of terms in the qual clause.  This would only happen
-	 * with machine-generated queries, presumably; and most likely such
-	 * a query is already in either CNF or DNF.
+	 * with machine-generated queries, presumably; and most likely such a
+	 * query is already in either CNF or DNF.
 	 */
 	cnfok = dnfok = true;
 	if (nodes >= 500.0)
 		cnfok = dnfok = false;
+
 	/*
 	 * Second heuristic is to forget about either CNF or DNF if it shows
 	 * unreasonable growth compared to the original form of the qual,
@@ -134,15 +139,17 @@ canonicalize_qual(Expr *qual, bool removeAndFlag)
 		cnfok = false;
 	if (dnfnodes >= 4.0 * nodes)
 		dnfok = false;
+
 	/*
-	 * Third heuristic is to prefer DNF if top level is already an OR,
-	 * and only one relation is mentioned, and DNF is no larger than
-	 * the CNF representation.  (Pretty shaky; can we improve on this?)
+	 * Third heuristic is to prefer DNF if top level is already an OR, and
+	 * only one relation is mentioned, and DNF is no larger than the CNF
+	 * representation.	(Pretty shaky; can we improve on this?)
 	 */
 	if (cnfok && dnfok && dnfnodes <= cnfnodes &&
 		or_clause((Node *) newqual) &&
 		NumRelids((Node *) newqual) == 1)
 		cnfok = false;
+
 	/*
 	 * Otherwise, we prefer CNF.
 	 *
@@ -150,20 +157,26 @@ canonicalize_qual(Expr *qual, bool removeAndFlag)
 	 */
 	if (cnfok)
 	{
-		/* Normalize into conjunctive normal form, and clean up the result. */
+
+		/*
+		 * Normalize into conjunctive normal form, and clean up the
+		 * result.
+		 */
 		newqual = qual_cleanup(find_ors(newqual));
 	}
 	else if (dnfok)
 	{
-		/* Normalize into disjunctive normal form, and clean up the result. */
+
+		/*
+		 * Normalize into disjunctive normal form, and clean up the
+		 * result.
+		 */
 		newqual = qual_cleanup(find_ands(newqual));
 	}
 
 	/* Convert to implicit-AND list if requested */
 	if (removeAndFlag)
-	{
 		newqual = (Expr *) make_ands_implicit(newqual);
-	}
 
 	return (List *) newqual;
 }
@@ -177,7 +190,7 @@ canonicalize_qual(Expr *qual, bool removeAndFlag)
  *
  * If 'removeAndFlag' is true then it removes explicit AND at the top level,
  * producing a list of implicitly-ANDed conditions.  Otherwise, a regular
- * boolean expression is returned.  Since most callers pass 'true', we
+ * boolean expression is returned.	Since most callers pass 'true', we
  * prefer to declare the result as List *, not Expr *.
  */
 List *
@@ -188,11 +201,14 @@ cnfify(Expr *qual, bool removeAndFlag)
 	if (qual == NULL)
 		return NIL;
 
-	/* Flatten AND and OR groups throughout the tree.
-	 * This improvement is always worthwhile.
+	/*
+	 * Flatten AND and OR groups throughout the tree. This improvement is
+	 * always worthwhile.
 	 */
 	newqual = flatten_andors(qual);
-	/* Push down NOTs.  We do this only in the top-level boolean
+
+	/*
+	 * Push down NOTs.	We do this only in the top-level boolean
 	 * expression, without examining arguments of operators/functions.
 	 */
 	newqual = find_nots(newqual);
@@ -202,9 +218,7 @@ cnfify(Expr *qual, bool removeAndFlag)
 	newqual = qual_cleanup(newqual);
 
 	if (removeAndFlag)
-	{
 		newqual = (Expr *) make_ands_implicit(newqual);
-	}
 
 	return (List *) newqual;
 }
@@ -227,11 +241,14 @@ dnfify(Expr *qual)
 	if (qual == NULL)
 		return NULL;
 
-	/* Flatten AND and OR groups throughout the tree.
-	 * This improvement is always worthwhile.
+	/*
+	 * Flatten AND and OR groups throughout the tree. This improvement is
+	 * always worthwhile.
 	 */
 	newqual = flatten_andors(qual);
-	/* Push down NOTs.  We do this only in the top-level boolean
+
+	/*
+	 * Push down NOTs.	We do this only in the top-level boolean
 	 * expression, without examining arguments of operators/functions.
 	 */
 	newqual = find_nots(newqual);
@@ -280,13 +297,13 @@ flatten_andors(Expr *qual)
 
 		foreach(arg, qual->args)
 		{
-			Expr   *subexpr = flatten_andors((Expr *) lfirst(arg));
+			Expr	   *subexpr = flatten_andors((Expr *) lfirst(arg));
 
 			/*
-			 * Note: we can destructively nconc the subexpression's arglist
-			 * because we know the recursive invocation of flatten_andors
-			 * will have built a new arglist not shared with any other expr.
-			 * Otherwise we'd need a listCopy here.
+			 * Note: we can destructively nconc the subexpression's
+			 * arglist because we know the recursive invocation of
+			 * flatten_andors will have built a new arglist not shared
+			 * with any other expr. Otherwise we'd need a listCopy here.
 			 */
 			if (and_clause((Node *) subexpr))
 				out_list = nconc(out_list, subexpr->args);
@@ -302,13 +319,13 @@ flatten_andors(Expr *qual)
 
 		foreach(arg, qual->args)
 		{
-			Expr   *subexpr = flatten_andors((Expr *) lfirst(arg));
+			Expr	   *subexpr = flatten_andors((Expr *) lfirst(arg));
 
 			/*
-			 * Note: we can destructively nconc the subexpression's arglist
-			 * because we know the recursive invocation of flatten_andors
-			 * will have built a new arglist not shared with any other expr.
-			 * Otherwise we'd need a listCopy here.
+			 * Note: we can destructively nconc the subexpression's
+			 * arglist because we know the recursive invocation of
+			 * flatten_andors will have built a new arglist not shared
+			 * with any other expr. Otherwise we'd need a listCopy here.
 			 */
 			if (or_clause((Node *) subexpr))
 				out_list = nconc(out_list, subexpr->args);
@@ -354,13 +371,13 @@ pull_ors(List *orlist)
 
 	foreach(arg, orlist)
 	{
-		Expr   *subexpr = (Expr *) lfirst(arg);
+		Expr	   *subexpr = (Expr *) lfirst(arg);
 
 		/*
 		 * Note: we can destructively nconc the subexpression's arglist
-		 * because we know the recursive invocation of pull_ors
-		 * will have built a new arglist not shared with any other expr.
-		 * Otherwise we'd need a listCopy here.
+		 * because we know the recursive invocation of pull_ors will have
+		 * built a new arglist not shared with any other expr. Otherwise
+		 * we'd need a listCopy here.
 		 */
 		if (or_clause((Node *) subexpr))
 			out_list = nconc(out_list, pull_ors(subexpr->args));
@@ -385,13 +402,13 @@ pull_ands(List *andlist)
 
 	foreach(arg, andlist)
 	{
-		Expr   *subexpr = (Expr *) lfirst(arg);
+		Expr	   *subexpr = (Expr *) lfirst(arg);
 
 		/*
 		 * Note: we can destructively nconc the subexpression's arglist
-		 * because we know the recursive invocation of pull_ands
-		 * will have built a new arglist not shared with any other expr.
-		 * Otherwise we'd need a listCopy here.
+		 * because we know the recursive invocation of pull_ands will have
+		 * built a new arglist not shared with any other expr. Otherwise
+		 * we'd need a listCopy here.
 		 */
 		if (and_clause((Node *) subexpr))
 			out_list = nconc(out_list, pull_ands(subexpr->args));
@@ -407,7 +424,7 @@ pull_ands(List *andlist)
  *	  For 'NOT' clauses, apply push_not() to try to push down the 'NOT'.
  *	  For all other clause types, simply recurse.
  *
- * Returns the modified qualification.  AND/OR flatness is preserved.
+ * Returns the modified qualification.	AND/OR flatness is preserved.
  */
 static Expr *
 find_nots(Expr *qual)
@@ -468,7 +485,8 @@ static Expr *
 push_nots(Expr *qual)
 {
 	if (qual == NULL)
-		return make_notclause(qual); /* XXX is this right?  Or possible? */
+		return make_notclause(qual);	/* XXX is this right?  Or
+										 * possible? */
 
 	/*
 	 * Negate an operator clause if possible: ("NOT" (< A B)) => (> A B)
@@ -486,6 +504,7 @@ push_nots(Expr *qual)
 											   InvalidOid,
 											   oper->opresulttype,
 											   0, NULL);
+
 			return make_opclause(op, get_leftop(qual), get_rightop(qual));
 		}
 		else
@@ -496,7 +515,7 @@ push_nots(Expr *qual)
 		/*--------------------
 		 * Apply DeMorgan's Laws:
 		 *		("NOT" ("AND" A B)) => ("OR" ("NOT" A) ("NOT" B))
-		 *		("NOT" ("OR" A B))  => ("AND" ("NOT" A) ("NOT" B))
+		 *		("NOT" ("OR" A B))	=> ("AND" ("NOT" A) ("NOT" B))
 		 * i.e., swap AND for OR and negate all the subclauses.
 		 *--------------------
 		 */
@@ -518,6 +537,7 @@ push_nots(Expr *qual)
 	}
 	else if (not_clause((Node *) qual))
 	{
+
 		/*
 		 * Another 'not' cancels this 'not', so eliminate the 'not' and
 		 * stop negating this branch.  But search the subexpression for
@@ -527,6 +547,7 @@ push_nots(Expr *qual)
 	}
 	else
 	{
+
 		/*
 		 * We don't know how to negate anything else, place a 'not' at
 		 * this level.
@@ -544,7 +565,7 @@ push_nots(Expr *qual)
  *	  Note that 'or' clauses will always be turned into 'and' clauses
  *	  if they contain any 'and' subclauses.
  *
- * Returns the modified qualification.  AND/OR flatness is preserved.
+ * Returns the modified qualification.	AND/OR flatness is preserved.
  */
 static Expr *
 find_ors(Expr *qual)
@@ -601,17 +622,17 @@ or_normalize(List *orlist)
 		return lfirst(orlist);	/* single-expression OR (can this happen?) */
 
 	/*
-	 * If we have a choice of AND clauses, pick the one with the
-	 * most subclauses.  Because we initialized num_subclauses = 1,
-	 * any AND clauses with only one arg will be ignored as useless.
+	 * If we have a choice of AND clauses, pick the one with the most
+	 * subclauses.	Because we initialized num_subclauses = 1, any AND
+	 * clauses with only one arg will be ignored as useless.
 	 */
 	foreach(temp, orlist)
 	{
-		Expr   *clause = lfirst(temp);
+		Expr	   *clause = lfirst(temp);
 
 		if (and_clause((Node *) clause))
 		{
-			int		nclauses = length(clause->args);
+			int			nclauses = length(clause->args);
 
 			if (nclauses > num_subclauses)
 			{
@@ -622,12 +643,13 @@ or_normalize(List *orlist)
 	}
 
 	/* if there's no suitable AND clause, we can't transform the OR */
-	if (! distributable)
+	if (!distributable)
 		return make_orclause(orlist);
 
-	/* Caution: lremove destructively modifies the input orlist.
-	 * This should be OK, since or_normalize is only called with
-	 * freshly constructed lists that are not referenced elsewhere.
+	/*
+	 * Caution: lremove destructively modifies the input orlist. This
+	 * should be OK, since or_normalize is only called with freshly
+	 * constructed lists that are not referenced elsewhere.
 	 */
 	orlist = lremove(distributable, orlist);
 
@@ -635,11 +657,12 @@ or_normalize(List *orlist)
 	{
 		Expr	   *andclause = lfirst(temp);
 
-		/* pull_ors is needed here in case andclause has a top-level OR.
-		 * Then we recursively apply or_normalize, since there might
-		 * be an AND subclause in the resulting OR-list.
-		 * Note: we rely on pull_ors to build a fresh list,
-		 * and not damage the given orlist.
+		/*
+		 * pull_ors is needed here in case andclause has a top-level OR.
+		 * Then we recursively apply or_normalize, since there might be an
+		 * AND subclause in the resulting OR-list. Note: we rely on
+		 * pull_ors to build a fresh list, and not damage the given
+		 * orlist.
 		 */
 		andclause = or_normalize(pull_ors(lcons(andclause, orlist)));
 		andclauses = lappend(andclauses, andclause);
@@ -658,7 +681,7 @@ or_normalize(List *orlist)
  *	  Note that 'and' clauses will always be turned into 'or' clauses
  *	  if they contain any 'or' subclauses.
  *
- * Returns the modified qualification.  AND/OR flatness is preserved.
+ * Returns the modified qualification.	AND/OR flatness is preserved.
  */
 static Expr *
 find_ands(Expr *qual)
@@ -712,20 +735,21 @@ and_normalize(List *andlist)
 	if (andlist == NIL)
 		return NULL;			/* probably can't happen */
 	if (lnext(andlist) == NIL)
-		return lfirst(andlist);	/* single-expression AND (can this happen?) */
+		return lfirst(andlist); /* single-expression AND (can this
+								 * happen?) */
 
 	/*
-	 * If we have a choice of OR clauses, pick the one with the
-	 * most subclauses.  Because we initialized num_subclauses = 1,
-	 * any OR clauses with only one arg will be ignored as useless.
+	 * If we have a choice of OR clauses, pick the one with the most
+	 * subclauses.	Because we initialized num_subclauses = 1, any OR
+	 * clauses with only one arg will be ignored as useless.
 	 */
 	foreach(temp, andlist)
 	{
-		Expr   *clause = lfirst(temp);
+		Expr	   *clause = lfirst(temp);
 
 		if (or_clause((Node *) clause))
 		{
-			int		nclauses = length(clause->args);
+			int			nclauses = length(clause->args);
 
 			if (nclauses > num_subclauses)
 			{
@@ -736,12 +760,13 @@ and_normalize(List *andlist)
 	}
 
 	/* if there's no suitable OR clause, we can't transform the AND */
-	if (! distributable)
+	if (!distributable)
 		return make_andclause(andlist);
 
-	/* Caution: lremove destructively modifies the input andlist.
-	 * This should be OK, since and_normalize is only called with
-	 * freshly constructed lists that are not referenced elsewhere.
+	/*
+	 * Caution: lremove destructively modifies the input andlist. This
+	 * should be OK, since and_normalize is only called with freshly
+	 * constructed lists that are not referenced elsewhere.
 	 */
 	andlist = lremove(distributable, andlist);
 
@@ -749,11 +774,12 @@ and_normalize(List *andlist)
 	{
 		Expr	   *orclause = lfirst(temp);
 
-		/* pull_ands is needed here in case orclause has a top-level AND.
-		 * Then we recursively apply and_normalize, since there might
-		 * be an OR subclause in the resulting AND-list.
-		 * Note: we rely on pull_ands to build a fresh list,
-		 * and not damage the given andlist.
+		/*
+		 * pull_ands is needed here in case orclause has a top-level AND.
+		 * Then we recursively apply and_normalize, since there might be
+		 * an OR subclause in the resulting AND-list. Note: we rely on
+		 * pull_ands to build a fresh list, and not damage the given
+		 * andlist.
 		 */
 		orclause = and_normalize(pull_ands(lcons(orclause, andlist)));
 		orclauses = lappend(orclauses, orclause);
@@ -767,7 +793,7 @@ and_normalize(List *andlist)
  * qual_cleanup
  *	  Fix up a qualification by removing duplicate entries (which could be
  *	  created during normalization, if identical subexpressions from different
- *	  parts of the tree are brought together).  Also, check for AND and OR
+ *	  parts of the tree are brought together).	Also, check for AND and OR
  *	  clauses with only one remaining subexpression, and simplify.
  *
  * Returns the modified qualification.
@@ -828,7 +854,7 @@ remove_duplicates(List *list)
 
 	foreach(i, list)
 	{
-		if (! member(lfirst(i), result))
+		if (!member(lfirst(i), result))
 			result = lappend(result, lfirst(i));
 	}
 	return result;
@@ -855,7 +881,9 @@ count_bool_nodes(Expr *qual,
 				 double *dnfnodes)
 {
 	List	   *temp;
-	double		subnodes, subcnfnodes, subdnfnodes;
+	double		subnodes,
+				subcnfnodes,
+				subdnfnodes;
 
 	if (and_clause((Node *) qual))
 	{
@@ -864,13 +892,15 @@ count_bool_nodes(Expr *qual,
 
 		foreach(temp, qual->args)
 		{
-			count_bool_nodes(lfirst(temp), 
+			count_bool_nodes(lfirst(temp),
 							 &subnodes, &subcnfnodes, &subdnfnodes);
 			*nodes += subnodes;
 			*cnfnodes += subcnfnodes;
 			*dnfnodes *= subdnfnodes;
 		}
-		/* we could get dnfnodes < cnfnodes here, if all the sub-nodes are
+
+		/*
+		 * we could get dnfnodes < cnfnodes here, if all the sub-nodes are
 		 * simple ones with count 1.  Make sure dnfnodes isn't too small.
 		 */
 		if (*dnfnodes < *cnfnodes)
@@ -883,13 +913,15 @@ count_bool_nodes(Expr *qual,
 
 		foreach(temp, qual->args)
 		{
-			count_bool_nodes(lfirst(temp), 
+			count_bool_nodes(lfirst(temp),
 							 &subnodes, &subcnfnodes, &subdnfnodes);
 			*nodes += subnodes;
 			*cnfnodes *= subcnfnodes;
 			*dnfnodes += subdnfnodes;
 		}
-		/* we could get cnfnodes < dnfnodes here, if all the sub-nodes are
+
+		/*
+		 * we could get cnfnodes < dnfnodes here, if all the sub-nodes are
 		 * simple ones with count 1.  Make sure cnfnodes isn't too small.
 		 */
 		if (*cnfnodes < *dnfnodes)
diff --git a/src/backend/optimizer/prep/preptlist.c b/src/backend/optimizer/prep/preptlist.c
index 22ed6f418f79a42dba35af1c602b3236a5e4913c..22f06bb61a94f4ddbbcd2985af50cda9aa7334f4 100644
--- a/src/backend/optimizer/prep/preptlist.c
+++ b/src/backend/optimizer/prep/preptlist.c
@@ -4,7 +4,7 @@
  *	  Routines to preprocess the parse tree target list
  *
  * This module takes care of altering the query targetlist as needed for
- * INSERT, UPDATE, and DELETE queries.  For INSERT and UPDATE queries,
+ * INSERT, UPDATE, and DELETE queries.	For INSERT and UPDATE queries,
  * the targetlist must contain an entry for each attribute of the target
  * relation in the correct order.  For both UPDATE and DELETE queries,
  * we need a junk targetlist entry holding the CTID attribute --- the
@@ -15,7 +15,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.35 2000/03/09 05:00:24 inoue Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.36 2000/04/12 17:15:23 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -31,7 +31,7 @@
 
 
 static List *expand_targetlist(List *tlist, int command_type,
-							   Index result_relation, List *range_table);
+				  Index result_relation, List *range_table);
 
 
 /*
@@ -46,6 +46,7 @@ preprocess_targetlist(List *tlist,
 					  Index result_relation,
 					  List *range_table)
 {
+
 	/*
 	 * for heap_formtuple to work, the targetlist must match the exact
 	 * order of the attributes. We also need to fill in any missing
@@ -56,11 +57,11 @@ preprocess_targetlist(List *tlist,
 								  result_relation, range_table);
 
 	/*
-	 *	for "update" and "delete" queries, add ctid of the result
-	 *	relation into the target list so that the ctid will propagate
-	 *	through execution and ExecutePlan() will be able to identify
-	 *	the right tuple to replace or delete.  This extra field is
-	 *	marked "junk" so that it is not stored back into the tuple.
+	 * for "update" and "delete" queries, add ctid of the result relation
+	 * into the target list so that the ctid will propagate through
+	 * execution and ExecutePlan() will be able to identify the right
+	 * tuple to replace or delete.	This extra field is marked "junk" so
+	 * that it is not stored back into the tuple.
 	 */
 	if (command_type == CMD_UPDATE || command_type == CMD_DELETE)
 	{
@@ -78,7 +79,8 @@ preprocess_targetlist(List *tlist,
 		var = makeVar(result_relation, SelfItemPointerAttributeNumber,
 					  TIDOID, -1, 0);
 
-		/* For an UPDATE, expand_targetlist already created a fresh tlist.
+		/*
+		 * For an UPDATE, expand_targetlist already created a fresh tlist.
 		 * For DELETE, better do a listCopy so that we don't destructively
 		 * modify the original tlist (is this really necessary?).
 		 */
@@ -117,11 +119,11 @@ expand_targetlist(List *tlist, int command_type,
 	List	   *temp;
 
 	/*
-	 * Keep a map of which tlist items we have transferred to new list.
-	 * +1 here keeps palloc from complaining if old_tlist_len=0.
+	 * Keep a map of which tlist items we have transferred to new list. +1
+	 * here keeps palloc from complaining if old_tlist_len=0.
 	 */
-	tlistentry_used = (bool *) palloc((old_tlist_len+1) * sizeof(bool));
-	memset(tlistentry_used, 0, (old_tlist_len+1) * sizeof(bool));
+	tlistentry_used = (bool *) palloc((old_tlist_len + 1) * sizeof(bool));
+	memset(tlistentry_used, 0, (old_tlist_len + 1) * sizeof(bool));
 
 	/*
 	 * Scan the tuple description in the relation's relcache entry to make
@@ -133,9 +135,9 @@ expand_targetlist(List *tlist, int command_type,
 
 	for (attrno = 1; attrno <= numattrs; attrno++)
 	{
-		Form_pg_attribute att_tup = rel->rd_att->attrs[attrno-1];
-		char		   *attrname = NameStr(att_tup->attname);
-		TargetEntry	   *new_tle = NULL;
+		Form_pg_attribute att_tup = rel->rd_att->attrs[attrno - 1];
+		char	   *attrname = NameStr(att_tup->attname);
+		TargetEntry *new_tle = NULL;
 
 		/*
 		 * We match targetlist entries to attributes using the resname.
@@ -143,22 +145,22 @@ expand_targetlist(List *tlist, int command_type,
 		old_tlist_index = 0;
 		foreach(temp, tlist)
 		{
-			TargetEntry	   *old_tle = (TargetEntry *) lfirst(temp);
-			Resdom		   *resdom = old_tle->resdom;
+			TargetEntry *old_tle = (TargetEntry *) lfirst(temp);
+			Resdom	   *resdom = old_tle->resdom;
 
-			if (! tlistentry_used[old_tlist_index] &&
+			if (!tlistentry_used[old_tlist_index] &&
 				strcmp(resdom->resname, attrname) == 0 &&
-				! resdom->resjunk)
+				!resdom->resjunk)
 			{
+
 				/*
 				 * We can recycle the old TLE+resdom if right resno; else
-				 * make a new one to avoid modifying the old tlist structure.
-				 * (Is preserving old tlist actually necessary?)
+				 * make a new one to avoid modifying the old tlist
+				 * structure. (Is preserving old tlist actually
+				 * necessary?)
 				 */
 				if (resdom->resno == attrno)
-				{
 					new_tle = old_tle;
-				}
 				else
 				{
 					resdom = (Resdom *) copyObject((Node *) resdom);
@@ -173,14 +175,15 @@ expand_targetlist(List *tlist, int command_type,
 
 		if (new_tle == NULL)
 		{
+
 			/*
 			 * Didn't find a matching tlist entry, so make one.
 			 *
-			 * For INSERT, generate a constant of the default value for
-			 * the attribute type, or NULL if no default value.
+			 * For INSERT, generate a constant of the default value for the
+			 * attribute type, or NULL if no default value.
 			 *
-			 * For UPDATE, generate a Var reference to the existing value
-			 * of the attribute, so that it gets copied to the new tuple.
+			 * For UPDATE, generate a Var reference to the existing value of
+			 * the attribute, so that it gets copied to the new tuple.
 			 */
 			Oid			atttype = att_tup->atttypid;
 			int32		atttypmod = att_tup->atttypmod;
@@ -188,92 +191,96 @@ expand_targetlist(List *tlist, int command_type,
 			switch (command_type)
 			{
 				case CMD_INSERT:
-				{
+					{
 #ifdef	_DROP_COLUMN_HACK__
-					Datum		typedefault;
+						Datum		typedefault;
+
 #else
-					Datum		typedefault = get_typdefault(atttype);
-#endif /* _DROP_COLUMN_HACK__ */
-					int			typlen;
-					Const	   *temp_const;
+						Datum		typedefault = get_typdefault(atttype);
+
+#endif	 /* _DROP_COLUMN_HACK__ */
+						int			typlen;
+						Const	   *temp_const;
 
 #ifdef	_DROP_COLUMN_HACK__
-					if (COLUMN_IS_DROPPED(att_tup))
-						typedefault = PointerGetDatum(NULL);
-					else
-						typedefault = get_typdefault(atttype);
-#endif /* _DROP_COLUMN_HACK__ */
-					if (typedefault == PointerGetDatum(NULL))
-						typlen = 0;
-					else
-					{
-						/*
-						 * Since this is an append or replace, the size of
-						 * any set attribute is the size of the OID used to
-						 * represent it.
-						 */
-						if (att_tup->attisset)
-							typlen = get_typlen(OIDOID);
+						if (COLUMN_IS_DROPPED(att_tup))
+							typedefault = PointerGetDatum(NULL);
+						else
+							typedefault = get_typdefault(atttype);
+#endif	 /* _DROP_COLUMN_HACK__ */
+						if (typedefault == PointerGetDatum(NULL))
+							typlen = 0;
 						else
-							typlen = get_typlen(atttype);
+						{
+
+							/*
+							 * Since this is an append or replace, the
+							 * size of any set attribute is the size of
+							 * the OID used to represent it.
+							 */
+							if (att_tup->attisset)
+								typlen = get_typlen(OIDOID);
+							else
+								typlen = get_typlen(atttype);
+						}
+
+						temp_const = makeConst(atttype,
+											   typlen,
+											   typedefault,
+								  (typedefault == PointerGetDatum(NULL)),
+											   false,
+											   false,	/* not a set */
+											   false);
+
+						new_tle = makeTargetEntry(makeResdom(attrno,
+															 atttype,
+															 -1,
+													   pstrdup(attrname),
+															 0,
+															 (Oid) 0,
+															 false),
+												  (Node *) temp_const);
+						break;
 					}
-
-					temp_const = makeConst(atttype,
-										   typlen,
-										   typedefault,
-										   (typedefault == PointerGetDatum(NULL)),
-										   false,
-										   false, /* not a set */
-										   false);
-
-					new_tle = makeTargetEntry(makeResdom(attrno,
-														 atttype,
-														 -1,
-														 pstrdup(attrname),
-														 0,
-														 (Oid) 0,
-														 false),
-											  (Node *) temp_const);
-					break;
-				}
 				case CMD_UPDATE:
-				{
-					Var		   *temp_var;
+					{
+						Var		   *temp_var;
 
 #ifdef	_DROP_COLUMN_HACK__
-					Node	*temp_node = (Node *) NULL;
-					if (COLUMN_IS_DROPPED(att_tup))
-					{
-						temp_node = (Node *)makeConst(atttype, 								0, 
-							PointerGetDatum(NULL),
-								true,
-								false,
-								false, /* not a set */
-								false);
-					}
-					else
-#endif /* _DROP_COLUMN_HACK__ */
-					temp_var = makeVar(result_relation, attrno, atttype,
-									   atttypmod, 0);
+						Node	   *temp_node = (Node *) NULL;
+
+						if (COLUMN_IS_DROPPED(att_tup))
+						{
+							temp_node = (Node *) makeConst(atttype, 0,
+												   PointerGetDatum(NULL),
+														   true,
+														   false,
+														   false,		/* not a set */
+														   false);
+						}
+						else
+#endif	 /* _DROP_COLUMN_HACK__ */
+							temp_var = makeVar(result_relation, attrno, atttype,
+											   atttypmod, 0);
 #ifdef	_DROP_COLUMN_HACK__
-					if (!temp_node)
-						temp_node = (Node *) temp_var;
-#endif /* _DROP_COLUMN_HACK__ */
-
-					new_tle = makeTargetEntry(makeResdom(attrno,
-														 atttype,
-														 atttypmod,
-														 pstrdup(attrname),
-														 0,
-														 (Oid) 0,
-														 false),										
+						if (!temp_node)
+							temp_node = (Node *) temp_var;
+#endif	 /* _DROP_COLUMN_HACK__ */
+
+						new_tle = makeTargetEntry(makeResdom(attrno,
+															 atttype,
+															 atttypmod,
+													   pstrdup(attrname),
+															 0,
+															 (Oid) 0,
+															 false),
 #ifdef	_DROP_COLUMN_HACK__
-				temp_node);
+												  temp_node);
 #else
-	(Node *) temp_var);
-#endif /* _DROP_COLUMN_HACK__ */
-					break;
-				}
+												  (Node *) temp_var);
+#endif	 /* _DROP_COLUMN_HACK__ */
+						break;
+					}
 				default:
 					elog(ERROR, "expand_targetlist: unexpected command_type");
 					break;
@@ -285,18 +292,19 @@ expand_targetlist(List *tlist, int command_type,
 
 	/*
 	 * Copy all unprocessed tlist entries to the end of the new tlist,
-	 * making sure they are marked resjunk = true.  Typical junk entries
-	 * include ORDER BY or GROUP BY expressions (are these actually possible
-	 * in an INSERT or UPDATE?), system attribute references, etc.
+	 * making sure they are marked resjunk = true.	Typical junk entries
+	 * include ORDER BY or GROUP BY expressions (are these actually
+	 * possible in an INSERT or UPDATE?), system attribute references,
+	 * etc.
 	 */
 	old_tlist_index = 0;
 	foreach(temp, tlist)
 	{
-		TargetEntry	   *old_tle = (TargetEntry *) lfirst(temp);
+		TargetEntry *old_tle = (TargetEntry *) lfirst(temp);
 
-		if (! tlistentry_used[old_tlist_index])
+		if (!tlistentry_used[old_tlist_index])
 		{
-			Resdom		   *resdom;
+			Resdom	   *resdom;
 
 			resdom = (Resdom *) copyObject((Node *) old_tle->resdom);
 			resdom->resno = attrno++;
diff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.c
index e866a5032fc1ee92d09f1f528fd3a42de0454498..cd2baf6bbb8edc93f8891ec72de579faf37db212 100644
--- a/src/backend/optimizer/prep/prepunion.c
+++ b/src/backend/optimizer/prep/prepunion.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.47 2000/03/21 05:12:06 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.48 2000/04/12 17:15:23 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,8 @@
 #include "parser/parsetree.h"
 #include "utils/lsyscache.h"
 
-typedef struct {
+typedef struct
+{
 	Index		rt_index;
 	int			sublevels_up;
 	Oid			old_relid;
@@ -40,11 +41,11 @@ static RangeTblEntry *new_rangetable_entry(Oid new_relid,
 					 RangeTblEntry *old_entry);
 static void fix_parsetree_attnums(Index rt_index, Oid old_relid,
 					  Oid new_relid, Query *parsetree);
-static bool fix_parsetree_attnums_walker (Node *node,
-								fix_parsetree_attnums_context *context);
+static bool fix_parsetree_attnums_walker(Node *node,
+							 fix_parsetree_attnums_context *context);
 static Append *make_append(List *appendplans, List *unionrtables,
-						   Index rt_index,
-						   List *inheritrtable, List *tlist);
+			Index rt_index,
+			List *inheritrtable, List *tlist);
 
 
 /*
@@ -122,11 +123,11 @@ plan_union_queries(Query *parse)
 	/* Is this a simple one */
 	if (!union_all_found ||
 		!union_found ||
-		/* A trailing UNION negates the effect of earlier UNION ALLs */
+	/* A trailing UNION negates the effect of earlier UNION ALLs */
 		!last_union_all_flag)
 	{
 		List	   *hold_unionClause = parse->unionClause;
-		double		tuple_fraction = -1.0; /* default processing */
+		double		tuple_fraction = -1.0;		/* default processing */
 
 		/* we will do sorting later, so don't do it now */
 		if (!union_all_found ||
@@ -134,6 +135,7 @@ plan_union_queries(Query *parse)
 		{
 			parse->sortClause = NIL;
 			parse->distinctClause = NIL;
+
 			/*
 			 * force lower-level planning to assume that all tuples will
 			 * be retrieved, even if it sees a LIMIT in the query node.
@@ -149,8 +151,9 @@ plan_union_queries(Query *parse)
 		{
 			Query	   *union_query = lfirst(ulist);
 
-			/* use subquery_planner here because the union'd queries
-			 * have not been preprocessed yet.  My goodness this is messy...
+			/*
+			 * use subquery_planner here because the union'd queries have
+			 * not been preprocessed yet.  My goodness this is messy...
 			 */
 			union_plans = lappend(union_plans,
 								  subquery_planner(union_query,
@@ -178,8 +181,8 @@ plan_union_queries(Query *parse)
 		 * Recursion, but UNION only. The last one is a UNION, so it will
 		 * not come here in recursion.
 		 *
-		 * XXX is it OK to pass default -1 to union_planner in this path,
-		 * or should we force a tuple_fraction value?
+		 * XXX is it OK to pass default -1 to union_planner in this path, or
+		 * should we force a tuple_fraction value?
 		 */
 		union_plans = lcons(union_planner(parse, -1.0), NIL);
 		union_rts = lcons(parse->rtable, NIL);
@@ -189,11 +192,12 @@ plan_union_queries(Query *parse)
 		{
 			Query	   *union_all_query = lfirst(ulist);
 
-			/* use subquery_planner here because the union'd queries
-			 * have not been preprocessed yet.  My goodness this is messy...
+			/*
+			 * use subquery_planner here because the union'd queries have
+			 * not been preprocessed yet.  My goodness this is messy...
 			 */
 			union_plans = lappend(union_plans,
-								  subquery_planner(union_all_query, -1.0));
+								subquery_planner(union_all_query, -1.0));
 			union_rts = lappend(union_rts, union_all_query->rtable);
 		}
 	}
@@ -201,9 +205,11 @@ plan_union_queries(Query *parse)
 	/* We have already split UNION and UNION ALL and we made it consistent */
 	if (!last_union_all_flag)
 	{
-		/* Need SELECT DISTINCT behavior to implement UNION.
-		 * Put back the held sortClause, add any missing columns to the
-		 * sort clause, and set distinctClause properly.
+
+		/*
+		 * Need SELECT DISTINCT behavior to implement UNION. Put back the
+		 * held sortClause, add any missing columns to the sort clause,
+		 * and set distinctClause properly.
 		 */
 		List	   *slitem;
 
@@ -215,7 +221,7 @@ plan_union_queries(Query *parse)
 			SortClause *scl = (SortClause *) lfirst(slitem);
 			TargetEntry *tle = get_sortgroupclause_tle(scl, parse->targetList);
 
-			if (! tle->resdom->resjunk)
+			if (!tle->resdom->resjunk)
 				parse->distinctClause = lappend(parse->distinctClause,
 												copyObject(scl));
 		}
@@ -226,9 +232,10 @@ plan_union_queries(Query *parse)
 		parse->distinctClause = NIL;
 	}
 
-	/* Make sure we don't try to apply the first query's grouping stuff
-	 * to the Append node, either.  Basically we don't want union_planner
-	 * to do anything when we return control, except add the top sort/unique
+	/*
+	 * Make sure we don't try to apply the first query's grouping stuff to
+	 * the Append node, either.  Basically we don't want union_planner to
+	 * do anything when we return control, except add the top sort/unique
 	 * nodes for DISTINCT processing if this wasn't UNION ALL, or the top
 	 * sort node if it was UNION ALL with a user-provided sort clause.
 	 */
@@ -259,13 +266,13 @@ plan_union_queries(Query *parse)
  *
  * If grouping, aggregation, or sorting is specified in the parent plan,
  * the subplans should not do any of those steps --- we must do those
- * operations just once above the APPEND node.  The given tlist has been
+ * operations just once above the APPEND node.	The given tlist has been
  * modified appropriately to remove group/aggregate expressions, but the
  * Query node still has the relevant fields set.  We remove them in the
  * copies used for subplans (see plan_inherit_query).
  *
  * NOTE: this can be invoked recursively if more than one inheritance wildcard
- * is present.  At each level of recursion, the first wildcard remaining in
+ * is present.	At each level of recursion, the first wildcard remaining in
  * the rangetable is expanded.
  */
 Append *
@@ -282,8 +289,8 @@ plan_inherit_queries(Query *parse, List *tlist, Index rt_index)
 
 	/*
 	 * Remove the flag for this relation, since we're about to handle it.
-	 * XXX destructive change to parent parse tree, but necessary to prevent
-	 * infinite recursion.
+	 * XXX destructive change to parent parse tree, but necessary to
+	 * prevent infinite recursion.
 	 */
 	rt_entry->inh = false;
 
@@ -313,42 +320,44 @@ plan_inherit_query(Relids relids,
 	List	   *union_plans = NIL;
 	List	   *union_rtentries = NIL;
 	List	   *save_tlist = root->targetList;
-	double tuple_fraction;
+	double		tuple_fraction;
 	List	   *i;
 
 	/*
 	 * Avoid making copies of the root's tlist, which we aren't going to
-	 * use anyway (we are going to make copies of the passed tlist, instead).
+	 * use anyway (we are going to make copies of the passed tlist,
+	 * instead).
 	 */
 	root->targetList = NIL;
 
 	/*
-	 * If we are going to need sorting or grouping at the top level,
-	 * force lower-level planners to assume that all tuples will be
-	 * retrieved.
+	 * If we are going to need sorting or grouping at the top level, force
+	 * lower-level planners to assume that all tuples will be retrieved.
 	 */
 	if (root->distinctClause || root->sortClause ||
 		root->groupClause || root->hasAggs)
-		tuple_fraction = 0.0; /* will need all tuples from each subplan */
+		tuple_fraction = 0.0;	/* will need all tuples from each subplan */
 	else
-		tuple_fraction = -1.0; /* default behavior is OK (I think) */
+		tuple_fraction = -1.0;	/* default behavior is OK (I think) */
 
 	foreach(i, relids)
 	{
 		int			relid = lfirsti(i);
+
 		/*
-		 * Make a modifiable copy of the original query,
-		 * and replace the target rangetable entry with a new one
-		 * identifying this child table.
+		 * Make a modifiable copy of the original query, and replace the
+		 * target rangetable entry with a new one identifying this child
+		 * table.
 		 */
 		Query	   *new_root = copyObject(root);
 		RangeTblEntry *new_rt_entry = new_rangetable_entry(relid,
 														   rt_entry);
 
 		rt_store(rt_index, new_root->rtable, new_rt_entry);
+
 		/*
-		 * Insert (a modifiable copy of) the desired simplified tlist
-		 * into the subquery
+		 * Insert (a modifiable copy of) the desired simplified tlist into
+		 * the subquery
 		 */
 		new_root->targetList = copyObject(tlist);
 
@@ -360,14 +369,15 @@ plan_inherit_query(Relids relids,
 		new_root->sortClause = NIL;
 		new_root->groupClause = NIL;
 		new_root->havingQual = NULL;
-		new_root->hasAggs = false; /* shouldn't be any left ... */
+		new_root->hasAggs = false;		/* shouldn't be any left ... */
 
 		/*
 		 * Update attribute numbers in case child has different ordering
 		 * of columns than parent (as can happen after ALTER TABLE).
 		 *
 		 * XXX This is a crock, and it doesn't really work.  It'd be better
-		 * to fix ALTER TABLE to preserve consistency of attribute numbering.
+		 * to fix ALTER TABLE to preserve consistency of attribute
+		 * numbering.
 		 */
 		fix_parsetree_attnums(rt_index,
 							  rt_entry->relid,
@@ -397,23 +407,24 @@ find_all_inheritors(Oid parentrel)
 	List	   *unexamined_relids = lconsi(parentrel, NIL);
 
 	/*
-	 * While the queue of unexamined relids is nonempty, remove the
-	 * first element, mark it examined, and find its direct descendants.
-	 * NB: cannot use foreach(), since we modify the queue inside loop.
+	 * While the queue of unexamined relids is nonempty, remove the first
+	 * element, mark it examined, and find its direct descendants. NB:
+	 * cannot use foreach(), since we modify the queue inside loop.
 	 */
 	while (unexamined_relids != NIL)
 	{
-		Oid		currentrel = lfirsti(unexamined_relids);
-		List   *currentchildren;
+		Oid			currentrel = lfirsti(unexamined_relids);
+		List	   *currentchildren;
 
 		unexamined_relids = lnext(unexamined_relids);
 		examined_relids = lappendi(examined_relids, currentrel);
 		currentchildren = find_inheritance_children(currentrel);
+
 		/*
-		 * Add to the queue only those children not already seen.
-		 * This could probably be simplified to a plain nconc,
-		 * because our inheritance relationships should always be a
-		 * strict tree, no?  Should never find any matches, ISTM...
+		 * Add to the queue only those children not already seen. This
+		 * could probably be simplified to a plain nconc, because our
+		 * inheritance relationships should always be a strict tree, no?
+		 * Should never find any matches, ISTM...
 		 */
 		currentchildren = set_differencei(currentchildren, examined_relids);
 		unexamined_relids = LispUnioni(unexamined_relids, currentchildren);
@@ -477,7 +488,7 @@ new_rangetable_entry(Oid new_relid, RangeTblEntry *old_entry)
  *	  'old_relid' in 'parsetree' with the attribute numbers from
  *	  'new_relid'.
  *
- * The parsetree is MODIFIED IN PLACE.  This is OK only because
+ * The parsetree is MODIFIED IN PLACE.	This is OK only because
  * plan_inherit_query made a copy of the tree for us to hack upon.
  */
 static void
@@ -495,6 +506,7 @@ fix_parsetree_attnums(Index rt_index,
 	context.old_relid = old_relid;
 	context.new_relid = new_relid;
 	context.sublevels_up = 0;
+
 	/*
 	 * We must scan both the targetlist and qual, but we know the
 	 * havingQual is empty, so we can ignore it.
@@ -504,7 +516,7 @@ fix_parsetree_attnums(Index rt_index,
 }
 
 /*
- * Adjust varnos for child tables.  This routine makes it possible for
+ * Adjust varnos for child tables.	This routine makes it possible for
  * child tables to have different column positions for the "same" attribute
  * as a parent, which helps ALTER TABLE ADD COLUMN.  Unfortunately this isn't
  * nearly enough to make it work transparently; there are other places where
@@ -513,8 +525,8 @@ fix_parsetree_attnums(Index rt_index,
  * ALTER TABLE...
  */
 static bool
-fix_parsetree_attnums_walker (Node *node,
-							  fix_parsetree_attnums_context *context)
+fix_parsetree_attnums_walker(Node *node,
+							 fix_parsetree_attnums_context *context)
 {
 	if (node == NULL)
 		return false;
@@ -534,9 +546,10 @@ fix_parsetree_attnums_walker (Node *node,
 	}
 	if (IsA(node, SubLink))
 	{
+
 		/*
-		 * Standard expression_tree_walker will not recurse into subselect,
-		 * but here we must do so.
+		 * Standard expression_tree_walker will not recurse into
+		 * subselect, but here we must do so.
 		 */
 		SubLink    *sub = (SubLink *) node;
 
@@ -588,9 +601,9 @@ make_append(List *appendplans,
 	node->plan.plan_width = 0;
 	foreach(subnode, appendplans)
 	{
-		Plan   *subplan = (Plan *) lfirst(subnode);
+		Plan	   *subplan = (Plan *) lfirst(subnode);
 
-		if (subnode == appendplans)	/* first node? */
+		if (subnode == appendplans)		/* first node? */
 			node->plan.startup_cost = subplan->startup_cost;
 		node->plan.total_cost += subplan->total_cost;
 		node->plan.plan_rows += subplan->plan_rows;
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c
index d429db93a03cdb384cc5b334d656d12f5ed4b8a7..7ddbe4190cc0ca28419d368c22033b674cdbd22f 100644
--- a/src/backend/optimizer/util/clauses.c
+++ b/src/backend/optimizer/util/clauses.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.64 2000/04/04 01:21:46 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.65 2000/04/12 17:15:24 momjian Exp $
  *
  * HISTORY
  *	  AUTHOR			DATE			MAJOR EVENT
@@ -46,9 +46,9 @@ static bool pull_agg_clause_walker(Node *node, List **listptr);
 static bool contain_subplans_walker(Node *node, void *context);
 static bool pull_subplans_walker(Node *node, List **listptr);
 static bool check_subplans_for_ungrouped_vars_walker(Node *node,
-													 Query *context);
-static int is_single_func(Node *node);
-static Node *eval_const_expressions_mutator (Node *node, void *context);
+										 Query *context);
+static int	is_single_func(Node *node);
+static Node *eval_const_expressions_mutator(Node *node, void *context);
 static Expr *simplify_op_or_func(Expr *expr, List *args);
 
 
@@ -340,18 +340,19 @@ make_ands_explicit(List *andclauses)
 List *
 make_ands_implicit(Expr *clause)
 {
+
 	/*
 	 * NB: because the parser sets the qual field to NULL in a query that
 	 * has no WHERE clause, we must consider a NULL input clause as TRUE,
-	 * even though one might more reasonably think it FALSE.  Grumble.
-	 * If this causes trouble, consider changing the parser's behavior.
+	 * even though one might more reasonably think it FALSE.  Grumble. If
+	 * this causes trouble, consider changing the parser's behavior.
 	 */
 	if (clause == NULL)
 		return NIL;				/* NULL -> NIL list == TRUE */
 	else if (and_clause((Node *) clause))
 		return clause->args;
 	else if (IsA(clause, Const) &&
-			 ! ((Const *) clause)->constisnull &&
+			 !((Const *) clause)->constisnull &&
 			 DatumGetInt32(((Const *) clause)->constvalue))
 		return NIL;				/* constant TRUE input -> NIL list */
 	else
@@ -381,7 +382,8 @@ contain_agg_clause_walker(Node *node, void *context)
 	if (node == NULL)
 		return false;
 	if (IsA(node, Aggref))
-		return true;			/* abort the tree traversal and return true */
+		return true;			/* abort the tree traversal and return
+								 * true */
 	return expression_tree_walker(node, contain_agg_clause_walker, context);
 }
 
@@ -411,12 +413,14 @@ pull_agg_clause_walker(Node *node, List **listptr)
 	if (IsA(node, Aggref))
 	{
 		*listptr = lappend(*listptr, node);
+
 		/*
 		 * Complain if the aggregate's argument contains any aggregates;
 		 * nested agg functions are semantically nonsensical.
 		 */
 		if (contain_agg_clause(((Aggref *) node)->target))
 			elog(ERROR, "Aggregate function calls may not be nested");
+
 		/*
 		 * Having checked that, we need not recurse into the argument.
 		 */
@@ -454,7 +458,8 @@ contain_subplans_walker(Node *node, void *context)
 	if (node == NULL)
 		return false;
 	if (is_subplan(node) || IsA(node, SubLink))
-		return true;			/* abort the tree traversal and return true */
+		return true;			/* abort the tree traversal and return
+								 * true */
 	return expression_tree_walker(node, contain_subplans_walker, context);
 }
 
@@ -462,7 +467,7 @@ contain_subplans_walker(Node *node, void *context)
  * pull_subplans
  *	  Recursively pulls all subplans from an expression tree.
  *
- *	  Returns list of subplan nodes found.  Note the nodes themselves are not
+ *	  Returns list of subplan nodes found.	Note the nodes themselves are not
  *	  copied, only referenced.
  */
 List *
@@ -507,7 +512,11 @@ void
 check_subplans_for_ungrouped_vars(Node *clause,
 								  Query *query)
 {
-	/* No special setup needed; context for walker is just the Query pointer */
+
+	/*
+	 * No special setup needed; context for walker is just the Query
+	 * pointer
+	 */
 	check_subplans_for_ungrouped_vars_walker(clause, query);
 }
 
@@ -517,17 +526,19 @@ check_subplans_for_ungrouped_vars_walker(Node *node,
 {
 	if (node == NULL)
 		return false;
+
 	/*
-	 * We can ignore Vars other than in subplan args lists,
-	 * since the parser already checked 'em.
+	 * We can ignore Vars other than in subplan args lists, since the
+	 * parser already checked 'em.
 	 */
 	if (is_subplan(node))
 	{
+
 		/*
 		 * The args list of the subplan node represents attributes from
 		 * outside passed into the sublink.
 		 */
-		List	*t;
+		List	   *t;
 
 		foreach(t, ((Expr *) node)->args)
 		{
@@ -539,10 +550,10 @@ check_subplans_for_ungrouped_vars_walker(Node *node,
 			/*
 			 * We do not care about args that are not local variables;
 			 * params or outer-level vars are not our responsibility to
-			 * check.  (The outer-level query passing them to us needs
-			 * to worry, instead.)
+			 * check.  (The outer-level query passing them to us needs to
+			 * worry, instead.)
 			 */
-			if (! IsA(thisarg, Var))
+			if (!IsA(thisarg, Var))
 				continue;
 			var = (Var *) thisarg;
 			if (var->varlevelsup > 0)
@@ -554,8 +565,8 @@ check_subplans_for_ungrouped_vars_walker(Node *node,
 			contained_in_group_clause = false;
 			foreach(gl, context->groupClause)
 			{
-				GroupClause	   *gcl = lfirst(gl);
-				Node		   *groupexpr;
+				GroupClause *gcl = lfirst(gl);
+				Node	   *groupexpr;
 
 				groupexpr = get_sortgroupclause_expr(gcl,
 													 context->targetList);
@@ -569,14 +580,14 @@ check_subplans_for_ungrouped_vars_walker(Node *node,
 			if (!contained_in_group_clause)
 			{
 				/* Found an ungrouped argument.  Complain. */
-				RangeTblEntry  *rte;
-				char		   *attname;
+				RangeTblEntry *rte;
+				char	   *attname;
 
 				Assert(var->varno > 0 &&
 					   var->varno <= length(context->rtable));
 				rte = rt_fetch(var->varno, context->rtable);
 				attname = get_attname(rte->relid, var->varattno);
-				if (! attname)
+				if (!attname)
 					elog(ERROR, "cache lookup of attribute %d in relation %u failed",
 						 var->varattno, rte->relid);
 				elog(ERROR, "Sub-SELECT uses un-GROUPed attribute %s.%s from outer query",
@@ -585,7 +596,7 @@ check_subplans_for_ungrouped_vars_walker(Node *node,
 		}
 	}
 	return expression_tree_walker(node,
-								  check_subplans_for_ungrouped_vars_walker,
+								check_subplans_for_ungrouped_vars_walker,
 								  (void *) context);
 }
 
@@ -697,7 +708,7 @@ NumRelids(Node *clause)
  *		is referenced in the clause).  The routine checks that the
  *		expression is of the form (var op something) or (something op var)
  *		where the var is an attribute of the specified relation, or
- *		a function of a var of the specified relation.  If so, it
+ *		a function of a var of the specified relation.	If so, it
  *		returns the following info:
  *			the found relation number (same as targetrelid unless that is 0)
  *			the found var number (or InvalidAttrNumber if a function)
@@ -707,7 +718,7 @@ NumRelids(Node *clause)
  *		specifically 0 for the relid and attno, 0 for the constant value.
  *
  *		Note that negative attno values are *not* invalid, but represent
- *		system attributes such as OID.  It's sufficient to check for relid=0
+ *		system attributes such as OID.	It's sufficient to check for relid=0
  *		to determine whether the routine succeeded.
  */
 void
@@ -785,15 +796,13 @@ default_results:
 		*flag |= SEL_CONSTANT;
 	}
 	else
-	{
 		*constval = 0;
-	}
 }
 
 /*
  * is_single_func
- *   If the given expression is a function of a single relation,
- *   return the relation number; else return 0
+ *	 If the given expression is a function of a single relation,
+ *	 return the relation number; else return 0
  */
 static int
 is_single_func(Node *node)
@@ -804,7 +813,7 @@ is_single_func(Node *node)
 
 		if (length(varnos) == 1)
 		{
-			int		funcvarno = lfirsti(varnos);
+			int			funcvarno = lfirsti(varnos);
 
 			freeList(varnos);
 			return funcvarno;
@@ -922,7 +931,7 @@ CommuteClause(Expr *clause)
  * expression tree, for example "2 + 2" => "4".  More interestingly,
  * we can reduce certain boolean expressions even when they contain
  * non-constant subexpressions: "x OR true" => "true" no matter what
- * the subexpression x is.  (XXX We assume that no such subexpression
+ * the subexpression x is.	(XXX We assume that no such subexpression
  * will have important side-effects, which is not necessarily a good
  * assumption in the presence of user-defined functions; do we need a
  * pg_proc flag that prevents discarding the execution of a function?)
@@ -954,7 +963,7 @@ eval_const_expressions(Node *node)
 }
 
 static Node *
-eval_const_expressions_mutator (Node *node, void *context)
+eval_const_expressions_mutator(Node *node, void *context)
 {
 	if (node == NULL)
 		return NULL;
@@ -963,21 +972,22 @@ eval_const_expressions_mutator (Node *node, void *context)
 		Expr	   *expr = (Expr *) node;
 		List	   *args;
 		Const	   *const_input;
-		Expr       *newexpr;
+		Expr	   *newexpr;
 
 		/*
 		 * Reduce constants in the Expr's arguments.  We know args is
-		 * either NIL or a List node, so we can call expression_tree_mutator
-		 * directly rather than recursing to self.
+		 * either NIL or a List node, so we can call
+		 * expression_tree_mutator directly rather than recursing to self.
 		 */
 		args = (List *) expression_tree_mutator((Node *) expr->args,
-												eval_const_expressions_mutator,
+										  eval_const_expressions_mutator,
 												(void *) context);
 
 		switch (expr->opType)
 		{
 			case OP_EXPR:
 			case FUNC_EXPR:
+
 				/*
 				 * Code for op/func case is pretty bulky, so split it out
 				 * as a separate function.
@@ -985,123 +995,131 @@ eval_const_expressions_mutator (Node *node, void *context)
 				newexpr = simplify_op_or_func(expr, args);
 				if (newexpr)	/* successfully simplified it */
 					return (Node *) newexpr;
-				/* else fall out to build new Expr node with simplified args */
-				break;
-			case OR_EXPR:
-			{
+
 				/*
-				 * OR arguments are handled as follows:
-				 *	non constant: keep
-				 *  FALSE: drop (does not affect result)
-				 *	TRUE: force result to TRUE
-				 *	NULL: keep only one
-				 * We keep one NULL input because ExecEvalOr returns
-				 * NULL when no input is TRUE and at least one is NULL.
+				 * else fall out to build new Expr node with simplified
+				 * args
 				 */
-				List	   *newargs = NIL;
-				List	   *arg;
-				bool		haveNull = false;
-				bool		forceTrue = false;
-
-                foreach(arg, args)
+				break;
+			case OR_EXPR:
 				{
-					if (! IsA(lfirst(arg), Const))
+
+					/*
+					 * OR arguments are handled as follows: non constant:
+					 * keep FALSE: drop (does not affect result) TRUE:
+					 * force result to TRUE NULL: keep only one We keep
+					 * one NULL input because ExecEvalOr returns NULL when
+					 * no input is TRUE and at least one is NULL.
+					 */
+					List	   *newargs = NIL;
+					List	   *arg;
+					bool		haveNull = false;
+					bool		forceTrue = false;
+
+					foreach(arg, args)
 					{
-						newargs = lappend(newargs, lfirst(arg));
-						continue;
+						if (!IsA(lfirst(arg), Const))
+						{
+							newargs = lappend(newargs, lfirst(arg));
+							continue;
+						}
+						const_input = (Const *) lfirst(arg);
+						if (const_input->constisnull)
+							haveNull = true;
+						else if (DatumGetInt32(const_input->constvalue))
+							forceTrue = true;
+						/* otherwise, we can drop the constant-false input */
 					}
-					const_input = (Const *) lfirst(arg);
-					if (const_input->constisnull)
-						haveNull = true;
-					else if (DatumGetInt32(const_input->constvalue))
-						forceTrue = true;
-					/* otherwise, we can drop the constant-false input */
+
+					/*
+					 * We could return TRUE before falling out of the
+					 * loop, but this coding method will be easier to
+					 * adapt if we ever add a notion of non-removable
+					 * functions. We'd need to check all the inputs for
+					 * non-removability.
+					 */
+					if (forceTrue)
+						return MAKEBOOLCONST(true, false);
+					if (haveNull)
+						newargs = lappend(newargs, MAKEBOOLCONST(false, true));
+					/* If all the inputs are FALSE, result is FALSE */
+					if (newargs == NIL)
+						return MAKEBOOLCONST(false, false);
+					/* If only one nonconst-or-NULL input, it's the result */
+					if (lnext(newargs) == NIL)
+						return (Node *) lfirst(newargs);
+					/* Else we still need an OR node */
+					return (Node *) make_orclause(newargs);
 				}
-				/*
-				 * We could return TRUE before falling out of the loop,
-				 * but this coding method will be easier to adapt if
-				 * we ever add a notion of non-removable functions.
-				 * We'd need to check all the inputs for non-removability.
-				 */
-				if (forceTrue)
-					return MAKEBOOLCONST(true, false);
-				if (haveNull)
-					newargs = lappend(newargs, MAKEBOOLCONST(false, true));
-				/* If all the inputs are FALSE, result is FALSE */
-				if (newargs == NIL)
-					return MAKEBOOLCONST(false, false);
-				/* If only one nonconst-or-NULL input, it's the result */
-				if (lnext(newargs) == NIL)
-					return (Node *) lfirst(newargs);
-				/* Else we still need an OR node */
-				return (Node *) make_orclause(newargs);
-			}
 			case AND_EXPR:
-			{
-				/*
-				 * AND arguments are handled as follows:
-				 *	non constant: keep
-				 *  TRUE: drop (does not affect result)
-				 *	FALSE: force result to FALSE
-				 *	NULL: keep only one
-				 * We keep one NULL input because ExecEvalAnd returns
-				 * NULL when no input is FALSE and at least one is NULL.
-				 */
-				List	   *newargs = NIL;
-				List	   *arg;
-				bool		haveNull = false;
-				bool		forceFalse = false;
-
-                foreach(arg, args)
 				{
-					if (! IsA(lfirst(arg), Const))
+
+					/*
+					 * AND arguments are handled as follows: non constant:
+					 * keep TRUE: drop (does not affect result) FALSE:
+					 * force result to FALSE NULL: keep only one We keep
+					 * one NULL input because ExecEvalAnd returns NULL
+					 * when no input is FALSE and at least one is NULL.
+					 */
+					List	   *newargs = NIL;
+					List	   *arg;
+					bool		haveNull = false;
+					bool		forceFalse = false;
+
+					foreach(arg, args)
 					{
-						newargs = lappend(newargs, lfirst(arg));
-						continue;
+						if (!IsA(lfirst(arg), Const))
+						{
+							newargs = lappend(newargs, lfirst(arg));
+							continue;
+						}
+						const_input = (Const *) lfirst(arg);
+						if (const_input->constisnull)
+							haveNull = true;
+						else if (!DatumGetInt32(const_input->constvalue))
+							forceFalse = true;
+						/* otherwise, we can drop the constant-true input */
 					}
-					const_input = (Const *) lfirst(arg);
-					if (const_input->constisnull)
-						haveNull = true;
-					else if (! DatumGetInt32(const_input->constvalue))
-						forceFalse = true;
-					/* otherwise, we can drop the constant-true input */
+
+					/*
+					 * We could return FALSE before falling out of the
+					 * loop, but this coding method will be easier to
+					 * adapt if we ever add a notion of non-removable
+					 * functions. We'd need to check all the inputs for
+					 * non-removability.
+					 */
+					if (forceFalse)
+						return MAKEBOOLCONST(false, false);
+					if (haveNull)
+						newargs = lappend(newargs, MAKEBOOLCONST(false, true));
+					/* If all the inputs are TRUE, result is TRUE */
+					if (newargs == NIL)
+						return MAKEBOOLCONST(true, false);
+					/* If only one nonconst-or-NULL input, it's the result */
+					if (lnext(newargs) == NIL)
+						return (Node *) lfirst(newargs);
+					/* Else we still need an AND node */
+					return (Node *) make_andclause(newargs);
 				}
-				/*
-				 * We could return FALSE before falling out of the loop,
-				 * but this coding method will be easier to adapt if
-				 * we ever add a notion of non-removable functions.
-				 * We'd need to check all the inputs for non-removability.
-				 */
-				if (forceFalse)
-					return MAKEBOOLCONST(false, false);
-				if (haveNull)
-					newargs = lappend(newargs, MAKEBOOLCONST(false, true));
-				/* If all the inputs are TRUE, result is TRUE */
-				if (newargs == NIL)
-					return MAKEBOOLCONST(true, false);
-				/* If only one nonconst-or-NULL input, it's the result */
-				if (lnext(newargs) == NIL)
-					return (Node *) lfirst(newargs);
-				/* Else we still need an AND node */
-				return (Node *) make_andclause(newargs);
-			}
 			case NOT_EXPR:
 				Assert(length(args) == 1);
-				if (! IsA(lfirst(args), Const))
+				if (!IsA(lfirst(args), Const))
 					break;
 				const_input = (Const *) lfirst(args);
 				/* NOT NULL => NULL */
 				if (const_input->constisnull)
 					return MAKEBOOLCONST(false, true);
 				/* otherwise pretty easy */
-				return MAKEBOOLCONST(! DatumGetInt32(const_input->constvalue),
+				return MAKEBOOLCONST(!DatumGetInt32(const_input->constvalue),
 									 false);
 			case SUBPLAN_EXPR:
+
 				/*
 				 * Safety measure per notes at head of this routine:
-				 * return a SubPlan unchanged.  Too late to do anything
+				 * return a SubPlan unchanged.	Too late to do anything
 				 * with it.  The arglist simplification above was wasted
-				 * work (the list probably only contains Var nodes anyway).
+				 * work (the list probably only contains Var nodes
+				 * anyway).
 				 */
 				return (Node *) expr;
 			default:
@@ -1112,25 +1130,26 @@ eval_const_expressions_mutator (Node *node, void *context)
 
 		/*
 		 * If we break out of the above switch on opType, then the
-		 * expression cannot be simplified any further, so build
-		 * and return a replacement Expr node using the
-		 * possibly-simplified arguments and the original oper node.
-		 * Can't use make_clause() here because we want to be sure
-		 * the typeOid field is preserved...
+		 * expression cannot be simplified any further, so build and
+		 * return a replacement Expr node using the possibly-simplified
+		 * arguments and the original oper node. Can't use make_clause()
+		 * here because we want to be sure the typeOid field is
+		 * preserved...
 		 */
 		newexpr = makeNode(Expr);
-        newexpr->typeOid = expr->typeOid;
-        newexpr->opType = expr->opType;
-        newexpr->oper = expr->oper;
-        newexpr->args = args;
-        return (Node *) newexpr;
+		newexpr->typeOid = expr->typeOid;
+		newexpr->opType = expr->opType;
+		newexpr->oper = expr->oper;
+		newexpr->args = args;
+		return (Node *) newexpr;
 	}
 	if (IsA(node, RelabelType))
 	{
+
 		/*
 		 * If we can simplify the input to a constant, then we don't need
-		 * the RelabelType node anymore: just change the type field of
-		 * the Const node.  Otherwise, copy the RelabelType node.
+		 * the RelabelType node anymore: just change the type field of the
+		 * Const node.	Otherwise, copy the RelabelType node.
 		 */
 		RelabelType *relabel = (RelabelType *) node;
 		Node	   *arg;
@@ -1138,13 +1157,15 @@ eval_const_expressions_mutator (Node *node, void *context)
 		arg = eval_const_expressions_mutator(relabel->arg, context);
 		if (arg && IsA(arg, Const))
 		{
-			Const  *con = (Const *) arg;
+			Const	   *con = (Const *) arg;
 
 			con->consttype = relabel->resulttype;
+
 			/*
 			 * relabel's resulttypmod is discarded, which is OK for now;
 			 * if the type actually needs a runtime length coercion then
-			 * there should be a function call to do it just above this node.
+			 * there should be a function call to do it just above this
+			 * node.
 			 */
 			return (Node *) con;
 		}
@@ -1160,15 +1181,15 @@ eval_const_expressions_mutator (Node *node, void *context)
 	}
 	if (IsA(node, CaseExpr))
 	{
+
 		/*
-		 * CASE expressions can be simplified if there are constant condition
-		 * clauses:
-		 *	FALSE (or NULL): drop the alternative
-		 *	TRUE: drop all remaining alternatives
-		 * If the first non-FALSE alternative is a constant TRUE, we can
-		 * simplify the entire CASE to that alternative's expression.
-		 * If there are no non-FALSE alternatives, we simplify the entire
-		 * CASE to the default result (ELSE result).
+		 * CASE expressions can be simplified if there are constant
+		 * condition clauses: FALSE (or NULL): drop the alternative TRUE:
+		 * drop all remaining alternatives If the first non-FALSE
+		 * alternative is a constant TRUE, we can simplify the entire CASE
+		 * to that alternative's expression. If there are no non-FALSE
+		 * alternatives, we simplify the entire CASE to the default result
+		 * (ELSE result).
 		 */
 		CaseExpr   *caseexpr = (CaseExpr *) node;
 		CaseExpr   *newcase;
@@ -1181,26 +1202,29 @@ eval_const_expressions_mutator (Node *node, void *context)
 		{
 			/* Simplify this alternative's condition and result */
 			CaseWhen   *casewhen = (CaseWhen *)
-				expression_tree_mutator((Node *) lfirst(arg),
-										eval_const_expressions_mutator,
-										(void *) context);
+			expression_tree_mutator((Node *) lfirst(arg),
+									eval_const_expressions_mutator,
+									(void *) context);
+
 			Assert(IsA(casewhen, CaseWhen));
 			if (casewhen->expr == NULL ||
-				! IsA(casewhen->expr, Const))
+				!IsA(casewhen->expr, Const))
 			{
 				newargs = lappend(newargs, casewhen);
 				continue;
 			}
 			const_input = (Const *) casewhen->expr;
 			if (const_input->constisnull ||
-				! DatumGetInt32(const_input->constvalue))
+				!DatumGetInt32(const_input->constvalue))
 				continue;		/* drop alternative with FALSE condition */
+
 			/*
-			 * Found a TRUE condition.  If it's the first (un-dropped)
+			 * Found a TRUE condition.	If it's the first (un-dropped)
 			 * alternative, the CASE reduces to just this alternative.
 			 */
 			if (newargs == NIL)
 				return casewhen->result;
+
 			/*
 			 * Otherwise, add it to the list, and drop all the rest.
 			 */
@@ -1211,7 +1235,11 @@ eval_const_expressions_mutator (Node *node, void *context)
 		/* Simplify the default result */
 		defresult = eval_const_expressions_mutator(caseexpr->defresult,
 												   context);
-		/* If no non-FALSE alternatives, CASE reduces to the default result */
+
+		/*
+		 * If no non-FALSE alternatives, CASE reduces to the default
+		 * result
+		 */
 		if (newargs == NIL)
 			return defresult;
 		/* Otherwise we need a new CASE node */
@@ -1224,21 +1252,21 @@ eval_const_expressions_mutator (Node *node, void *context)
 	}
 	if (IsA(node, Iter))
 	{
+
 		/*
-		 * The argument of an Iter is normally a function call.
-		 * We must not try to eliminate the function, but we
-		 * can try to simplify its arguments.  If, by chance,
-		 * the arg is NOT a function then we go ahead and try to
-		 * simplify it (by falling into expression_tree_mutator).
-		 * Is that the right thing?
+		 * The argument of an Iter is normally a function call. We must
+		 * not try to eliminate the function, but we can try to simplify
+		 * its arguments.  If, by chance, the arg is NOT a function then
+		 * we go ahead and try to simplify it (by falling into
+		 * expression_tree_mutator). Is that the right thing?
 		 */
 		Iter	   *iter = (Iter *) node;
 
 		if (is_funcclause(iter->iterexpr))
 		{
-			Expr   *func = (Expr *) iter->iterexpr;
-			Expr   *newfunc;
-			Iter   *newiter;
+			Expr	   *func = (Expr *) iter->iterexpr;
+			Expr	   *newfunc;
+			Iter	   *newiter;
 
 			newfunc = makeNode(Expr);
 			newfunc->typeOid = func->typeOid;
@@ -1254,12 +1282,13 @@ eval_const_expressions_mutator (Node *node, void *context)
 			return (Node *) newiter;
 		}
 	}
+
 	/*
 	 * For any node type not handled above, we recurse using
-	 * expression_tree_mutator, which will copy the node unchanged
-	 * but try to simplify its arguments (if any) using this routine.
-	 * For example: we cannot eliminate an ArrayRef node, but we
-	 * might be able to simplify constant expressions in its subscripts.
+	 * expression_tree_mutator, which will copy the node unchanged but try
+	 * to simplify its arguments (if any) using this routine. For example:
+	 * we cannot eliminate an ArrayRef node, but we might be able to
+	 * simplify constant expressions in its subscripts.
 	 */
 	return expression_tree_mutator(node, eval_const_expressions_mutator,
 								   (void *) context);
@@ -1289,31 +1318,32 @@ simplify_op_or_func(Expr *expr, List *args)
 	HeapTuple	func_tuple;
 	Form_pg_proc funcform;
 	Type		resultType;
-	Expr       *newexpr;
+	Expr	   *newexpr;
 	Datum		const_val;
 	bool		const_is_null;
 	bool		isDone;
 
 	/*
-	 * For an operator or function, we cannot simplify unless all the inputs
-	 * are constants.  (XXX possible future improvement: if the op/func is
-	 * strict and at least one input is NULL, we could simplify to NULL.
-	 * But we do not currently have any way to know if the op/func is strict
-	 * or not.  For now, a NULL input is treated the same as any other
-	 * constant node.)
+	 * For an operator or function, we cannot simplify unless all the
+	 * inputs are constants.  (XXX possible future improvement: if the
+	 * op/func is strict and at least one input is NULL, we could simplify
+	 * to NULL. But we do not currently have any way to know if the
+	 * op/func is strict or not.  For now, a NULL input is treated the
+	 * same as any other constant node.)
 	 */
 	foreach(arg, args)
 	{
-		if (! IsA(lfirst(arg), Const))
+		if (!IsA(lfirst(arg), Const))
 			return NULL;
 	}
+
 	/*
-	 * Get the function procedure's OID and look to see
-	 * whether it is marked proiscachable.
+	 * Get the function procedure's OID and look to see whether it is
+	 * marked proiscachable.
 	 */
 	if (expr->opType == OP_EXPR)
 	{
-		Oper   *oper = (Oper *) expr->oper;
+		Oper	   *oper = (Oper *) expr->oper;
 
 		replace_opid(oper);		/* OK to scribble on input to this extent */
 		funcid = oper->opid;
@@ -1321,7 +1351,7 @@ simplify_op_or_func(Expr *expr, List *args)
 	}
 	else
 	{
-		Func   *func = (Func *) expr->oper;
+		Func	   *func = (Func *) expr->oper;
 
 		funcid = func->funcid;
 		result_typeid = func->functype;
@@ -1333,21 +1363,23 @@ simplify_op_or_func(Expr *expr, List *args)
 	if (!HeapTupleIsValid(func_tuple))
 		elog(ERROR, "Function OID %u does not exist", funcid);
 	funcform = (Form_pg_proc) GETSTRUCT(func_tuple);
-	if (! funcform->proiscachable)
+	if (!funcform->proiscachable)
 		return NULL;
+
 	/*
 	 * Also check to make sure it doesn't return a set.
 	 */
 	if (funcform->proretset)
 		return NULL;
+
 	/*
 	 * OK, looks like we can simplify this operator/function.
 	 *
 	 * We use the executor's routine ExecEvalExpr() to avoid duplication of
 	 * code and ensure we get the same result as the executor would get.
 	 *
-	 * Build a new Expr node containing the already-simplified arguments.
-	 * The only other setup needed here is the replace_opid() that we already
+	 * Build a new Expr node containing the already-simplified arguments. The
+	 * only other setup needed here is the replace_opid() that we already
 	 * did for the OP_EXPR case.
 	 */
 	newexpr = makeNode(Expr);
@@ -1355,21 +1387,23 @@ simplify_op_or_func(Expr *expr, List *args)
 	newexpr->opType = expr->opType;
 	newexpr->oper = expr->oper;
 	newexpr->args = args;
+
 	/*
 	 * It is OK to pass econtext = NULL because none of the ExecEvalExpr()
 	 * code used in this situation will use econtext.  That might seem
-	 * fortuitous, but it's not so unreasonable --- a constant expression does
-	 * not depend on context, by definition, n'est ce pas?
+	 * fortuitous, but it's not so unreasonable --- a constant expression
+	 * does not depend on context, by definition, n'est ce pas?
 	 */
 	const_val = ExecEvalExpr((Node *) newexpr, NULL,
 							 &const_is_null, &isDone);
 	Assert(isDone);				/* if this isn't set, we blew it... */
 	pfree(newexpr);
+
 	/*
 	 * Make the constant result node.
 	 *
-	 * XXX would it be better to take the result type from the
-	 * pg_proc tuple, rather than the Oper or Func node?
+	 * XXX would it be better to take the result type from the pg_proc tuple,
+	 * rather than the Oper or Func node?
 	 */
 	resultType = typeidType(result_typeid);
 	return (Expr *) makeConst(result_typeid, typeLen(resultType),
@@ -1426,8 +1460,8 @@ simplify_op_or_func(Expr *expr, List *args)
  *
  * The walker routine should return "false" to continue the tree walk, or
  * "true" to abort the walk and immediately return "true" to the top-level
- * caller.  This can be used to short-circuit the traversal if the walker
- * has found what it came for.  "false" is returned to the top-level caller
+ * caller.	This can be used to short-circuit the traversal if the walker
+ * has found what it came for.	"false" is returned to the top-level caller
  * iff no invocation of the walker returned "true".
  *
  * The node types handled by expression_tree_walker include all those
@@ -1454,16 +1488,16 @@ simplify_op_or_func(Expr *expr, List *args)
  */
 
 bool
-expression_tree_walker(Node *node, bool (*walker) (), void *context)
+			expression_tree_walker(Node *node, bool (*walker) (), void *context)
 {
 	List	   *temp;
 
 	/*
-	 * The walker has already visited the current node,
-	 * and so we need only recurse into any sub-nodes it has.
+	 * The walker has already visited the current node, and so we need
+	 * only recurse into any sub-nodes it has.
 	 *
-	 * We assume that the walker is not interested in List nodes per se,
-	 * so when we expect a List we just recurse directly to self without
+	 * We assume that the walker is not interested in List nodes per se, so
+	 * when we expect a List we just recurse directly to self without
 	 * bothering to call the walker.
 	 */
 	if (node == NULL)
@@ -1478,7 +1512,7 @@ expression_tree_walker(Node *node, bool (*walker) (), void *context)
 			break;
 		case T_Expr:
 			{
-				Expr   *expr = (Expr *) node;
+				Expr	   *expr = (Expr *) node;
 
 				if (expr->opType == SUBPLAN_EXPR)
 				{
@@ -1500,6 +1534,7 @@ expression_tree_walker(Node *node, bool (*walker) (), void *context)
 		case T_ArrayRef:
 			{
 				ArrayRef   *aref = (ArrayRef *) node;
+
 				/* recurse directly for upper/lower array index lists */
 				if (expression_tree_walker((Node *) aref->refupperindexpr,
 										   walker, context))
@@ -1519,10 +1554,12 @@ expression_tree_walker(Node *node, bool (*walker) (), void *context)
 		case T_CaseExpr:
 			{
 				CaseExpr   *caseexpr = (CaseExpr *) node;
+
 				/* we assume walker doesn't care about CaseWhens, either */
 				foreach(temp, caseexpr->args)
 				{
 					CaseWhen   *when = (CaseWhen *) lfirst(temp);
+
 					Assert(IsA(when, CaseWhen));
 					if (walker(when->expr, context))
 						return true;
@@ -1538,12 +1575,14 @@ expression_tree_walker(Node *node, bool (*walker) (), void *context)
 			break;
 		case T_SubLink:
 			{
-				SubLink   *sublink = (SubLink *) node;
+				SubLink    *sublink = (SubLink *) node;
 
-				/* If the SubLink has already been processed by subselect.c,
-				 * it will have lefthand=NIL, and we only need to look at
-				 * the oper list.  Otherwise we only need to look at lefthand
-				 * (the Oper nodes in the oper list are deemed uninteresting).
+				/*
+				 * If the SubLink has already been processed by
+				 * subselect.c, it will have lefthand=NIL, and we only
+				 * need to look at the oper list.  Otherwise we only need
+				 * to look at lefthand (the Oper nodes in the oper list
+				 * are deemed uninteresting).
 				 */
 				if (sublink->lefthand)
 					return walker((Node *) sublink->lefthand, context);
@@ -1628,18 +1667,19 @@ expression_tree_walker(Node *node, bool (*walker) (), void *context)
  */
 
 Node *
-expression_tree_mutator(Node *node, Node * (*mutator) (), void *context)
+			expression_tree_mutator(Node *node, Node *(*mutator) (), void *context)
 {
+
 	/*
-	 * The mutator has already decided not to modify the current node,
-	 * but we must call the mutator for any sub-nodes.
+	 * The mutator has already decided not to modify the current node, but
+	 * we must call the mutator for any sub-nodes.
 	 */
 
 #define FLATCOPY(newnode, node, nodetype)  \
 	( (newnode) = makeNode(nodetype), \
 	  memcpy((newnode), (node), sizeof(nodetype)) )
 
-#define CHECKFLATCOPY(newnode, node, nodetype)  \
+#define CHECKFLATCOPY(newnode, node, nodetype)	\
 	( AssertMacro(IsA((node), nodetype)), \
 	  (newnode) = makeNode(nodetype), \
 	  memcpy((newnode), (node), sizeof(nodetype)) )
@@ -1659,31 +1699,41 @@ expression_tree_mutator(Node *node, Node * (*mutator) (), void *context)
 			return (Node *) copyObject(node);
 		case T_Expr:
 			{
-				Expr   *expr = (Expr *) node;
-				Expr   *newnode;
+				Expr	   *expr = (Expr *) node;
+				Expr	   *newnode;
 
 				FLATCOPY(newnode, expr, Expr);
 
 				if (expr->opType == SUBPLAN_EXPR)
 				{
-					SubLink	   *oldsublink = ((SubPlan *) expr->oper)->sublink;
-					SubPlan	   *newsubplan;
+					SubLink    *oldsublink = ((SubPlan *) expr->oper)->sublink;
+					SubPlan    *newsubplan;
 
 					/* flat-copy the oper node, which is a SubPlan */
 					CHECKFLATCOPY(newsubplan, expr->oper, SubPlan);
 					newnode->oper = (Node *) newsubplan;
 					/* likewise its SubLink node */
 					CHECKFLATCOPY(newsubplan->sublink, oldsublink, SubLink);
-					/* transform args list (params to be passed to subplan) */
+
+					/*
+					 * transform args list (params to be passed to
+					 * subplan)
+					 */
 					MUTATE(newnode->args, expr->args, List *);
 					/* transform sublink's oper list as well */
-					MUTATE(newsubplan->sublink->oper, oldsublink->oper, List*);
-					/* but not the subplan itself, which is referenced as-is */
+					MUTATE(newsubplan->sublink->oper, oldsublink->oper, List *);
+
+					/*
+					 * but not the subplan itself, which is referenced
+					 * as-is
+					 */
 				}
 				else
 				{
-					/* for other Expr node types, just transform args list,
-					 * linking to original oper node (OK?)
+
+					/*
+					 * for other Expr node types, just transform args
+					 * list, linking to original oper node (OK?)
 					 */
 					MUTATE(newnode->args, expr->args, List *);
 				}
@@ -1692,8 +1742,8 @@ expression_tree_mutator(Node *node, Node * (*mutator) (), void *context)
 			break;
 		case T_Aggref:
 			{
-				Aggref   *aggref = (Aggref *) node;
-				Aggref   *newnode;
+				Aggref	   *aggref = (Aggref *) node;
+				Aggref	   *newnode;
 
 				FLATCOPY(newnode, aggref, Aggref);
 				MUTATE(newnode->target, aggref->target, Node *);
@@ -1702,8 +1752,8 @@ expression_tree_mutator(Node *node, Node * (*mutator) (), void *context)
 			break;
 		case T_Iter:
 			{
-				Iter   *iter = (Iter *) node;
-				Iter   *newnode;
+				Iter	   *iter = (Iter *) node;
+				Iter	   *newnode;
 
 				FLATCOPY(newnode, iter, Iter);
 				MUTATE(newnode->iterexpr, iter->iterexpr, Node *);
@@ -1763,12 +1813,14 @@ expression_tree_mutator(Node *node, Node * (*mutator) (), void *context)
 			break;
 		case T_SubLink:
 			{
-				/* A "bare" SubLink (note we will not come here if we found
-				 * a SUBPLAN_EXPR node above it).  Transform the lefthand side,
-				 * but not the oper list nor the subquery.
+
+				/*
+				 * A "bare" SubLink (note we will not come here if we
+				 * found a SUBPLAN_EXPR node above it).  Transform the
+				 * lefthand side, but not the oper list nor the subquery.
 				 */
-				SubLink   *sublink = (SubLink *) node;
-				SubLink   *newnode;
+				SubLink    *sublink = (SubLink *) node;
+				SubLink    *newnode;
 
 				FLATCOPY(newnode, sublink, SubLink);
 				MUTATE(newnode->lefthand, sublink->lefthand, List *);
@@ -1777,9 +1829,12 @@ expression_tree_mutator(Node *node, Node * (*mutator) (), void *context)
 			break;
 		case T_List:
 			{
-				/* We assume the mutator isn't interested in the list nodes
-				 * per se, so just invoke it on each list element.
-				 * NOTE: this would fail badly on a list with integer elements!
+
+				/*
+				 * We assume the mutator isn't interested in the list
+				 * nodes per se, so just invoke it on each list element.
+				 * NOTE: this would fail badly on a list with integer
+				 * elements!
 				 */
 				List	   *resultlist = NIL;
 				List	   *temp;
@@ -1795,9 +1850,13 @@ expression_tree_mutator(Node *node, Node * (*mutator) (), void *context)
 			break;
 		case T_TargetEntry:
 			{
-				/* We mutate the expression, but not the resdom, by default. */
-				TargetEntry   *targetentry = (TargetEntry *) node;
-				TargetEntry   *newnode;
+
+				/*
+				 * We mutate the expression, but not the resdom, by
+				 * default.
+				 */
+				TargetEntry *targetentry = (TargetEntry *) node;
+				TargetEntry *newnode;
 
 				FLATCOPY(newnode, targetentry, TargetEntry);
 				MUTATE(newnode->expr, targetentry->expr, Node *);
diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c
index 400c813125cb569703019b68ed340979c5651c60..69a28138d8a5cf285cc2d4c11fbad8ac9a31d98c 100644
--- a/src/backend/optimizer/util/pathnode.c
+++ b/src/backend/optimizer/util/pathnode.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.62 2000/03/22 22:08:35 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.63 2000/04/12 17:15:24 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -42,6 +42,7 @@ compare_path_costs(Path *path1, Path *path2, CostSelector criterion)
 			return -1;
 		if (path1->startup_cost > path2->startup_cost)
 			return +1;
+
 		/*
 		 * If paths have the same startup cost (not at all unlikely),
 		 * order them by total cost.
@@ -57,6 +58,7 @@ compare_path_costs(Path *path1, Path *path2, CostSelector criterion)
 			return -1;
 		if (path1->total_cost > path2->total_cost)
 			return +1;
+
 		/*
 		 * If paths have the same total cost, order them by startup cost.
 		 */
@@ -172,7 +174,8 @@ set_cheapest(RelOptInfo *parent_rel)
 void
 add_path(RelOptInfo *parent_rel, Path *new_path)
 {
-	bool		accept_new = true; /* unless we find a superior old path */
+	bool		accept_new = true;		/* unless we find a superior old
+										 * path */
 	List	   *p1_prev = NIL;
 	List	   *p1;
 
@@ -184,36 +187,39 @@ add_path(RelOptInfo *parent_rel, Path *new_path)
 	foreach(p1, parent_rel->pathlist)
 	{
 		Path	   *old_path = (Path *) lfirst(p1);
-		bool		remove_old = false;	/* unless new proves superior */
+		bool		remove_old = false; /* unless new proves superior */
 		int			costcmp;
 
 		costcmp = compare_path_costs(new_path, old_path, TOTAL_COST);
+
 		/*
-		 * If the two paths compare differently for startup and total cost,
-		 * then we want to keep both, and we can skip the (much slower)
-		 * comparison of pathkeys.  If they compare the same, proceed with
-		 * the pathkeys comparison.  Note this test relies on the fact that
-		 * compare_path_costs will only return 0 if both costs are equal
-		 * (and, therefore, there's no need to call it twice in that case).
+		 * If the two paths compare differently for startup and total
+		 * cost, then we want to keep both, and we can skip the (much
+		 * slower) comparison of pathkeys.	If they compare the same,
+		 * proceed with the pathkeys comparison.  Note this test relies on
+		 * the fact that compare_path_costs will only return 0 if both
+		 * costs are equal (and, therefore, there's no need to call it
+		 * twice in that case).
 		 */
 		if (costcmp == 0 ||
-			costcmp == compare_path_costs(new_path, old_path, STARTUP_COST))
+		 costcmp == compare_path_costs(new_path, old_path, STARTUP_COST))
 		{
 			switch (compare_pathkeys(new_path->pathkeys, old_path->pathkeys))
 			{
 				case PATHKEYS_EQUAL:
 					if (costcmp < 0)
-						remove_old = true; /* new dominates old */
+						remove_old = true;		/* new dominates old */
 					else
-						accept_new = false;	/* old equals or dominates new */
+						accept_new = false;		/* old equals or dominates
+												 * new */
 					break;
 				case PATHKEYS_BETTER1:
 					if (costcmp <= 0)
-						remove_old = true; /* new dominates old */
+						remove_old = true;		/* new dominates old */
 					break;
 				case PATHKEYS_BETTER2:
 					if (costcmp >= 0)
-						accept_new = false;	/* old dominates new */
+						accept_new = false;		/* old dominates new */
 					break;
 				case PATHKEYS_DIFFERENT:
 					/* keep both paths, since they have different ordering */
@@ -241,7 +247,7 @@ add_path(RelOptInfo *parent_rel, Path *new_path)
 		 * scanning the pathlist; we will not add new_path, and we assume
 		 * new_path cannot dominate any other elements of the pathlist.
 		 */
-		if (! accept_new)
+		if (!accept_new)
 			break;
 	}
 
@@ -315,12 +321,14 @@ create_index_path(Query *root,
 	if (pathnode->path.pathkeys == NIL)
 	{
 		/* No ordering available from index, is that OK? */
-		if (! ScanDirectionIsNoMovement(indexscandir))
+		if (!ScanDirectionIsNoMovement(indexscandir))
 			elog(ERROR, "create_index_path: failed to create ordered index scan");
 	}
 	else
 	{
-		/* The index is ordered, and build_index_pathkeys defaulted to
+
+		/*
+		 * The index is ordered, and build_index_pathkeys defaulted to
 		 * forward scan, so make sure we mark the pathnode properly.
 		 */
 		if (ScanDirectionIsNoMovement(indexscandir))
@@ -341,11 +349,11 @@ create_index_path(Query *root,
 	pathnode->indexscandir = indexscandir;
 
 	/*
-	 * This routine is only used to generate "standalone" indexpaths,
-	 * not nestloop inner indexpaths.  So joinrelids is always NIL
-	 * and the number of rows is the same as the parent rel's estimate.
+	 * This routine is only used to generate "standalone" indexpaths, not
+	 * nestloop inner indexpaths.  So joinrelids is always NIL and the
+	 * number of rows is the same as the parent rel's estimate.
 	 */
-	pathnode->joinrelids = NIL;	/* no join clauses here */
+	pathnode->joinrelids = NIL; /* no join clauses here */
 	pathnode->rows = rel->rows;
 
 	cost_index(&pathnode->path, root, rel, index, indexquals, false);
@@ -359,20 +367,23 @@ create_index_path(Query *root,
  *	  pathnode.
  *
  */
-TidPath *
+TidPath    *
 create_tidscan_path(RelOptInfo *rel, List *tideval)
 {
-	TidPath	*pathnode = makeNode(TidPath);
+	TidPath    *pathnode = makeNode(TidPath);
 
 	pathnode->path.pathtype = T_TidScan;
 	pathnode->path.parent = rel;
 	pathnode->path.pathkeys = NIL;
-	pathnode->tideval = copyObject(tideval); /* is copy really necessary? */
+	pathnode->tideval = copyObject(tideval);	/* is copy really
+												 * necessary? */
 	pathnode->unjoined_relids = NIL;
 
 	cost_tidscan(&pathnode->path, rel, tideval);
-	/* divide selectivity for each clause to get an equal selectivity
-	 * as IndexScan does OK ? 
+
+	/*
+	 * divide selectivity for each clause to get an equal selectivity as
+	 * IndexScan does OK ?
 	 */
 
 	return pathnode;
@@ -485,7 +496,7 @@ create_mergejoin_path(RelOptInfo *joinrel,
  * 'innerdisbursion' is an estimate of the disbursion of the inner hash key
  *
  */
-HashPath *
+HashPath   *
 create_hashjoin_path(RelOptInfo *joinrel,
 					 Path *outer_path,
 					 Path *inner_path,
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index 716c31ab0f132b7756457f30ba066a1e41b10a30..e9d7690e00c754dbd83413e1ba677f11424d8f2d 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.49 2000/02/18 09:30:09 inoue Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.50 2000/04/12 17:15:24 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -50,7 +50,7 @@ relation_info(Query *root, Index relid,
 	Form_pg_class relation;
 
 	relationTuple = SearchSysCacheTuple(RELOID,
-										ObjectIdGetDatum(relationObjectId),
+									  ObjectIdGetDatum(relationObjectId),
 										0, 0, 0);
 	if (!HeapTupleIsValid(relationTuple))
 		elog(ERROR, "relation_info: Relation %u not found",
@@ -81,7 +81,7 @@ find_secondary_indexes(Query *root, Index relid)
 	Oid			indrelid = getrelid(relid, root->rtable);
 	Relation	relation;
 	HeapScanDesc scan;
-	ScanKeyData	indexKey;
+	ScanKeyData indexKey;
 	HeapTuple	indexTuple;
 
 	/* Scan pg_index for tuples describing indexes of this rel */
@@ -97,27 +97,28 @@ find_secondary_indexes(Query *root, Index relid)
 
 	while (HeapTupleIsValid(indexTuple = heap_getnext(scan, 0)))
 	{
-		Form_pg_index	index = (Form_pg_index) GETSTRUCT(indexTuple);
-		IndexOptInfo   *info = makeNode(IndexOptInfo);
-		int				i;
-		Relation		indexRelation;
-		Oid				relam;
-		uint16			amorderstrategy;
+		Form_pg_index index = (Form_pg_index) GETSTRUCT(indexTuple);
+		IndexOptInfo *info = makeNode(IndexOptInfo);
+		int			i;
+		Relation	indexRelation;
+		Oid			relam;
+		uint16		amorderstrategy;
 
 		/*
 		 * Need to make these arrays large enough to be sure there is a
 		 * terminating 0 at the end of each one.
 		 */
-		info->classlist = (Oid *) palloc(sizeof(Oid) * (INDEX_MAX_KEYS+1));
-		info->indexkeys = (int *) palloc(sizeof(int) * (INDEX_MAX_KEYS+1));
-		info->ordering = (Oid *) palloc(sizeof(Oid) * (INDEX_MAX_KEYS+1));
+		info->classlist = (Oid *) palloc(sizeof(Oid) * (INDEX_MAX_KEYS + 1));
+		info->indexkeys = (int *) palloc(sizeof(int) * (INDEX_MAX_KEYS + 1));
+		info->ordering = (Oid *) palloc(sizeof(Oid) * (INDEX_MAX_KEYS + 1));
 
 		/* Extract info from the pg_index tuple */
 		info->indexoid = index->indexrelid;
-		info->indproc = index->indproc;		/* functional index ?? */
-		if (VARSIZE(&index->indpred) != 0)	/* partial index ?? */
+		info->indproc = index->indproc; /* functional index ?? */
+		if (VARSIZE(&index->indpred) != 0)		/* partial index ?? */
 		{
 			char	   *predString = fmgr(F_TEXTOUT, &index->indpred);
+
 			info->indpred = (List *) stringToNode(predString);
 			pfree(predString);
 		}
@@ -143,26 +144,25 @@ find_secondary_indexes(Query *root, Index relid)
 		index_close(indexRelation);
 
 		/*
-		 * Fetch the ordering operators associated with the index,
-		 * if any.
+		 * Fetch the ordering operators associated with the index, if any.
 		 */
-		MemSet(info->ordering, 0, sizeof(Oid) * (INDEX_MAX_KEYS+1));
+		MemSet(info->ordering, 0, sizeof(Oid) * (INDEX_MAX_KEYS + 1));
 		if (amorderstrategy != 0)
 		{
 			for (i = 0; i < INDEX_MAX_KEYS && index->indclass[i]; i++)
 			{
-				HeapTuple		amopTuple;
-				Form_pg_amop	amop;
+				HeapTuple	amopTuple;
+				Form_pg_amop amop;
 
 				amopTuple =
 					SearchSysCacheTuple(AMOPSTRATEGY,
 										ObjectIdGetDatum(relam),
-										ObjectIdGetDatum(index->indclass[i]),
+									ObjectIdGetDatum(index->indclass[i]),
 										UInt16GetDatum(amorderstrategy),
 										0);
 				if (!HeapTupleIsValid(amopTuple))
 					elog(ERROR, "find_secondary_indexes: no amop %u %u %d",
-						 relam, index->indclass[i], (int) amorderstrategy);
+					   relam, index->indclass[i], (int) amorderstrategy);
 				amop = (Form_pg_amop) GETSTRUCT(amopTuple);
 				info->ordering[i] = amop->amopopr;
 			}
diff --git a/src/backend/optimizer/util/relnode.c b/src/backend/optimizer/util/relnode.c
index 694a1b905e14238a6a915b4c2686243adf0741d9..da7059ce9151f3921b7a1fadd80d3cc52a42428d 100644
--- a/src/backend/optimizer/util/relnode.c
+++ b/src/backend/optimizer/util/relnode.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.25 2000/02/18 23:47:31 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.26 2000/04/12 17:15:24 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -24,15 +24,15 @@
 
 static List *new_join_tlist(List *tlist, int first_resdomno);
 static List *build_joinrel_restrictlist(RelOptInfo *joinrel,
-										RelOptInfo *outer_rel,
-										RelOptInfo *inner_rel);
+						   RelOptInfo *outer_rel,
+						   RelOptInfo *inner_rel);
 static void build_joinrel_joinlist(RelOptInfo *joinrel,
-								   RelOptInfo *outer_rel,
-								   RelOptInfo *inner_rel);
+					   RelOptInfo *outer_rel,
+					   RelOptInfo *inner_rel);
 static List *subbuild_joinrel_restrictlist(RelOptInfo *joinrel,
-										   List *joininfo_list);
+							  List *joininfo_list);
 static void subbuild_joinrel_joinlist(RelOptInfo *joinrel,
-									  List *joininfo_list);
+						  List *joininfo_list);
 
 
 /*
@@ -50,7 +50,10 @@ get_base_rel(Query *root, int relid)
 	{
 		rel = (RelOptInfo *) lfirst(baserels);
 
-		/* We know length(rel->relids) == 1 for all members of base_rel_list */
+		/*
+		 * We know length(rel->relids) == 1 for all members of
+		 * base_rel_list
+		 */
 		if (lfirsti(rel->relids) == relid)
 			return rel;
 	}
@@ -75,18 +78,20 @@ get_base_rel(Query *root, int relid)
 
 	if (relid < 0)
 	{
+
 		/*
-		 * If the relation is a materialized relation, assume
-		 * constants for sizes.
+		 * If the relation is a materialized relation, assume constants
+		 * for sizes.
 		 */
 		rel->pages = _NONAME_RELATION_PAGES_;
 		rel->tuples = _NONAME_RELATION_TUPLES_;
 	}
 	else
 	{
+
 		/*
-		 * Otherwise, retrieve relation statistics from the
-		 * system catalogs.
+		 * Otherwise, retrieve relation statistics from the system
+		 * catalogs.
 		 */
 		relation_info(root, relid,
 					  &rel->indexed, &rel->pages, &rel->tuples);
@@ -162,6 +167,7 @@ get_join_rel(Query *root,
 
 	if (joinrel)
 	{
+
 		/*
 		 * Yes, so we only need to figure the restrictlist for this
 		 * particular pair of component relations.
@@ -198,13 +204,13 @@ get_join_rel(Query *root,
 	 * of the outer and inner join relations and then merging the results
 	 * together.
 	 *
-	 * NOTE: the tlist order for a join rel will depend on which pair
-	 * of outer and inner rels we first try to build it from.  But the
+	 * NOTE: the tlist order for a join rel will depend on which pair of
+	 * outer and inner rels we first try to build it from.	But the
 	 * contents should be the same regardless.
 	 *
-	 * XXX someday: consider pruning vars from the join's targetlist
-	 * if they are needed only to evaluate restriction clauses of this
-	 * join, and will never be accessed at higher levels of the plantree.
+	 * XXX someday: consider pruning vars from the join's targetlist if they
+	 * are needed only to evaluate restriction clauses of this join, and
+	 * will never be accessed at higher levels of the plantree.
 	 */
 	new_outer_tlist = new_join_tlist(outer_rel->targetlist, 1);
 	new_inner_tlist = new_join_tlist(inner_rel->targetlist,
@@ -212,9 +218,9 @@ get_join_rel(Query *root,
 	joinrel->targetlist = nconc(new_outer_tlist, new_inner_tlist);
 
 	/*
-	 * Construct restrict and join clause lists for the new joinrel.
-	 * (The caller might or might not need the restrictlist, but
-	 * I need it anyway for set_joinrel_size_estimates().)
+	 * Construct restrict and join clause lists for the new joinrel. (The
+	 * caller might or might not need the restrictlist, but I need it
+	 * anyway for set_joinrel_size_estimates().)
 	 */
 	restrictlist = build_joinrel_restrictlist(joinrel, outer_rel, inner_rel);
 	if (restrictlist_ptr)
@@ -246,7 +252,7 @@ get_join_rel(Query *root,
  *
  *	  XXX the above comment refers to code that is long dead and gone;
  *	  we don't keep track of joinlists for individual targetlist entries
- *	  anymore.  For now, all vars present in either input tlist will be
+ *	  anymore.	For now, all vars present in either input tlist will be
  *	  emitted in the join's tlist.
  *
  * 'tlist' is the target list of one of the join relations
@@ -286,16 +292,16 @@ new_join_tlist(List *tlist,
  *	  the join lists need only be computed once for any join RelOptInfo.
  *	  The join lists are fully determined by the set of rels making up the
  *	  joinrel, so we should get the same results (up to ordering) from any
- *	  candidate pair of sub-relations.  But the restriction list is whatever
+ *	  candidate pair of sub-relations.	But the restriction list is whatever
  *	  is not handled in the sub-relations, so it depends on which
  *	  sub-relations are considered.
  *
  *	  If a join clause from an input relation refers to base rels still not
  *	  present in the joinrel, then it is still a join clause for the joinrel;
- *	  we put it into an appropriate JoinInfo list for the joinrel.  Otherwise,
+ *	  we put it into an appropriate JoinInfo list for the joinrel.	Otherwise,
  *	  the clause is now a restrict clause for the joined relation, and we
  *	  return it to the caller of build_joinrel_restrictlist() to be stored in
- *	  join paths made from this pair of sub-relations.  (It will not need to
+ *	  join paths made from this pair of sub-relations.	(It will not need to
  *	  be considered further up the join tree.)
  *
  * 'joinrel' is a join relation node
@@ -304,11 +310,11 @@ new_join_tlist(List *tlist,
  *
  * build_joinrel_restrictlist() returns a list of relevant restrictinfos,
  * whereas build_joinrel_joinlist() stores its results in the joinrel's
- * joininfo lists.  One or the other must accept each given clause!
+ * joininfo lists.	One or the other must accept each given clause!
  *
  * NB: Formerly, we made deep(!) copies of each input RestrictInfo to pass
  * up to the join relation.  I believe this is no longer necessary, because
- * RestrictInfo nodes are no longer context-dependent.  Instead, just include
+ * RestrictInfo nodes are no longer context-dependent.	Instead, just include
  * the original nodes in the lists made for the join relation.
  */
 static List *
@@ -316,9 +322,10 @@ build_joinrel_restrictlist(RelOptInfo *joinrel,
 						   RelOptInfo *outer_rel,
 						   RelOptInfo *inner_rel)
 {
+
 	/*
-	 * We must eliminate duplicates, since we will see the
-	 * same clauses arriving from both input relations...
+	 * We must eliminate duplicates, since we will see the same clauses
+	 * arriving from both input relations...
 	 */
 	return LispUnion(subbuild_joinrel_restrictlist(joinrel,
 												   outer_rel->joininfo),
@@ -348,6 +355,7 @@ subbuild_joinrel_restrictlist(RelOptInfo *joinrel,
 
 		if (is_subseti(joininfo->unjoined_relids, joinrel->relids))
 		{
+
 			/*
 			 * Clauses in this JoinInfo list become restriction clauses
 			 * for the joinrel, since they refer to no outside rels.
@@ -360,9 +368,10 @@ subbuild_joinrel_restrictlist(RelOptInfo *joinrel,
 		}
 		else
 		{
+
 			/*
-			 * These clauses are still join clauses at this level,
-			 * so we ignore them in this routine.
+			 * These clauses are still join clauses at this level, so we
+			 * ignore them in this routine.
 			 */
 		}
 	}
@@ -385,18 +394,20 @@ subbuild_joinrel_joinlist(RelOptInfo *joinrel,
 											  joinrel->relids);
 		if (new_unjoined_relids == NIL)
 		{
+
 			/*
 			 * Clauses in this JoinInfo list become restriction clauses
-			 * for the joinrel, since they refer to no outside rels.
-			 * So we can ignore them in this routine.
+			 * for the joinrel, since they refer to no outside rels. So we
+			 * can ignore them in this routine.
 			 */
 		}
 		else
 		{
+
 			/*
-			 * These clauses are still join clauses at this level,
-			 * so find or make the appropriate JoinInfo item for the joinrel,
-			 * and add the clauses to it (eliminating duplicates).
+			 * These clauses are still join clauses at this level, so find
+			 * or make the appropriate JoinInfo item for the joinrel, and
+			 * add the clauses to it (eliminating duplicates).
 			 */
 			JoinInfo   *new_joininfo;
 
diff --git a/src/backend/optimizer/util/tlist.c b/src/backend/optimizer/util/tlist.c
index b4c745b25f32e2da0efa86ff33bba7ab566d5efc..d4094dac12a8a9ee05542d44a427173787b31ba4 100644
--- a/src/backend/optimizer/util/tlist.c
+++ b/src/backend/optimizer/util/tlist.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.43 2000/01/27 18:11:34 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.44 2000/04/12 17:15:24 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -27,7 +27,7 @@
 /*
  * tlistentry_member
  *	  Finds the (first) member of the given tlist whose expression is
- *	  equal() to the given expression.  Result is NULL if no such member.
+ *	  equal() to the given expression.	Result is NULL if no such member.
  */
 TargetEntry *
 tlistentry_member(Node *node, List *targetlist)
@@ -36,7 +36,7 @@ tlistentry_member(Node *node, List *targetlist)
 
 	foreach(temp, targetlist)
 	{
-		TargetEntry	   *tlentry = (TargetEntry *) lfirst(temp);
+		TargetEntry *tlentry = (TargetEntry *) lfirst(temp);
 
 		if (equal(node, tlentry->expr))
 			return tlentry;
@@ -87,12 +87,12 @@ tlist_member(Node *node, List *targetlist)
 void
 add_var_to_tlist(RelOptInfo *rel, Var *var)
 {
-	if (! tlistentry_member((Node *) var, rel->targetlist))
+	if (!tlistentry_member((Node *) var, rel->targetlist))
 	{
 		/* XXX is copyObject necessary here? */
 		rel->targetlist = lappend(rel->targetlist,
-							create_tl_element((Var *) copyObject(var),
-											  length(rel->targetlist) + 1));
+							   create_tl_element((Var *) copyObject(var),
+										   length(rel->targetlist) + 1));
 	}
 }
 
@@ -189,7 +189,7 @@ add_to_flat_tlist(List *tlist, List *vars)
 	{
 		Var		   *var = lfirst(v);
 
-		if (! tlistentry_member((Node *) var, tlist))
+		if (!tlistentry_member((Node *) var, tlist))
 		{
 			Resdom	   *r;
 
diff --git a/src/backend/optimizer/util/var.c b/src/backend/optimizer/util/var.c
index f438845cff96b2ffd108c27ccf8fd0f99b8865c7..bed7be7f08a583c600001613bb56255b4b059d95 100644
--- a/src/backend/optimizer/util/var.c
+++ b/src/backend/optimizer/util/var.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/util/var.c,v 1.25 2000/01/26 05:56:40 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/util/var.c,v 1.26 2000/04/12 17:15:24 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -20,7 +20,8 @@
 #include "optimizer/var.h"
 
 
-typedef struct {
+typedef struct
+{
 	List	   *varlist;
 	bool		includeUpperVars;
 } pull_var_clause_context;
@@ -28,7 +29,7 @@ typedef struct {
 static bool pull_varnos_walker(Node *node, List **listptr);
 static bool contain_var_clause_walker(Node *node, void *context);
 static bool pull_var_clause_walker(Node *node,
-								   pull_var_clause_context *context);
+					   pull_var_clause_context *context);
 
 
 /*
@@ -54,7 +55,8 @@ pull_varnos_walker(Node *node, List **listptr)
 		return false;
 	if (IsA(node, Var))
 	{
-		Var	   *var = (Var *) node;
+		Var		   *var = (Var *) node;
+
 		if (var->varlevelsup == 0 && !intMember(var->varno, *listptr))
 			*listptr = lconsi(var->varno, *listptr);
 		return false;
@@ -83,7 +85,8 @@ contain_var_clause_walker(Node *node, void *context)
 	if (IsA(node, Var))
 	{
 		if (((Var *) node)->varlevelsup == 0)
-			return true;		/* abort the tree traversal and return true */
+			return true;		/* abort the tree traversal and return
+								 * true */
 		return false;
 	}
 	return expression_tree_walker(node, contain_var_clause_walker, context);
@@ -94,7 +97,7 @@ contain_var_clause_walker(Node *node, void *context)
  *	  Recursively pulls all var nodes from an expression clause.
  *
  *	  Upper-level vars (with varlevelsup > 0) are included only
- *	  if includeUpperVars is true.  Most callers probably want
+ *	  if includeUpperVars is true.	Most callers probably want
  *	  to ignore upper-level vars.
  *
  *	  Returns list of varnodes found.  Note the varnodes themselves are not
@@ -103,7 +106,7 @@ contain_var_clause_walker(Node *node, void *context)
 List *
 pull_var_clause(Node *clause, bool includeUpperVars)
 {
-	pull_var_clause_context		context;
+	pull_var_clause_context context;
 
 	context.varlist = NIL;
 	context.includeUpperVars = includeUpperVars;
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index a874c24f5e139229f572c7d903b93dba57258029..7658443a378738af3b00ba8fdd845d13b2defd84 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- *	$Id: analyze.c,v 1.141 2000/03/24 23:34:19 tgl Exp $
+ *	$Id: analyze.c,v 1.142 2000/04/12 17:15:26 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -28,7 +28,7 @@
 #include "utils/builtins.h"
 #include "utils/numeric.h"
 
-void		CheckSelectForUpdate(Query *qry); /* no points for style... */
+void		CheckSelectForUpdate(Query *qry);	/* no points for style... */
 
 static Query *transformStmt(ParseState *pstate, Node *stmt);
 static Query *transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt);
@@ -48,8 +48,8 @@ static void transformConstraintAttrs(List *constraintList);
 static void transformColumnType(ParseState *pstate, ColumnDef *column);
 
 /* kluge to return extra info from transformCreateStmt() */
-static List	   *extras_before;
-static List	   *extras_after;
+static List *extras_before;
+static List *extras_after;
 
 
 /*
@@ -81,7 +81,7 @@ parse_analyze(List *pl, ParseState *parentParseState)
 		while (extras_before != NIL)
 		{
 			result = lappend(result,
-							 transformStmt(pstate, lfirst(extras_before)));
+						   transformStmt(pstate, lfirst(extras_before)));
 			if (pstate->p_target_relation != NULL)
 				heap_close(pstate->p_target_relation, AccessShareLock);
 			pstate->p_target_relation = NULL;
@@ -147,13 +147,15 @@ transformStmt(ParseState *pstate, Node *parseTree)
 
 				n->query = (Query *) transformStmt(pstate, (Node *) n->query);
 
-				/* If a list of column names was given, run through and insert these
-				 * into the actual query tree. - thomas 2000-03-08
+				/*
+				 * If a list of column names was given, run through and
+				 * insert these into the actual query tree. - thomas
+				 * 2000-03-08
 				 */
 				if (n->aliases != NIL)
 				{
-					int i;
-					List *targetList = n->query->targetList;
+					int			i;
+					List	   *targetList = n->query->targetList;
 
 					if (length(targetList) < length(n->aliases))
 						elog(ERROR, "CREATE VIEW specifies %d columns"
@@ -162,9 +164,10 @@ transformStmt(ParseState *pstate, Node *parseTree)
 
 					for (i = 0; i < length(n->aliases); i++)
 					{
-						Ident *id;
+						Ident	   *id;
 						TargetEntry *te;
-						Resdom *rd;
+						Resdom	   *rd;
+
 						id = nth(i, n->aliases);
 						Assert(nodeTag(id) == T_Ident);
 						te = nth(i, targetList);
@@ -210,9 +213,7 @@ transformStmt(ParseState *pstate, Node *parseTree)
 			break;
 
 		case T_AlterTableStmt:
-			{
-				result = transformAlterTableStmt(pstate, (AlterTableStmt *) parseTree);
-			}
+			result = transformAlterTableStmt(pstate, (AlterTableStmt *) parseTree);
 			break;
 
 			/*------------------------
@@ -311,7 +312,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
 	 * It is important that we finish processing all the SELECT subclauses
 	 * before we start doing any INSERT-specific processing; otherwise
 	 * the behavior of SELECT within INSERT might be different from a
-	 * stand-alone SELECT.  (Indeed, Postgres up through 6.5 had bugs of
+	 * stand-alone SELECT.	(Indeed, Postgres up through 6.5 had bugs of
 	 * just that nature...)
 	 *----------
 	 */
@@ -323,7 +324,8 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
 
 	qry->qual = transformWhereClause(pstate, stmt->whereClause);
 
-	/* Initial processing of HAVING clause is just like WHERE clause.
+	/*
+	 * Initial processing of HAVING clause is just like WHERE clause.
 	 * Additional work will be done in optimizer/plan/planner.c.
 	 */
 	qry->havingQual = transformWhereClause(pstate, stmt->havingClause);
@@ -338,7 +340,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
 	qry->distinctClause = transformDistinctClause(pstate,
 												  stmt->distinctClause,
 												  qry->targetList,
-												  & qry->sortClause);
+												  &qry->sortClause);
 
 	qry->hasSubLinks = pstate->p_hasSubLinks;
 	qry->hasAggs = pstate->p_hasAggs;
@@ -390,9 +392,11 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
 
 		if (resnode->resjunk)
 		{
-			/* Resjunk nodes need no additional processing, but be sure they
-			 * have names and resnos that do not match any target columns;
-			 * else rewriter or planner might get confused.
+
+			/*
+			 * Resjunk nodes need no additional processing, but be sure
+			 * they have names and resnos that do not match any target
+			 * columns; else rewriter or planner might get confused.
 			 */
 			resnode->resname = "?resjunk?";
 			resnode->resno = (AttrNumber) pstate->p_last_resno++;
@@ -411,9 +415,9 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
 	/*
 	 * It is possible that the targetlist has fewer entries than were in
 	 * the columns list.  We do not consider this an error (perhaps we
-	 * should, if the columns list was explictly given?).  We must truncate
-	 * the attrnos list to only include the attrs actually provided,
-	 * else we will fail to apply defaults for them below.
+	 * should, if the columns list was explictly given?).  We must
+	 * truncate the attrnos list to only include the attrs actually
+	 * provided, else we will fail to apply defaults for them below.
 	 */
 	if (icolumns != NIL)
 		attrnos = ltruncate(numuseratts, attrnos);
@@ -422,8 +426,8 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
 	 * Add targetlist items to assign DEFAULT values to any columns that
 	 * have defaults and were not assigned to by the user.
 	 *
-	 * XXX wouldn't it make more sense to do this further downstream,
-	 * after the rule rewriter?
+	 * XXX wouldn't it make more sense to do this further downstream, after
+	 * the rule rewriter?
 	 */
 	rd_att = pstate->p_target_relation->rd_att;
 	if (rd_att->constr && rd_att->constr->num_defval > 0)
@@ -434,24 +438,26 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
 
 		while (--ndef >= 0)
 		{
-			AttrNumber		attrno = defval[ndef].adnum;
+			AttrNumber	attrno = defval[ndef].adnum;
 			Form_pg_attribute thisatt = att[attrno - 1];
-			TargetEntry	   *te;
+			TargetEntry *te;
 
 			if (intMember((int) attrno, attrnos))
 				continue;		/* there was a user-specified value */
+
 			/*
-			 * No user-supplied value, so add a targetentry with DEFAULT expr
-			 * and correct data for the target column.
+			 * No user-supplied value, so add a targetentry with DEFAULT
+			 * expr and correct data for the target column.
 			 */
 			te = makeTargetEntry(
-				makeResdom(attrno,
-						   thisatt->atttypid,
-						   thisatt->atttypmod,
-						   pstrdup(NameStr(thisatt->attname)),
-						   0, 0, false),
-				stringToNode(defval[ndef].adbin));
+								 makeResdom(attrno,
+											thisatt->atttypid,
+											thisatt->atttypmod,
+									  pstrdup(NameStr(thisatt->attname)),
+											0, 0, false),
+								 stringToNode(defval[ndef].adbin));
 			qry->targetList = lappend(qry->targetList, te);
+
 			/*
 			 * Make sure the value is coerced to the target column type
 			 * (might not be right type if it's not a constant!)
@@ -476,7 +482,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
  *	Create a name for an implicitly created index, sequence, constraint, etc.
  *
  *	The parameters are: the original table name, the original field name, and
- *	a "type" string (such as "seq" or "pkey").  The field name and/or type
+ *	a "type" string (such as "seq" or "pkey").	The field name and/or type
  *	can be NULL if not relevant.
  *
  *	The result is a palloc'd string.
@@ -484,12 +490,12 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
  *	The basic result we want is "name1_name2_type", omitting "_name2" or
  *	"_type" when those parameters are NULL.  However, we must generate
  *	a name with less than NAMEDATALEN characters!  So, we truncate one or
- *	both names if necessary to make a short-enough string.  The type part
+ *	both names if necessary to make a short-enough string.	The type part
  *	is never truncated (so it had better be reasonably short).
  *
  *	To reduce the probability of collisions, we might someday add more
  *	smarts to this routine, like including some "hash" characters computed
- *	from the truncated characters.  Currently it seems best to keep it simple,
+ *	from the truncated characters.	Currently it seems best to keep it simple,
  *	so that the generated names are easily predictable by a person.
  */
 static char *
@@ -513,10 +519,11 @@ makeObjectName(char *name1, char *name2, char *typename)
 	if (typename)
 		overhead += strlen(typename) + 1;
 
-	availchars = NAMEDATALEN-1 - overhead;
+	availchars = NAMEDATALEN - 1 - overhead;
 
-	/* If we must truncate,  preferentially truncate the longer name.
-	 * This logic could be expressed without a loop, but it's simple and
+	/*
+	 * If we must truncate,  preferentially truncate the longer name. This
+	 * logic could be expressed without a loop, but it's simple and
 	 * obvious as a loop.
 	 */
 	while (name1chars + name2chars > availchars)
@@ -534,13 +541,13 @@ makeObjectName(char *name1, char *name2, char *typename)
 	if (name2)
 	{
 		name[ndx++] = '_';
-		strncpy(name+ndx, name2, name2chars);
+		strncpy(name + ndx, name2, name2chars);
 		ndx += name2chars;
 	}
 	if (typename)
 	{
 		name[ndx++] = '_';
-		strcpy(name+ndx, typename);
+		strcpy(name + ndx, typename);
 	}
 	else
 		name[ndx] = '\0';
@@ -556,7 +563,8 @@ CreateIndexName(char *table_name, char *column_name, char *label, List *indices)
 	List	   *ilist;
 	char		typename[NAMEDATALEN];
 
-	/* The type name for makeObjectName is label, or labelN if that's
+	/*
+	 * The type name for makeObjectName is label, or labelN if that's
 	 * necessary to prevent collisions among multiple indexes for the same
 	 * table.  Note there is no check for collisions with already-existing
 	 * indexes; this ought to be rethought someday.
@@ -570,6 +578,7 @@ CreateIndexName(char *table_name, char *column_name, char *label, List *indices)
 		foreach(ilist, indices)
 		{
 			IndexStmt  *index = lfirst(ilist);
+
 			if (strcmp(iname, index->idxname) == 0)
 				break;
 		}
@@ -597,28 +606,28 @@ CreateIndexName(char *table_name, char *column_name, char *label, List *indices)
 static Query *
 transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
 {
-	Query		   *q;
-	List		   *elements;
-	Node		   *element;
-	List		   *columns;
-	List		   *dlist;
-	ColumnDef	   *column;
-	List		   *constraints,
-				   *clist;
-	Constraint	   *constraint;
-	List		   *fkconstraints,	/* List of FOREIGN KEY constraints to */
-				   *fkclist;		/* add finally */
-	FkConstraint   *fkconstraint;
-	List		   *keys;
-	Ident		   *key;
-	List		   *blist = NIL;	/* "before list" of things to do before
-									 * creating the table */
-	List		   *ilist = NIL;	/* "index list" of things to do after
-									 * creating the table */
-	IndexStmt	   *index,
-				   *pkey = NULL;
-	IndexElem	   *iparam;
-	bool			saw_nullable;
+	Query	   *q;
+	List	   *elements;
+	Node	   *element;
+	List	   *columns;
+	List	   *dlist;
+	ColumnDef  *column;
+	List	   *constraints,
+			   *clist;
+	Constraint *constraint;
+	List	   *fkconstraints,	/* List of FOREIGN KEY constraints to */
+			   *fkclist;		/* add finally */
+	FkConstraint *fkconstraint;
+	List	   *keys;
+	Ident	   *key;
+	List	   *blist = NIL;	/* "before list" of things to do before
+								 * creating the table */
+	List	   *ilist = NIL;	/* "index list" of things to do after
+								 * creating the table */
+	IndexStmt  *index,
+			   *pkey = NULL;
+	IndexElem  *iparam;
+	bool		saw_nullable;
 
 	q = makeNode(Query);
 	q->commandType = CMD_UTILITY;
@@ -647,18 +656,19 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
 				{
 					char	   *sname;
 					char	   *qstring;
-					A_Const	   *snamenode;
+					A_Const    *snamenode;
 					FuncCall   *funccallnode;
 					CreateSeqStmt *sequence;
 
 					/*
-					 * Create appropriate constraints for SERIAL.  We do this
-					 * in full, rather than shortcutting, so that we will
-					 * detect any conflicting constraints the user wrote
-					 * (like a different DEFAULT).
+					 * Create appropriate constraints for SERIAL.  We do
+					 * this in full, rather than shortcutting, so that we
+					 * will detect any conflicting constraints the user
+					 * wrote (like a different DEFAULT).
 					 */
 					sname = makeObjectName(stmt->relname, column->colname,
 										   "seq");
+
 					/*
 					 * Create an expression tree representing the function
 					 * call  nextval('"sequencename"')
@@ -701,7 +711,7 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
 					sequence->options = NIL;
 
 					elog(NOTICE, "CREATE TABLE will create implicit sequence '%s' for SERIAL column '%s.%s'",
-						 sequence->seqname, stmt->relname, column->colname);
+					  sequence->seqname, stmt->relname, column->colname);
 
 					blist = lcons(sequence, NIL);
 				}
@@ -724,12 +734,13 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
 					 */
 					if (IsA(constraint, FkConstraint))
 					{
-						Ident	*id = makeNode(Ident);
-						id->name		= column->colname;
-						id->indirection	= NIL;
-						id->isRel		= false;
+						Ident	   *id = makeNode(Ident);
+
+						id->name = column->colname;
+						id->indirection = NIL;
+						id->isRel = false;
 
-						fkconstraint = (FkConstraint *)constraint;
+						fkconstraint = (FkConstraint *) constraint;
 						fkconstraint->fk_attrs = lappend(NIL, id);
 
 						fkconstraints = lappend(fkconstraints, constraint);
@@ -747,7 +758,7 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
 							break;
 
 						case CONSTR_NOTNULL:
-							if (saw_nullable && ! column->is_not_null)
+							if (saw_nullable && !column->is_not_null)
 								elog(ERROR, "CREATE TABLE/(NOT) NULL conflicting declaration"
 									 " for '%s.%s'", stmt->relname, column->colname);
 							column->is_not_null = TRUE;
@@ -910,7 +921,7 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
 				if (strcmp(column->colname, key->name) == 0)
 					break;
 			}
-			if (columns == NIL)	/* fell off end of list? */
+			if (columns == NIL) /* fell off end of list? */
 				elog(ERROR, "CREATE TABLE: column '%s' named in key does not exist",
 					 key->name);
 
@@ -927,7 +938,7 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
 				index->idxname = CreateIndexName(stmt->relname, iparam->name, "key", ilist);
 		}
 
-		if (index->idxname == NULL)	/* should not happen */
+		if (index->idxname == NULL)		/* should not happen */
 			elog(ERROR, "CREATE TABLE: failed to make implicit index name");
 
 		ilist = lappend(ilist, index);
@@ -945,9 +956,11 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
 		ilist = NIL;
 		while (dlist != NIL)
 		{
-			List *pcols, *icols;
-			int plen, ilen;
-			int	keep = TRUE;
+			List	   *pcols,
+					   *icols;
+			int			plen,
+						ilen;
+			int			keep = TRUE;
 
 			index = lfirst(dlist);
 			pcols = pkey->indexParams;
@@ -962,10 +975,10 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
 				keep = FALSE;
 				while ((pcols != NIL) && (icols != NIL))
 				{
-					IndexElem *pcol = lfirst(pcols);
-					IndexElem *icol = lfirst(icols);
-					char *pname = pcol->name;
-					char *iname = icol->name;
+					IndexElem  *pcol = lfirst(pcols);
+					IndexElem  *icol = lfirst(icols);
+					char	   *pname = pcol->name;
+					char	   *iname = icol->name;
 
 					/* different names? then no match... */
 					if (strcmp(iname, pname) != 0)
@@ -999,22 +1012,22 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
 	extras_after = ilist;
 
 	/*
-	 * Now process the FOREIGN KEY constraints and add appropriate
-	 * queries to the extras_after statements list.
+	 * Now process the FOREIGN KEY constraints and add appropriate queries
+	 * to the extras_after statements list.
 	 *
 	 */
 	if (fkconstraints != NIL)
 	{
-		CreateTrigStmt	   *fk_trigger;
-		List			   *fk_attr;
-		List			   *pk_attr;
-		Ident			   *id;
+		CreateTrigStmt *fk_trigger;
+		List	   *fk_attr;
+		List	   *pk_attr;
+		Ident	   *id;
 
 		elog(NOTICE, "CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)");
 
-		foreach (fkclist, fkconstraints)
+		foreach(fkclist, fkconstraints)
 		{
-			fkconstraint = (FkConstraint *)lfirst(fkclist);
+			fkconstraint = (FkConstraint *) lfirst(fkclist);
 
 			/*
 			 * If the constraint has no name, set it to <unnamed>
@@ -1024,37 +1037,37 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
 				fkconstraint->constr_name = "<unnamed>";
 
 			/*
-			 * If the attribute list for the referenced table was
-			 * omitted, lookup for the definition of the primary key.
-			 * If the referenced table is this table, use the definition
-			 * we found above, rather than looking to the system
-			 * tables.
+			 * If the attribute list for the referenced table was omitted,
+			 * lookup for the definition of the primary key. If the
+			 * referenced table is this table, use the definition we found
+			 * above, rather than looking to the system tables.
 			 *
 			 */
 			if (fkconstraint->fk_attrs != NIL && fkconstraint->pk_attrs == NIL)
 			{
 				if (strcmp(fkconstraint->pktable_name, stmt->relname) != 0)
 					transformFkeyGetPrimaryKey(fkconstraint);
-				else if (pkey != NULL) 
+				else if (pkey != NULL)
 				{
-					List *pkey_attr = pkey->indexParams;
-					List *attr;
-					IndexElem *ielem;
-					Ident *pkattr;
+					List	   *pkey_attr = pkey->indexParams;
+					List	   *attr;
+					IndexElem  *ielem;
+					Ident	   *pkattr;
 
-					foreach (attr, pkey_attr) 
+					foreach(attr, pkey_attr)
 					{
 						ielem = lfirst(attr);
-						pkattr = (Ident *)makeNode(Ident);
+						pkattr = (Ident *) makeNode(Ident);
 						pkattr->name = pstrdup(ielem->name);
 						pkattr->indirection = NIL;
 						pkattr->isRel = false;
 						fkconstraint->pk_attrs = lappend(fkconstraint->pk_attrs, pkattr);
-					}										
+					}
 				}
-				else {
+				else
+				{
 					elog(ERROR, "PRIMARY KEY for referenced table \"%s\" not found",
-						fkconstraint->pktable_name);
+						 fkconstraint->pktable_name);
 				}
 			}
 
@@ -1063,85 +1076,87 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
 			 * action.
 			 *
 			 */
-			fk_trigger = (CreateTrigStmt *)makeNode(CreateTrigStmt);
-			fk_trigger->trigname		= fkconstraint->constr_name;
-			fk_trigger->relname			= stmt->relname;
-			fk_trigger->funcname		= "RI_FKey_check_ins";
-			fk_trigger->before			= false;
-			fk_trigger->row				= true;
-			fk_trigger->actions[0]		= 'i';
-			fk_trigger->actions[1]		= 'u';
-			fk_trigger->actions[2]		= '\0';
-			fk_trigger->lang			= NULL;
-			fk_trigger->text			= NULL;
-			fk_trigger->attr			= NIL;
-			fk_trigger->when			= NULL;
-			fk_trigger->isconstraint	= true;
-			fk_trigger->deferrable		= fkconstraint->deferrable;
-			fk_trigger->initdeferred	= fkconstraint->initdeferred;
-			fk_trigger->constrrelname	= fkconstraint->pktable_name;
-
-			fk_trigger->args		= NIL;
+			fk_trigger = (CreateTrigStmt *) makeNode(CreateTrigStmt);
+			fk_trigger->trigname = fkconstraint->constr_name;
+			fk_trigger->relname = stmt->relname;
+			fk_trigger->funcname = "RI_FKey_check_ins";
+			fk_trigger->before = false;
+			fk_trigger->row = true;
+			fk_trigger->actions[0] = 'i';
+			fk_trigger->actions[1] = 'u';
+			fk_trigger->actions[2] = '\0';
+			fk_trigger->lang = NULL;
+			fk_trigger->text = NULL;
+
+			fk_trigger->attr = NIL;
+			fk_trigger->when = NULL;
+			fk_trigger->isconstraint = true;
+			fk_trigger->deferrable = fkconstraint->deferrable;
+			fk_trigger->initdeferred = fkconstraint->initdeferred;
+			fk_trigger->constrrelname = fkconstraint->pktable_name;
+
+			fk_trigger->args = NIL;
 			fk_trigger->args = lappend(fk_trigger->args,
-										fkconstraint->constr_name);
+									   fkconstraint->constr_name);
 			fk_trigger->args = lappend(fk_trigger->args,
-										stmt->relname);
+									   stmt->relname);
 			fk_trigger->args = lappend(fk_trigger->args,
-										fkconstraint->pktable_name);
+									   fkconstraint->pktable_name);
 			fk_trigger->args = lappend(fk_trigger->args,
-										fkconstraint->match_type);
+									   fkconstraint->match_type);
 			fk_attr = fkconstraint->fk_attrs;
 			pk_attr = fkconstraint->pk_attrs;
 			if (length(fk_attr) != length(pk_attr))
 			{
 				elog(NOTICE, "Illegal FOREIGN KEY definition REFERENCES \"%s\"",
-							fkconstraint->pktable_name);
+					 fkconstraint->pktable_name);
 				elog(ERROR, "number of key attributes in referenced table must be equal to foreign key");
 			}
 			while (fk_attr != NIL)
 			{
-				id = (Ident *)lfirst(fk_attr);
+				id = (Ident *) lfirst(fk_attr);
 				fk_trigger->args = lappend(fk_trigger->args, id->name);
 
-				id = (Ident *)lfirst(pk_attr);
+				id = (Ident *) lfirst(pk_attr);
 				fk_trigger->args = lappend(fk_trigger->args, id->name);
 
 				fk_attr = lnext(fk_attr);
 				pk_attr = lnext(pk_attr);
 			}
 
-			extras_after = lappend(extras_after, (Node *)fk_trigger);
+			extras_after = lappend(extras_after, (Node *) fk_trigger);
 
 			/*
-			 * Build a CREATE CONSTRAINT TRIGGER statement for the
-			 * ON DELETE action fired on the PK table !!!
+			 * Build a CREATE CONSTRAINT TRIGGER statement for the ON
+			 * DELETE action fired on the PK table !!!
 			 *
 			 */
-			fk_trigger = (CreateTrigStmt *)makeNode(CreateTrigStmt);
-			fk_trigger->trigname		= fkconstraint->constr_name;
-			fk_trigger->relname			= fkconstraint->pktable_name;
-			fk_trigger->before			= false;
-			fk_trigger->row				= true;
-			fk_trigger->actions[0]		= 'd';
-			fk_trigger->actions[1]		= '\0';
-			fk_trigger->lang			= NULL;
-			fk_trigger->text			= NULL;
-			fk_trigger->attr			= NIL;
-			fk_trigger->when			= NULL;
-			fk_trigger->isconstraint	= true;
-			fk_trigger->deferrable		= fkconstraint->deferrable;
-			fk_trigger->initdeferred	= fkconstraint->initdeferred;
-			fk_trigger->constrrelname	= stmt->relname;
+			fk_trigger = (CreateTrigStmt *) makeNode(CreateTrigStmt);
+			fk_trigger->trigname = fkconstraint->constr_name;
+			fk_trigger->relname = fkconstraint->pktable_name;
+			fk_trigger->before = false;
+			fk_trigger->row = true;
+			fk_trigger->actions[0] = 'd';
+			fk_trigger->actions[1] = '\0';
+			fk_trigger->lang = NULL;
+			fk_trigger->text = NULL;
+
+			fk_trigger->attr = NIL;
+			fk_trigger->when = NULL;
+			fk_trigger->isconstraint = true;
+			fk_trigger->deferrable = fkconstraint->deferrable;
+			fk_trigger->initdeferred = fkconstraint->initdeferred;
+			fk_trigger->constrrelname = stmt->relname;
 			switch ((fkconstraint->actions & FKCONSTR_ON_DELETE_MASK)
-							>> FKCONSTR_ON_DELETE_SHIFT)
+					>> FKCONSTR_ON_DELETE_SHIFT)
 			{
 				case FKCONSTR_ON_KEY_NOACTION:
 					fk_trigger->funcname = "RI_FKey_noaction_del";
 					break;
 				case FKCONSTR_ON_KEY_RESTRICT:
-					fk_trigger->deferrable		= false;
-					fk_trigger->initdeferred	= false;
-					fk_trigger->funcname		= "RI_FKey_restrict_del";
+					fk_trigger->deferrable = false;
+					fk_trigger->initdeferred = false;
+					fk_trigger->funcname = "RI_FKey_restrict_del";
 					break;
 				case FKCONSTR_ON_KEY_CASCADE:
 					fk_trigger->funcname = "RI_FKey_cascade_del";
@@ -1157,61 +1172,62 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
 					break;
 			}
 
-			fk_trigger->args		= NIL;
+			fk_trigger->args = NIL;
 			fk_trigger->args = lappend(fk_trigger->args,
-										fkconstraint->constr_name);
+									   fkconstraint->constr_name);
 			fk_trigger->args = lappend(fk_trigger->args,
-										stmt->relname);
+									   stmt->relname);
 			fk_trigger->args = lappend(fk_trigger->args,
-										fkconstraint->pktable_name);
+									   fkconstraint->pktable_name);
 			fk_trigger->args = lappend(fk_trigger->args,
-										fkconstraint->match_type);
+									   fkconstraint->match_type);
 			fk_attr = fkconstraint->fk_attrs;
 			pk_attr = fkconstraint->pk_attrs;
 			while (fk_attr != NIL)
 			{
-				id = (Ident *)lfirst(fk_attr);
+				id = (Ident *) lfirst(fk_attr);
 				fk_trigger->args = lappend(fk_trigger->args, id->name);
 
-				id = (Ident *)lfirst(pk_attr);
+				id = (Ident *) lfirst(pk_attr);
 				fk_trigger->args = lappend(fk_trigger->args, id->name);
 
 				fk_attr = lnext(fk_attr);
 				pk_attr = lnext(pk_attr);
 			}
 
-			extras_after = lappend(extras_after, (Node *)fk_trigger);
+			extras_after = lappend(extras_after, (Node *) fk_trigger);
 
 			/*
-			 * Build a CREATE CONSTRAINT TRIGGER statement for the
-			 * ON UPDATE action fired on the PK table !!!
+			 * Build a CREATE CONSTRAINT TRIGGER statement for the ON
+			 * UPDATE action fired on the PK table !!!
 			 *
 			 */
-			fk_trigger = (CreateTrigStmt *)makeNode(CreateTrigStmt);
-			fk_trigger->trigname		= fkconstraint->constr_name;
-			fk_trigger->relname			= fkconstraint->pktable_name;
-			fk_trigger->before			= false;
-			fk_trigger->row				= true;
-			fk_trigger->actions[0]		= 'u';
-			fk_trigger->actions[1]		= '\0';
-			fk_trigger->lang			= NULL;
-			fk_trigger->text			= NULL;
-			fk_trigger->attr			= NIL;
-			fk_trigger->when			= NULL;
-			fk_trigger->isconstraint	= true;
-			fk_trigger->deferrable		= fkconstraint->deferrable;
-			fk_trigger->initdeferred	= fkconstraint->initdeferred;
-			fk_trigger->constrrelname	= stmt->relname;
+			fk_trigger = (CreateTrigStmt *) makeNode(CreateTrigStmt);
+			fk_trigger->trigname = fkconstraint->constr_name;
+			fk_trigger->relname = fkconstraint->pktable_name;
+			fk_trigger->before = false;
+			fk_trigger->row = true;
+			fk_trigger->actions[0] = 'u';
+			fk_trigger->actions[1] = '\0';
+			fk_trigger->lang = NULL;
+			fk_trigger->text = NULL;
+
+			fk_trigger->attr = NIL;
+			fk_trigger->when = NULL;
+			fk_trigger->isconstraint = true;
+			fk_trigger->deferrable = fkconstraint->deferrable;
+			fk_trigger->initdeferred = fkconstraint->initdeferred;
+			fk_trigger->constrrelname = stmt->relname;
 			switch ((fkconstraint->actions & FKCONSTR_ON_UPDATE_MASK)
-							>> FKCONSTR_ON_UPDATE_SHIFT)
+					>> FKCONSTR_ON_UPDATE_SHIFT)
 			{
 				case FKCONSTR_ON_KEY_NOACTION:
 					fk_trigger->funcname = "RI_FKey_noaction_upd";
 					break;
 				case FKCONSTR_ON_KEY_RESTRICT:
-					fk_trigger->deferrable		= false;
-					fk_trigger->initdeferred	= false;
-					fk_trigger->funcname		= "RI_FKey_restrict_upd";
+					fk_trigger->deferrable = false;
+					fk_trigger->initdeferred = false;
+					fk_trigger->funcname = "RI_FKey_restrict_upd";
 					break;
 				case FKCONSTR_ON_KEY_CASCADE:
 					fk_trigger->funcname = "RI_FKey_cascade_upd";
@@ -1227,30 +1243,30 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
 					break;
 			}
 
-			fk_trigger->args		= NIL;
+			fk_trigger->args = NIL;
 			fk_trigger->args = lappend(fk_trigger->args,
-										fkconstraint->constr_name);
+									   fkconstraint->constr_name);
 			fk_trigger->args = lappend(fk_trigger->args,
-										stmt->relname);
+									   stmt->relname);
 			fk_trigger->args = lappend(fk_trigger->args,
-										fkconstraint->pktable_name);
+									   fkconstraint->pktable_name);
 			fk_trigger->args = lappend(fk_trigger->args,
-										fkconstraint->match_type);
+									   fkconstraint->match_type);
 			fk_attr = fkconstraint->fk_attrs;
 			pk_attr = fkconstraint->pk_attrs;
 			while (fk_attr != NIL)
 			{
-				id = (Ident *)lfirst(fk_attr);
+				id = (Ident *) lfirst(fk_attr);
 				fk_trigger->args = lappend(fk_trigger->args, id->name);
 
-				id = (Ident *)lfirst(pk_attr);
+				id = (Ident *) lfirst(pk_attr);
 				fk_trigger->args = lappend(fk_trigger->args, id->name);
 
 				fk_attr = lnext(fk_attr);
 				pk_attr = lnext(pk_attr);
 			}
 
-			extras_after = lappend(extras_after, (Node *)fk_trigger);
+			extras_after = lappend(extras_after, (Node *) fk_trigger);
 		}
 	}
 
@@ -1408,7 +1424,8 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt)
 
 	qry->qual = transformWhereClause(pstate, stmt->whereClause);
 
-	/* Initial processing of HAVING clause is just like WHERE clause.
+	/*
+	 * Initial processing of HAVING clause is just like WHERE clause.
 	 * Additional work will be done in optimizer/plan/planner.c.
 	 */
 	qry->havingQual = transformWhereClause(pstate, stmt->havingClause);
@@ -1424,7 +1441,7 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt)
 	qry->distinctClause = transformDistinctClause(pstate,
 												  stmt->distinctClause,
 												  qry->targetList,
-												  & qry->sortClause);
+												  &qry->sortClause);
 
 	qry->hasSubLinks = pstate->p_hasSubLinks;
 	qry->hasAggs = pstate->p_hasAggs;
@@ -1506,9 +1523,11 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
 
 		if (resnode->resjunk)
 		{
-			/* Resjunk nodes need no additional processing, but be sure they
-			 * have names and resnos that do not match any target columns;
-			 * else rewriter or planner might get confused.
+
+			/*
+			 * Resjunk nodes need no additional processing, but be sure
+			 * they have names and resnos that do not match any target
+			 * columns; else rewriter or planner might get confused.
 			 */
 			resnode->resname = "?resjunk?";
 			resnode->resno = (AttrNumber) pstate->p_last_resno++;
@@ -1551,38 +1570,42 @@ transformCursorStmt(ParseState *pstate, SelectStmt *stmt)
 
 /*
  * tranformAlterTableStmt -
- * 	transform an Alter Table Statement
+ *	transform an Alter Table Statement
  *
  */
 static Query *
-transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt) 
+transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt)
 {
-	Query *qry;
+	Query	   *qry;
+
 	qry = makeNode(Query);
 	qry->commandType = CMD_UTILITY;
 
-	/* 
-	 * The only subtypes that currently have special handling are
-	 *	'A'dd column and Add 'C'onstraint.  In addition, right now
-	 *	only Foreign Key 'C'onstraints have a special transformation.
+	/*
+	 * The only subtypes that currently have special handling are 'A'dd
+	 * column and Add 'C'onstraint.  In addition, right now only Foreign
+	 * Key 'C'onstraints have a special transformation.
 	 *
 	 */
-	switch (stmt->subtype) {
+	switch (stmt->subtype)
+	{
 		case 'A':
 			transformColumnType(pstate, (ColumnDef *) stmt->def);
 			break;
-		case 'C':  
-			if (stmt->def && nodeTag(stmt->def) == T_FkConstraint )
+		case 'C':
+			if (stmt->def && nodeTag(stmt->def) == T_FkConstraint)
 			{
-				CreateTrigStmt	   *fk_trigger;
-				List			   *fk_attr;
-				List			   *pk_attr;
-				Ident			   *id;
-				FkConstraint	*fkconstraint;
+				CreateTrigStmt *fk_trigger;
+				List	   *fk_attr;
+				List	   *pk_attr;
+				Ident	   *id;
+				FkConstraint *fkconstraint;
+
 				extras_after = NIL;
 				elog(NOTICE, "ALTER TABLE ... ADD CONSTRAINT will create implicit trigger(s) for FOREIGN KEY check(s)");
 
 				fkconstraint = (FkConstraint *) stmt->def;
+
 				/*
 				 * If the constraint has no name, set it to <unnamed>
 				 *
@@ -1599,69 +1622,70 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt)
 					transformFkeyGetPrimaryKey(fkconstraint);
 
 				/*
-				 * Build a CREATE CONSTRAINT TRIGGER statement for the CHECK
-				 * action.
+				 * Build a CREATE CONSTRAINT TRIGGER statement for the
+				 * CHECK action.
 				 *
 				 */
-				fk_trigger = (CreateTrigStmt *)makeNode(CreateTrigStmt);
-				fk_trigger->trigname		= fkconstraint->constr_name;
-				fk_trigger->relname			= stmt->relname;
-				fk_trigger->funcname		= "RI_FKey_check_ins";
-				fk_trigger->before			= false;
-				fk_trigger->row				= true;
-				fk_trigger->actions[0]		= 'i';
-				fk_trigger->actions[1]		= 'u';
-				fk_trigger->actions[2]		= '\0';
-				fk_trigger->lang			= NULL;
-				fk_trigger->text			= NULL;
-				fk_trigger->attr			= NIL;
-				fk_trigger->when			= NULL;
-				fk_trigger->isconstraint	= true;
-				fk_trigger->deferrable		= fkconstraint->deferrable;
-				fk_trigger->initdeferred	= fkconstraint->initdeferred;
-				fk_trigger->constrrelname	= fkconstraint->pktable_name;
-
-				fk_trigger->args		= NIL;
+				fk_trigger = (CreateTrigStmt *) makeNode(CreateTrigStmt);
+				fk_trigger->trigname = fkconstraint->constr_name;
+				fk_trigger->relname = stmt->relname;
+				fk_trigger->funcname = "RI_FKey_check_ins";
+				fk_trigger->before = false;
+				fk_trigger->row = true;
+				fk_trigger->actions[0] = 'i';
+				fk_trigger->actions[1] = 'u';
+				fk_trigger->actions[2] = '\0';
+				fk_trigger->lang = NULL;
+				fk_trigger->text = NULL;
+
+				fk_trigger->attr = NIL;
+				fk_trigger->when = NULL;
+				fk_trigger->isconstraint = true;
+				fk_trigger->deferrable = fkconstraint->deferrable;
+				fk_trigger->initdeferred = fkconstraint->initdeferred;
+				fk_trigger->constrrelname = fkconstraint->pktable_name;
+
+				fk_trigger->args = NIL;
 				fk_trigger->args = lappend(fk_trigger->args,
-										fkconstraint->constr_name);
+										   fkconstraint->constr_name);
 				fk_trigger->args = lappend(fk_trigger->args,
-										stmt->relname);
+										   stmt->relname);
 				fk_trigger->args = lappend(fk_trigger->args,
-										fkconstraint->pktable_name);
+										   fkconstraint->pktable_name);
 				fk_trigger->args = lappend(fk_trigger->args,
-										fkconstraint->match_type);
+										   fkconstraint->match_type);
 				fk_attr = fkconstraint->fk_attrs;
 				pk_attr = fkconstraint->pk_attrs;
 				if (length(fk_attr) != length(pk_attr))
 				{
 					elog(NOTICE, "Illegal FOREIGN KEY definition REFERENCES \"%s\"",
-								fkconstraint->pktable_name);
+						 fkconstraint->pktable_name);
 					elog(ERROR, "number of key attributes in referenced table must be equal to foreign key");
 				}
 				while (fk_attr != NIL)
 				{
-					id = (Ident *)lfirst(fk_attr);
+					id = (Ident *) lfirst(fk_attr);
 					fk_trigger->args = lappend(fk_trigger->args, id->name);
-	
-					id = (Ident *)lfirst(pk_attr);
+
+					id = (Ident *) lfirst(pk_attr);
 					fk_trigger->args = lappend(fk_trigger->args, id->name);
 
 					fk_attr = lnext(fk_attr);
 					pk_attr = lnext(pk_attr);
 				}
 
-				extras_after = lappend(extras_after, (Node *)fk_trigger);
+				extras_after = lappend(extras_after, (Node *) fk_trigger);
 
 				/*
-				 * Build a CREATE CONSTRAINT TRIGGER statement for the
-				 * ON DELETE action fired on the PK table !!!
+				 * Build a CREATE CONSTRAINT TRIGGER statement for the ON
+				 * DELETE action fired on the PK table !!!
 				 *
 				 */
-				fk_trigger = (CreateTrigStmt *)makeNode(CreateTrigStmt);
-				fk_trigger->trigname		= fkconstraint->constr_name;
-				fk_trigger->relname			= fkconstraint->pktable_name;
+				fk_trigger = (CreateTrigStmt *) makeNode(CreateTrigStmt);
+				fk_trigger->trigname = fkconstraint->constr_name;
+				fk_trigger->relname = fkconstraint->pktable_name;
 				switch ((fkconstraint->actions & FKCONSTR_ON_DELETE_MASK)
-								>> FKCONSTR_ON_DELETE_SHIFT)
+						>> FKCONSTR_ON_DELETE_SHIFT)
 				{
 					case FKCONSTR_ON_KEY_NOACTION:
 						fk_trigger->funcname = "RI_FKey_noaction_del";
@@ -1682,54 +1706,55 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt)
 						elog(ERROR, "Only one ON DELETE action can be specified for FOREIGN KEY constraint");
 						break;
 				}
-				fk_trigger->before			= false;
-				fk_trigger->row				= true;
-				fk_trigger->actions[0]		= 'd';
-				fk_trigger->actions[1]		= '\0';
-				fk_trigger->lang			= NULL;
-				fk_trigger->text			= NULL;
-				fk_trigger->attr			= NIL;
-				fk_trigger->when			= NULL;
-				fk_trigger->isconstraint	= true;
-				fk_trigger->deferrable		= fkconstraint->deferrable;
-				fk_trigger->initdeferred	= fkconstraint->initdeferred;
-				fk_trigger->constrrelname	= stmt->relname;
-
-				fk_trigger->args		= NIL;
+				fk_trigger->before = false;
+				fk_trigger->row = true;
+				fk_trigger->actions[0] = 'd';
+				fk_trigger->actions[1] = '\0';
+				fk_trigger->lang = NULL;
+				fk_trigger->text = NULL;
+
+				fk_trigger->attr = NIL;
+				fk_trigger->when = NULL;
+				fk_trigger->isconstraint = true;
+				fk_trigger->deferrable = fkconstraint->deferrable;
+				fk_trigger->initdeferred = fkconstraint->initdeferred;
+				fk_trigger->constrrelname = stmt->relname;
+
+				fk_trigger->args = NIL;
 				fk_trigger->args = lappend(fk_trigger->args,
-										fkconstraint->constr_name);
+										   fkconstraint->constr_name);
 				fk_trigger->args = lappend(fk_trigger->args,
-										stmt->relname);
+										   stmt->relname);
 				fk_trigger->args = lappend(fk_trigger->args,
-										fkconstraint->pktable_name);
+										   fkconstraint->pktable_name);
 				fk_trigger->args = lappend(fk_trigger->args,
-										fkconstraint->match_type);
+										   fkconstraint->match_type);
 				fk_attr = fkconstraint->fk_attrs;
 				pk_attr = fkconstraint->pk_attrs;
 				while (fk_attr != NIL)
 				{
-					id = (Ident *)lfirst(fk_attr);
+					id = (Ident *) lfirst(fk_attr);
 					fk_trigger->args = lappend(fk_trigger->args, id->name);
 
-					id = (Ident *)lfirst(pk_attr);
+					id = (Ident *) lfirst(pk_attr);
 					fk_trigger->args = lappend(fk_trigger->args, id->name);
 
 					fk_attr = lnext(fk_attr);
 					pk_attr = lnext(pk_attr);
 				}
 
-				extras_after = lappend(extras_after, (Node *)fk_trigger);
+				extras_after = lappend(extras_after, (Node *) fk_trigger);
 
 				/*
-				 * Build a CREATE CONSTRAINT TRIGGER statement for the
-				 * ON UPDATE action fired on the PK table !!!
+				 * Build a CREATE CONSTRAINT TRIGGER statement for the ON
+				 * UPDATE action fired on the PK table !!!
 				 *
 				 */
-				fk_trigger = (CreateTrigStmt *)makeNode(CreateTrigStmt);
-				fk_trigger->trigname		= fkconstraint->constr_name;
-				fk_trigger->relname			= fkconstraint->pktable_name;
+				fk_trigger = (CreateTrigStmt *) makeNode(CreateTrigStmt);
+				fk_trigger->trigname = fkconstraint->constr_name;
+				fk_trigger->relname = fkconstraint->pktable_name;
 				switch ((fkconstraint->actions & FKCONSTR_ON_UPDATE_MASK)
-								>> FKCONSTR_ON_UPDATE_SHIFT)
+						>> FKCONSTR_ON_UPDATE_SHIFT)
 				{
 					case FKCONSTR_ON_KEY_NOACTION:
 						fk_trigger->funcname = "RI_FKey_noaction_upd";
@@ -1750,43 +1775,44 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt)
 						elog(ERROR, "Only one ON UPDATE action can be specified for FOREIGN KEY constraint");
 						break;
 				}
-				fk_trigger->before			= false;
-				fk_trigger->row				= true;
-				fk_trigger->actions[0]		= 'u';
-				fk_trigger->actions[1]		= '\0';
-				fk_trigger->lang			= NULL;
-				fk_trigger->text			= NULL;
-				fk_trigger->attr			= NIL;
-				fk_trigger->when			= NULL;
-				fk_trigger->isconstraint	= true;
-				fk_trigger->deferrable		= fkconstraint->deferrable;
-				fk_trigger->initdeferred	= fkconstraint->initdeferred;
-				fk_trigger->constrrelname	= stmt->relname;
-
-				fk_trigger->args		= NIL;
+				fk_trigger->before = false;
+				fk_trigger->row = true;
+				fk_trigger->actions[0] = 'u';
+				fk_trigger->actions[1] = '\0';
+				fk_trigger->lang = NULL;
+				fk_trigger->text = NULL;
+
+				fk_trigger->attr = NIL;
+				fk_trigger->when = NULL;
+				fk_trigger->isconstraint = true;
+				fk_trigger->deferrable = fkconstraint->deferrable;
+				fk_trigger->initdeferred = fkconstraint->initdeferred;
+				fk_trigger->constrrelname = stmt->relname;
+
+				fk_trigger->args = NIL;
 				fk_trigger->args = lappend(fk_trigger->args,
-										fkconstraint->constr_name);
+										   fkconstraint->constr_name);
 				fk_trigger->args = lappend(fk_trigger->args,
-										stmt->relname);
+										   stmt->relname);
 				fk_trigger->args = lappend(fk_trigger->args,
-										fkconstraint->pktable_name);
+										   fkconstraint->pktable_name);
 				fk_trigger->args = lappend(fk_trigger->args,
-										fkconstraint->match_type);
+										   fkconstraint->match_type);
 				fk_attr = fkconstraint->fk_attrs;
 				pk_attr = fkconstraint->pk_attrs;
 				while (fk_attr != NIL)
 				{
-					id = (Ident *)lfirst(fk_attr);
+					id = (Ident *) lfirst(fk_attr);
 					fk_trigger->args = lappend(fk_trigger->args, id->name);
 
-					id = (Ident *)lfirst(pk_attr);
+					id = (Ident *) lfirst(pk_attr);
 					fk_trigger->args = lappend(fk_trigger->args, id->name);
 
 					fk_attr = lnext(fk_attr);
 					pk_attr = lnext(pk_attr);
 				}
 
-				extras_after = lappend(extras_after, (Node *)fk_trigger);
+				extras_after = lappend(extras_after, (Node *) fk_trigger);
 			}
 			break;
 		default:
@@ -1975,16 +2001,16 @@ transformForUpdate(Query *qry, List *forUpdate)
 static void
 transformFkeyGetPrimaryKey(FkConstraint *fkconstraint)
 {
-	Relation			pkrel;
-	Form_pg_attribute  *pkrel_attrs;
-	Relation			indexRd;
-	HeapScanDesc		indexSd;
-	ScanKeyData			key;
-	HeapTuple			indexTup;
-	Form_pg_index		indexStruct = NULL;
-	Ident			   *pkattr;
-	int					pkattno;
-	int					i;
+	Relation	pkrel;
+	Form_pg_attribute *pkrel_attrs;
+	Relation	indexRd;
+	HeapScanDesc indexSd;
+	ScanKeyData key;
+	HeapTuple	indexTup;
+	Form_pg_index indexStruct = NULL;
+	Ident	   *pkattr;
+	int			pkattno;
+	int			i;
 
 	/* ----------
 	 * Open the referenced table and get the attributes list
@@ -1993,7 +2019,7 @@ transformFkeyGetPrimaryKey(FkConstraint *fkconstraint)
 	pkrel = heap_openr(fkconstraint->pktable_name, AccessShareLock);
 	if (pkrel == NULL)
 		elog(ERROR, "referenced table \"%s\" not found",
-						fkconstraint->pktable_name);
+			 fkconstraint->pktable_name);
 	pkrel_attrs = pkrel->rd_att->attrs;
 
 	/* ----------
@@ -2003,13 +2029,13 @@ transformFkeyGetPrimaryKey(FkConstraint *fkconstraint)
 	 */
 	indexRd = heap_openr(IndexRelationName, AccessShareLock);
 	ScanKeyEntryInitialize(&key, 0, Anum_pg_index_indrelid,
-								F_OIDEQ,
-								ObjectIdGetDatum(pkrel->rd_id));
-    indexSd = heap_beginscan(indexRd,   /* scan desc */
-								false,     /* scan backward flag */
-								SnapshotNow,       /* NOW snapshot */
-								1, /* number scan keys */
-								&key);     /* scan keys */
+						   F_OIDEQ,
+						   ObjectIdGetDatum(pkrel->rd_id));
+	indexSd = heap_beginscan(indexRd,	/* scan desc */
+							 false,		/* scan backward flag */
+							 SnapshotNow,		/* NOW snapshot */
+							 1, /* number scan keys */
+							 &key);		/* scan keys */
 
 	/* ----------
 	 * Fetch the index with indisprimary == true
@@ -2020,9 +2046,7 @@ transformFkeyGetPrimaryKey(FkConstraint *fkconstraint)
 		indexStruct = (Form_pg_index) GETSTRUCT(indexTup);
 
 		if (indexStruct->indisprimary)
-		{
 			break;
-		}
 	}
 
 	/* ----------
@@ -2031,7 +2055,7 @@ transformFkeyGetPrimaryKey(FkConstraint *fkconstraint)
 	 */
 	if (!HeapTupleIsValid(indexTup))
 		elog(ERROR, "PRIMARY KEY for referenced table \"%s\" not found",
-					fkconstraint->pktable_name);
+			 fkconstraint->pktable_name);
 
 	/* ----------
 	 * Now build the list of PK attributes from the indkey definition
@@ -2041,7 +2065,7 @@ transformFkeyGetPrimaryKey(FkConstraint *fkconstraint)
 	for (i = 0; i < INDEX_MAX_KEYS && indexStruct->indkey[i] != 0; i++)
 	{
 		pkattno = indexStruct->indkey[i];
-		pkattr = (Ident *)makeNode(Ident);
+		pkattr = (Ident *) makeNode(Ident);
 		pkattr->name = nameout(&(pkrel_attrs[pkattno - 1]->attname));
 		pkattr->indirection = NIL;
 		pkattr->isRel = false;
@@ -2076,9 +2100,9 @@ transformConstraintAttrs(List *constraintList)
 
 	foreach(clist, constraintList)
 	{
-		Node   *node = lfirst(clist);
+		Node	   *node = lfirst(clist);
 
-		if (! IsA(node, Constraint))
+		if (!IsA(node, Constraint))
 		{
 			lastprimarynode = node;
 			/* reset flags for new primary node */
@@ -2087,13 +2111,13 @@ transformConstraintAttrs(List *constraintList)
 		}
 		else
 		{
-			Constraint	   *con = (Constraint *) node;
+			Constraint *con = (Constraint *) node;
 
 			switch (con->contype)
 			{
 				case CONSTR_ATTR_DEFERRABLE:
 					if (lastprimarynode == NULL ||
-						! IsA(lastprimarynode, FkConstraint))
+						!IsA(lastprimarynode, FkConstraint))
 						elog(ERROR, "Misplaced DEFERRABLE clause");
 					if (saw_deferrability)
 						elog(ERROR, "Multiple DEFERRABLE/NOT DEFERRABLE clauses not allowed");
@@ -2102,7 +2126,7 @@ transformConstraintAttrs(List *constraintList)
 					break;
 				case CONSTR_ATTR_NOT_DEFERRABLE:
 					if (lastprimarynode == NULL ||
-						! IsA(lastprimarynode, FkConstraint))
+						!IsA(lastprimarynode, FkConstraint))
 						elog(ERROR, "Misplaced NOT DEFERRABLE clause");
 					if (saw_deferrability)
 						elog(ERROR, "Multiple DEFERRABLE/NOT DEFERRABLE clauses not allowed");
@@ -2114,21 +2138,25 @@ transformConstraintAttrs(List *constraintList)
 					break;
 				case CONSTR_ATTR_DEFERRED:
 					if (lastprimarynode == NULL ||
-						! IsA(lastprimarynode, FkConstraint))
+						!IsA(lastprimarynode, FkConstraint))
 						elog(ERROR, "Misplaced INITIALLY DEFERRED clause");
 					if (saw_initially)
 						elog(ERROR, "Multiple INITIALLY IMMEDIATE/DEFERRED clauses not allowed");
 					saw_initially = true;
 					((FkConstraint *) lastprimarynode)->initdeferred = true;
-					/* If only INITIALLY DEFERRED appears, assume DEFERRABLE */
-					if (! saw_deferrability)
+
+					/*
+					 * If only INITIALLY DEFERRED appears, assume
+					 * DEFERRABLE
+					 */
+					if (!saw_deferrability)
 						((FkConstraint *) lastprimarynode)->deferrable = true;
-					else if (! ((FkConstraint *) lastprimarynode)->deferrable)
+					else if (!((FkConstraint *) lastprimarynode)->deferrable)
 						elog(ERROR, "INITIALLY DEFERRED constraint must be DEFERRABLE");
 					break;
 				case CONSTR_ATTR_IMMEDIATE:
 					if (lastprimarynode == NULL ||
-						! IsA(lastprimarynode, FkConstraint))
+						!IsA(lastprimarynode, FkConstraint))
 						elog(ERROR, "Misplaced INITIALLY IMMEDIATE clause");
 					if (saw_initially)
 						elog(ERROR, "Multiple INITIALLY IMMEDIATE/DEFERRED clauses not allowed");
@@ -2153,9 +2181,10 @@ transformConstraintAttrs(List *constraintList)
 static void
 transformColumnType(ParseState *pstate, ColumnDef *column)
 {
+
 	/*
-	 * If the column doesn't have an explicitly specified typmod,
-	 * check to see if we want to insert a default length.
+	 * If the column doesn't have an explicitly specified typmod, check to
+	 * see if we want to insert a default length.
 	 *
 	 * Note that we deliberately do NOT look at array or set information
 	 * here; "numeric[]" needs the same default typmod as "numeric".
@@ -2164,13 +2193,13 @@ transformColumnType(ParseState *pstate, ColumnDef *column)
 	{
 		switch (typeTypeId(typenameType(column->typename->name)))
 		{
-			case BPCHAROID:
+				case BPCHAROID:
 				/* "char" -> "char(1)" */
 				column->typename->typmod = VARHDRSZ + 1;
 				break;
 			case NUMERICOID:
 				column->typename->typmod = VARHDRSZ +
-					((NUMERIC_DEFAULT_PRECISION<<16) | NUMERIC_DEFAULT_SCALE);
+					((NUMERIC_DEFAULT_PRECISION << 16) | NUMERIC_DEFAULT_SCALE);
 				break;
 		}
 	}
diff --git a/src/backend/parser/keywords.c b/src/backend/parser/keywords.c
index cd1b66a7f8e03afe692b9f0be5d42e014ef29476..f30abe49153991a7e7859576caec54aefcc7b3b0 100644
--- a/src/backend/parser/keywords.c
+++ b/src/backend/parser/keywords.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.70 2000/04/07 13:39:34 thomas Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.71 2000/04/12 17:15:26 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -227,7 +227,7 @@ static ScanKeyword ScanKeywords[] = {
 	{"stdin", STDIN},
 	{"stdout", STDOUT},
 	{"substring", SUBSTRING},
-    {"sysid", SYSID},
+	{"sysid", SYSID},
 	{"table", TABLE},
 	{"temp", TEMP},
 	{"temporary", TEMPORARY},
diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c
index 8a37485bbd68587e76ce2472de4e7f209072610e..fff451206bb95d80e1b746451dd1b2a58d9de9c5 100644
--- a/src/backend/parser/parse_agg.c
+++ b/src/backend/parser/parse_agg.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.36 2000/03/17 02:36:17 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.37 2000/04/12 17:15:26 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -24,15 +24,16 @@
 #include "utils/lsyscache.h"
 #include "utils/syscache.h"
 
-typedef struct {
+typedef struct
+{
 	ParseState *pstate;
 	List	   *groupClauses;
 } check_ungrouped_columns_context;
 
 static void check_ungrouped_columns(Node *node, ParseState *pstate,
-									List *groupClauses);
+						List *groupClauses);
 static bool check_ungrouped_columns_walker(Node *node,
-										   check_ungrouped_columns_context *context);
+							   check_ungrouped_columns_context *context);
 
 /*
  * check_ungrouped_columns -
@@ -46,7 +47,7 @@ static bool check_ungrouped_columns_walker(Node *node,
  *
  * NOTE: in the case of a SubLink, expression_tree_walker does not descend
  * into the subquery.  This means we will fail to detect ungrouped columns
- * that appear as outer-level variables within a subquery.  That case seems
+ * that appear as outer-level variables within a subquery.	That case seems
  * unreasonably hard to handle here.  Instead, we expect the planner to check
  * for ungrouped columns after it's found all the outer-level references
  * inside the subquery and converted them into a list of parameters for the
@@ -56,7 +57,7 @@ static void
 check_ungrouped_columns(Node *node, ParseState *pstate,
 						List *groupClauses)
 {
-	check_ungrouped_columns_context	context;
+	check_ungrouped_columns_context context;
 
 	context.pstate = pstate;
 	context.groupClauses = groupClauses;
@@ -71,13 +72,16 @@ check_ungrouped_columns_walker(Node *node,
 
 	if (node == NULL)
 		return false;
-	if (IsA(node, Const) || IsA(node, Param))
+	if (IsA(node, Const) ||IsA(node, Param))
 		return false;			/* constants are always acceptable */
+
 	/*
-	 * If we find an aggregate function, do not recurse into its arguments.
+	 * If we find an aggregate function, do not recurse into its
+	 * arguments.
 	 */
 	if (IsA(node, Aggref))
 		return false;
+
 	/*
 	 * Check to see if subexpression as a whole matches any GROUP BY item.
 	 * We need to do this at every recursion level so that we recognize
@@ -88,17 +92,19 @@ check_ungrouped_columns_walker(Node *node,
 		if (equal(node, lfirst(gl)))
 			return false;		/* acceptable, do not descend more */
 	}
+
 	/*
 	 * If we have an ungrouped Var, we have a failure --- unless it is an
 	 * outer-level Var.  In that case it's a constant as far as this query
-	 * level is concerned, and we can accept it.  (If it's ungrouped as far
-	 * as the upper query is concerned, that's someone else's problem...)
+	 * level is concerned, and we can accept it.  (If it's ungrouped as
+	 * far as the upper query is concerned, that's someone else's
+	 * problem...)
 	 */
 	if (IsA(node, Var))
 	{
-		Var			   *var = (Var *) node;
-		RangeTblEntry  *rte;
-		char		   *attname;
+		Var		   *var = (Var *) node;
+		RangeTblEntry *rte;
+		char	   *attname;
 
 		if (var->varlevelsup > 0)
 			return false;		/* outer-level Var is acceptable */
@@ -107,7 +113,7 @@ check_ungrouped_columns_walker(Node *node,
 			   (int) var->varno <= length(context->pstate->p_rtable));
 		rte = rt_fetch(var->varno, context->pstate->p_rtable);
 		attname = get_attname(rte->relid, var->varattno);
-		if (! attname)
+		if (!attname)
 			elog(ERROR, "cache lookup of attribute %d in relation %u failed",
 				 var->varattno, rte->relid);
 		elog(ERROR, "Attribute %s.%s must be GROUPed or used in an aggregate function",
@@ -139,9 +145,9 @@ parseCheckAggregates(ParseState *pstate, Query *qry)
 	/*
 	 * Aggregates must never appear in WHERE clauses. (Note this check
 	 * should appear first to deliver an appropriate error message;
-	 * otherwise we are likely to complain about some innocent variable
-	 * in the target list, which is outright misleading if the problem
-	 * is in WHERE.)
+	 * otherwise we are likely to complain about some innocent variable in
+	 * the target list, which is outright misleading if the problem is in
+	 * WHERE.)
 	 */
 	if (contain_agg_clause(qry->qual))
 		elog(ERROR, "Aggregates not allowed in WHERE clause");
@@ -149,14 +155,14 @@ parseCheckAggregates(ParseState *pstate, Query *qry)
 	/*
 	 * No aggregates allowed in GROUP BY clauses, either.
 	 *
-	 * While we are at it, build a list of the acceptable GROUP BY expressions
-	 * for use by check_ungrouped_columns() (this avoids repeated scans of the
-	 * targetlist within the recursive routine...)
+	 * While we are at it, build a list of the acceptable GROUP BY
+	 * expressions for use by check_ungrouped_columns() (this avoids
+	 * repeated scans of the targetlist within the recursive routine...)
 	 */
 	foreach(tl, qry->groupClause)
 	{
 		GroupClause *grpcl = lfirst(tl);
-		Node		*expr;
+		Node	   *expr;
 
 		expr = get_sortgroupclause_expr(grpcl, qry->targetList);
 		if (contain_agg_clause(expr))
@@ -198,16 +204,16 @@ ParseAgg(ParseState *pstate, char *aggname, Oid basetype,
 	/*
 	 * There used to be a really ugly hack for count(*) here.
 	 *
-	 * It's gone.  Now, the grammar transforms count(*) into count(1),
-	 * which does the right thing.  (It didn't use to do the right thing,
-	 * because the optimizer had the wrong ideas about semantics of queries
-	 * without explicit variables.  Fixed as of Oct 1999 --- tgl.)
+	 * It's gone.  Now, the grammar transforms count(*) into count(1), which
+	 * does the right thing.  (It didn't use to do the right thing,
+	 * because the optimizer had the wrong ideas about semantics of
+	 * queries without explicit variables.	Fixed as of Oct 1999 --- tgl.)
 	 *
-	 * Since "1" never evaluates as null, we currently have no need of
-	 * the "usenulls" flag, but it should be kept around; in fact, we should
+	 * Since "1" never evaluates as null, we currently have no need of the
+	 * "usenulls" flag, but it should be kept around; in fact, we should
 	 * extend the pg_aggregate table to let usenulls be specified as an
-	 * attribute of user-defined aggregates.  In the meantime, usenulls
-	 * is just always set to "false".
+	 * attribute of user-defined aggregates.  In the meantime, usenulls is
+	 * just always set to "false".
 	 */
 
 	aggform = (Form_pg_aggregate) GETSTRUCT(theAggTuple);
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c
index d2ceac82732a4dd6b3116966d7ca1a8863b018fc..ec33e5c309094f08db22c1a3e279bb02cf24a6ab 100644
--- a/src/backend/parser/parse_clause.c
+++ b/src/backend/parser/parse_clause.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.58 2000/03/23 07:38:30 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.59 2000/04/12 17:15:26 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -33,15 +33,16 @@
 static char *clauseText[] = {"ORDER BY", "GROUP BY", "DISTINCT ON"};
 
 static TargetEntry *findTargetlistEntry(ParseState *pstate, Node *node,
-										List *tlist, int clause);
+					List *tlist, int clause);
 static void parseFromClause(ParseState *pstate, List *frmList);
 RangeTblEntry *transformTableEntry(ParseState *pstate, RangeVar *r);
 static List *addTargetToSortList(TargetEntry *tle, List *sortlist,
-								 List *targetlist, char *opname);
+					List *targetlist, char *opname);
 static bool exprIsInSortList(Node *expr, List *sortList, List *targetList);
 
 #ifndef DISABLE_OUTER_JOINS
 static Node *transformUsingClause(ParseState *pstate, List *using, List *left, List *right);
+
 #endif
 
 
@@ -63,8 +64,8 @@ makeRangeTable(ParseState *pstate, List *frmList)
  *
  *	  Note that the target is not marked as either inFromCl or inJoinSet.
  *	  For INSERT, we don't want the target to be joined to; it's a
- *	  destination of tuples, not a source.  For UPDATE/DELETE, we do
- *	  need to scan or join the target.  This will happen without the
+ *	  destination of tuples, not a source.	For UPDATE/DELETE, we do
+ *	  need to scan or join the target.	This will happen without the
  *	  inJoinSet flag because the planner's preprocess_targetlist()
  *	  adds the destination's CTID attribute to the targetlist, and
  *	  therefore the destination will be a referenced table even if
@@ -94,7 +95,7 @@ setTargetTable(ParseState *pstate, char *relname)
 
 
 Node *
-mergeInnerJoinQuals(ParseState *pstate, Node *clause);
+			mergeInnerJoinQuals(ParseState *pstate, Node *clause);
 
 Node *
 mergeInnerJoinQuals(ParseState *pstate, Node *clause)
@@ -119,7 +120,7 @@ mergeInnerJoinQuals(ParseState *pstate, Node *clause)
 	pstate->p_join_quals = NULL;
 
 	return (Node *) expr;
-} /* mergeInnerJoinQuals() */
+}	/* mergeInnerJoinQuals() */
 
 /*
  * transformWhereClause -
@@ -150,12 +151,12 @@ transformWhereClause(ParseState *pstate, Node *clause)
 
 #ifndef DISABLE_JOIN_SYNTAX
 char *
-AttrString(Attr *attr);
+			AttrString(Attr *attr);
 
 char *
 AttrString(Attr *attr)
 {
-	Value *val;
+	Value	   *val;
 
 	Assert(length(attr->attrs) == 1);
 
@@ -167,17 +168,18 @@ AttrString(Attr *attr)
 }
 
 List *
-ListTableAsAttrs(ParseState *pstate, char *table);
+			ListTableAsAttrs(ParseState *pstate, char *table);
 List *
 ListTableAsAttrs(ParseState *pstate, char *table)
 {
-	Attr *attr = expandTable(pstate, table, TRUE);
-	List *rlist = NIL;
-	List *col;
+	Attr	   *attr = expandTable(pstate, table, TRUE);
+	List	   *rlist = NIL;
+	List	   *col;
 
 	foreach(col, attr->attrs)
 	{
-		Attr *a = makeAttr(table, strVal((Value *) lfirst(col)));
+		Attr	   *a = makeAttr(table, strVal((Value *) lfirst(col)));
+
 		rlist = lappend(rlist, a);
 	}
 
@@ -185,25 +187,26 @@ ListTableAsAttrs(ParseState *pstate, char *table)
 }
 
 List *
-makeUniqueAttrList(List *candidates, List *idents);
+			makeUniqueAttrList(List *candidates, List *idents);
 List *
 makeUniqueAttrList(List *attrs, List *filter)
 {
-	List *result = NULL;
-	List *candidate;
+	List	   *result = NULL;
+	List	   *candidate;
 
 	foreach(candidate, attrs)
 	{
-		List *fmember;
-		bool match = FALSE;
-		Attr *cattr = lfirst(candidate);
+		List	   *fmember;
+		bool		match = FALSE;
+		Attr	   *cattr = lfirst(candidate);
 
 		Assert(IsA(cattr, Attr));
 		Assert(length(cattr->attrs) == 1);
 
 		foreach(fmember, filter)
 		{
-			Attr *fattr = lfirst(fmember);
+			Attr	   *fattr = lfirst(fmember);
+
 			Assert(IsA(fattr, Attr));
 			Assert(length(fattr->attrs) == 1);
 
@@ -222,19 +225,19 @@ makeUniqueAttrList(List *attrs, List *filter)
 }
 
 List *
-makeAttrList(Attr *attr);
+			makeAttrList(Attr *attr);
 
 List *
 makeAttrList(Attr *attr)
 {
-	List *result = NULL;
+	List	   *result = NULL;
 
-	char *name = attr->relname;
-	List *col;
+	char	   *name = attr->relname;
+	List	   *col;
 
-	foreach (col, attr->attrs)
+	foreach(col, attr->attrs)
 	{
-		Attr *newattr = makeAttr(name, strVal((Value *) lfirst(col)));
+		Attr	   *newattr = makeAttr(name, strVal((Value *) lfirst(col)));
 
 		result = lappend(result, newattr);
 	}
@@ -247,13 +250,13 @@ makeAttrList(Attr *attr)
  * with one attribute name per node.
  */
 List *
-ExpandAttrs(Attr *attr);
+			ExpandAttrs(Attr *attr);
 List *
 ExpandAttrs(Attr *attr)
 {
-	List *col;
-	char *relname = attr->relname;
-	List *rlist = NULL;
+	List	   *col;
+	char	   *relname = attr->relname;
+	List	   *rlist = NULL;
 
 	Assert(attr != NULL);
 
@@ -262,7 +265,7 @@ ExpandAttrs(Attr *attr)
 
 	foreach(col, attr->attrs)
 	{
-		Attr *attr = lfirst(col);
+		Attr	   *attr = lfirst(col);
 
 		rlist = lappend(rlist, makeAttr(relname, AttrString(attr)));
 	}
@@ -281,18 +284,20 @@ transformUsingClause(ParseState *pstate, List *usingList, List *leftList, List *
 
 	foreach(using, usingList)
 	{
-		List *col;
-		A_Expr *e;
+		List	   *col;
+		A_Expr	   *e;
 
-		Attr *uattr = lfirst(using);
-		Attr *lattr = NULL, *rattr = NULL;
+		Attr	   *uattr = lfirst(using);
+		Attr	   *lattr = NULL,
+				   *rattr = NULL;
 
-		/* find the first instances of this column in the shape list
-		 * and the last table in the shape list...
+		/*
+		 * find the first instances of this column in the shape list and
+		 * the last table in the shape list...
 		 */
-		foreach (col, leftList)
+		foreach(col, leftList)
 		{
-			Attr *attr = lfirst(col);
+			Attr	   *attr = lfirst(col);
 
 			if (strcmp(AttrString(attr), AttrString(uattr)) == 0)
 			{
@@ -300,9 +305,9 @@ transformUsingClause(ParseState *pstate, List *usingList, List *leftList, List *
 				break;
 			}
 		}
-		foreach (col, rightList)
+		foreach(col, rightList)
 		{
-			Attr *attr = lfirst(col);
+			Attr	   *attr = lfirst(col);
 
 			if (strcmp(AttrString(attr), AttrString(uattr)) == 0)
 			{
@@ -334,7 +339,8 @@ transformUsingClause(ParseState *pstate, List *usingList, List *leftList, List *
 	}
 
 	return ((Node *) transformExpr(pstate, (Node *) expr, EXPR_COLUMN_FIRST));
-} /* transformUsiongClause() */
+}	/* transformUsiongClause() */
+
 #endif
 
 
@@ -343,9 +349,11 @@ transformTableEntry(ParseState *pstate, RangeVar *r)
 {
 	RelExpr    *baserel = r->relExpr;
 	char	   *relname = baserel->relname;
+
 #if 0
 	char	   *refname;
 	List	   *columns;
+
 #endif
 	RangeTblEntry *rte;
 
@@ -368,7 +376,7 @@ transformTableEntry(ParseState *pstate, RangeVar *r)
 				if (length(columns) != length(r->name->attrs))
 					elog(ERROR, "'%s' has %d columns but %d %s specified",
 						 relname, length(columns), length(r->name->attrs),
-						 ((length(r->name->attrs) != 1)? "aliases": "alias"));
+						 ((length(r->name->attrs) != 1) ? "aliases" : "alias"));
 
 				aliasList = nconc(aliasList, r->name->attrs);
 			}
@@ -380,9 +388,7 @@ transformTableEntry(ParseState *pstate, RangeVar *r)
 			}
 		}
 		else
-		{
 			elog(NOTICE, "transformTableEntry: column aliases not handled (internal error)");
-		}
 #else
 		elog(ERROR, "Column aliases not yet supported");
 #endif
@@ -412,7 +418,7 @@ transformTableEntry(ParseState *pstate, RangeVar *r)
 							 baserel->inh, TRUE, TRUE);
 
 	return rte;
-} /* transformTableEntry() */
+}	/* transformTableEntry() */
 
 
 /*
@@ -432,7 +438,7 @@ transformTableEntry(ParseState *pstate, RangeVar *r)
 static void
 parseFromClause(ParseState *pstate, List *frmList)
 {
-	List *fl;
+	List	   *fl;
 
 	foreach(fl, frmList)
 	{
@@ -452,17 +458,17 @@ parseFromClause(ParseState *pstate, List *frmList)
 
 		/* Plain vanilla inner join, just like we've always had? */
 		if (IsA(n, RangeVar))
-		{
 			transformTableEntry(pstate, (RangeVar *) n);
-		}
 
 		/* A newfangled join expression? */
 		else if (IsA(n, JoinExpr))
 		{
 #ifndef DISABLE_JOIN_SYNTAX
-			RangeTblEntry	   *l_rte, *r_rte;
-			Attr			   *l_name, *r_name = NULL;
-			JoinExpr *j = (JoinExpr *) n;
+			RangeTblEntry *l_rte,
+					   *r_rte;
+			Attr	   *l_name,
+					   *r_name = NULL;
+			JoinExpr   *j = (JoinExpr *) n;
 
 			if (j->alias != NULL)
 				elog(ERROR, "JOIN table aliases are not supported");
@@ -471,7 +477,7 @@ parseFromClause(ParseState *pstate, List *frmList)
 			if (IsA(j->larg, JoinExpr))
 			{
 				parseFromClause(pstate, lcons(j->larg, NIL));
-				l_name = ((JoinExpr *)j->larg)->alias;
+				l_name = ((JoinExpr *) j->larg)->alias;
 			}
 			else
 			{
@@ -483,7 +489,7 @@ parseFromClause(ParseState *pstate, List *frmList)
 			if (IsA(j->rarg, JoinExpr))
 			{
 				parseFromClause(pstate, lcons(j->rarg, NIL));
-				l_name = ((JoinExpr *)j->larg)->alias;
+				l_name = ((JoinExpr *) j->larg)->alias;
 			}
 			else
 			{
@@ -492,25 +498,30 @@ parseFromClause(ParseState *pstate, List *frmList)
 				r_name = expandTable(pstate, r_rte->eref->relname, TRUE);
 			}
 
-			/* Natural join does not explicitly specify columns; must generate columns to join.
-			 * Need to run through the list of columns from each table or join result
-			 * and match up the column names. Use the first table, and check every
-			 * column in the second table for a match.
+			/*
+			 * Natural join does not explicitly specify columns; must
+			 * generate columns to join. Need to run through the list of
+			 * columns from each table or join result and match up the
+			 * column names. Use the first table, and check every column
+			 * in the second table for a match.
 			 */
 			if (j->isNatural)
 			{
-				List *lx, *rx;
-				List *rlist = NULL;
+				List	   *lx,
+						   *rx;
+				List	   *rlist = NULL;
 
 				foreach(lx, l_name->attrs)
 				{
-					Ident *id = NULL;
-					Value *l_col = lfirst(lx);
+					Ident	   *id = NULL;
+					Value	   *l_col = lfirst(lx);
+
 					Assert(IsA(l_col, String));
 
 					foreach(rx, r_name->attrs)
 					{
-						Value *r_col = lfirst(rx);
+						Value	   *r_col = lfirst(rx);
+
 						Assert(IsA(r_col, String));
 
 						if (strcmp(strVal(l_col), strVal(r_col)) == 0)
@@ -534,30 +545,32 @@ parseFromClause(ParseState *pstate, List *frmList)
 			{
 				/* CROSS JOIN */
 				if (j->quals == NULL)
-				{
 					printf("CROSS JOIN...\n");
-				}
 
-				/* JOIN/USING
-				 * This is an inner join, so rip apart the join node and
-				 * transform into a traditional FROM list. NATURAL JOIN
-				 * and JOIN USING both change the shape of the result.
-				 * Need to generate a list of result columns to use for
-				 * target list expansion and validation.
+				/*
+				 * JOIN/USING This is an inner join, so rip apart the join
+				 * node and transform into a traditional FROM list.
+				 * NATURAL JOIN and JOIN USING both change the shape of
+				 * the result. Need to generate a list of result columns
+				 * to use for target list expansion and validation.
 				 */
 				else if (IsA(j->quals, List))
 				{
+
 					/*
-					 * List of Ident nodes means column names from a real USING
-					 * clause. Determine the shape of the joined table.
+					 * List of Ident nodes means column names from a real
+					 * USING clause. Determine the shape of the joined
+					 * table.
 					 */
-					List *ucols, *ucol;
-					List *shape = NULL;
-					List *alias = NULL;
-					List *l_shape, *r_shape;
+					List	   *ucols,
+							   *ucol;
+					List	   *shape = NULL;
+					List	   *alias = NULL;
+					List	   *l_shape,
+							   *r_shape;
 
-					List *l_cols = makeAttrList(l_name);
-					List *r_cols = makeAttrList(r_name);
+					List	   *l_cols = makeAttrList(l_name);
+					List	   *r_cols = makeAttrList(r_name);
 
 					printf("USING input tables are:\n %s\n %s\n",
 						   nodeToString(l_name), nodeToString(r_name));
@@ -566,14 +579,15 @@ parseFromClause(ParseState *pstate, List *frmList)
 						   nodeToString(l_cols), nodeToString(r_cols));
 
 					/* Columns from the USING clause... */
-					ucols = (List *)j->quals;
+					ucols = (List *) j->quals;
 					foreach(ucol, ucols)
 					{
-						List *col;
-						Attr *l_attr = NULL, *r_attr = NULL;
-						Ident *id = lfirst(ucol);
+						List	   *col;
+						Attr	   *l_attr = NULL,
+								   *r_attr = NULL;
+						Ident	   *id = lfirst(ucol);
 
-						Attr *attr = makeAttr("", id->name);
+						Attr	   *attr = makeAttr("", id->name);
 
 						foreach(col, l_cols)
 						{
@@ -634,9 +648,7 @@ parseFromClause(ParseState *pstate, List *frmList)
 
 				/* otherwise, must be an expression from an ON clause... */
 				else
-				{
 					j->quals = (List *) lcons(j->quals, NIL);
-				}
 
 				pstate->p_join_quals = (Node *) j->quals;
 
@@ -654,24 +666,22 @@ parseFromClause(ParseState *pstate, List *frmList)
 
 #if 0
 					/* merge qualified join clauses... */
-				if (j->quals != NULL)
-				{
-					if (*qual != NULL)
+					if (j->quals != NULL)
 					{
-						A_Expr	   *a = makeNode(A_Expr);
+						if (*qual != NULL)
+						{
+							A_Expr	   *a = makeNode(A_Expr);
 
-						a->oper = AND;
-						a->opname = NULL;
-						a->lexpr = (Node *) *qual;
-						a->rexpr = (Node *) j->quals;
+							a->oper = AND;
+							a->opname = NULL;
+							a->lexpr = (Node *) *qual;
+							a->rexpr = (Node *) j->quals;
 
-						*qual = (Node *)a;
-					}
-					else
-					{
-						*qual = (Node *)j->quals;
+							*qual = (Node *) a;
+						}
+						else
+							*qual = (Node *) j->quals;
 					}
-				}
 #endif
 
 #if 0
@@ -688,8 +698,8 @@ parseFromClause(ParseState *pstate, List *frmList)
 				 * then we will need to replace the node with two nodes.
 				 * Will need access to the previous list item to change
 				 * the link pointer to reference these new nodes. Try
-				 * accumulating and returning a new list.
-				 * - thomas 1999-01-08 Not doing this yet though!
+				 * accumulating and returning a new list. - thomas
+				 * 1999-01-08 Not doing this yet though!
 				 */
 
 			}
@@ -708,7 +718,7 @@ parseFromClause(ParseState *pstate, List *frmList)
 			elog(ERROR, "parseFromClause: unexpected FROM clause node (internal error)"
 				 "\n\t%s", nodeToString(n));
 	}
-} /* parseFromClause() */
+}	/* parseFromClause() */
 
 
 /*
@@ -733,17 +743,17 @@ findTargetlistEntry(ParseState *pstate, Node *node, List *tlist, int clause)
 	 * Handle two special cases as mandated by the SQL92 spec:
 	 *
 	 * 1. Bare ColumnName (no qualifier or subscripts)
-	 *    For a bare identifier, we search for a matching column name
-	 *	  in the existing target list.  Multiple matches are an error
+	 *	  For a bare identifier, we search for a matching column name
+	 *	  in the existing target list.	Multiple matches are an error
 	 *	  unless they refer to identical values; for example,
-	 *	  we allow  SELECT a, a FROM table ORDER BY a
-	 *	  but not   SELECT a AS b, b FROM table ORDER BY b
+	 *	  we allow	SELECT a, a FROM table ORDER BY a
+	 *	  but not	SELECT a AS b, b FROM table ORDER BY b
 	 *	  If no match is found, we fall through and treat the identifier
 	 *	  as an expression.
 	 *	  For GROUP BY, it is incorrect to match the grouping item against
 	 *	  targetlist entries: according to SQL92, an identifier in GROUP BY
 	 *	  is a reference to a column name exposed by FROM, not to a target
-	 *	  list column.  However, many implementations (including pre-7.0
+	 *	  list column.	However, many implementations (including pre-7.0
 	 *	  PostgreSQL) accept this anyway.  So for GROUP BY, we look first
 	 *	  to see if the identifier matches any FROM column name, and only
 	 *	  try for a targetlist name if it doesn't.  This ensures that we
@@ -768,19 +778,21 @@ findTargetlistEntry(ParseState *pstate, Node *node, List *tlist, int clause)
 	 * an expression.
 	 *----------
 	 */
-	if (IsA(node, Ident) && ((Ident *) node)->indirection == NIL)
+	if (IsA(node, Ident) &&((Ident *) node)->indirection == NIL)
 	{
 		char	   *name = ((Ident *) node)->name;
 
 		if (clause == GROUP_CLAUSE)
 		{
+
 			/*
 			 * In GROUP BY, we must prefer a match against a FROM-clause
-			 * column to one against the targetlist.  Look to see if there is
-			 * a matching column.  If so, fall through to let transformExpr()
-			 * do the rest.  NOTE: if name could refer ambiguously to more
-			 * than one column name exposed by FROM, colnameRangeTableEntry
-			 * will elog(ERROR).  That's just what we want here.
+			 * column to one against the targetlist.  Look to see if there
+			 * is a matching column.  If so, fall through to let
+			 * transformExpr() do the rest.  NOTE: if name could refer
+			 * ambiguously to more than one column name exposed by FROM,
+			 * colnameRangeTableEntry will elog(ERROR).  That's just what
+			 * we want here.
 			 */
 			if (colnameRangeTableEntry(pstate, name) != NULL)
 				name = NULL;
@@ -798,7 +810,7 @@ findTargetlistEntry(ParseState *pstate, Node *node, List *tlist, int clause)
 				{
 					if (target_result != NULL)
 					{
-						if (! equal(target_result->expr, tle->expr))
+						if (!equal(target_result->expr, tle->expr))
 							elog(ERROR, "%s '%s' is ambiguous",
 								 clauseText[clause], name);
 					}
@@ -808,7 +820,7 @@ findTargetlistEntry(ParseState *pstate, Node *node, List *tlist, int clause)
 				}
 			}
 			if (target_result != NULL)
-				return target_result; /* return the first match */
+				return target_result;	/* return the first match */
 		}
 	}
 	if (IsA(node, A_Const))
@@ -817,7 +829,7 @@ findTargetlistEntry(ParseState *pstate, Node *node, List *tlist, int clause)
 		int			targetlist_pos = 0;
 		int			target_pos;
 
-		if (! IsA(val, Integer))
+		if (!IsA(val, Integer))
 			elog(ERROR, "Non-integer constant in %s", clauseText[clause]);
 		target_pos = intVal(val);
 		foreach(tl, tlist)
@@ -828,7 +840,7 @@ findTargetlistEntry(ParseState *pstate, Node *node, List *tlist, int clause)
 			if (!resnode->resjunk)
 			{
 				if (++targetlist_pos == target_pos)
-					return tle;	/* return the unique match */
+					return tle; /* return the unique match */
 			}
 		}
 		elog(ERROR, "%s position %d is not in target list",
@@ -836,12 +848,12 @@ findTargetlistEntry(ParseState *pstate, Node *node, List *tlist, int clause)
 	}
 
 	/*
-	 * Otherwise, we have an expression (this is a Postgres extension
-	 * not found in SQL92).  Convert the untransformed node to a
-	 * transformed expression, and search for a match in the tlist.
-	 * NOTE: it doesn't really matter whether there is more than one
-	 * match.  Also, we are willing to match a resjunk target here,
-	 * though the above cases must ignore resjunk targets.
+	 * Otherwise, we have an expression (this is a Postgres extension not
+	 * found in SQL92).  Convert the untransformed node to a transformed
+	 * expression, and search for a match in the tlist. NOTE: it doesn't
+	 * really matter whether there is more than one match.	Also, we are
+	 * willing to match a resjunk target here, though the above cases must
+	 * ignore resjunk targets.
 	 */
 	expr = transformExpr(pstate, node, EXPR_COLUMN_FIRST);
 
@@ -855,8 +867,8 @@ findTargetlistEntry(ParseState *pstate, Node *node, List *tlist, int clause)
 
 	/*
 	 * If no matches, construct a new target entry which is appended to
-	 * the end of the target list.  This target is given resjunk = TRUE
-	 * so that it will not be projected into the final tuple.
+	 * the end of the target list.	This target is given resjunk = TRUE so
+	 * that it will not be projected into the final tuple.
 	 */
 	target_result = transformTargetEntry(pstate, node, expr, NULL, true);
 	lappend(tlist, target_result);
@@ -884,7 +896,7 @@ transformGroupClause(ParseState *pstate, List *grouplist, List *targetlist)
 								  targetlist, GROUP_CLAUSE);
 
 		/* avoid making duplicate grouplist entries */
-		if (! exprIsInSortList(tle->expr, glist, targetlist))
+		if (!exprIsInSortList(tle->expr, glist, targetlist))
 		{
 			GroupClause *grpcl = makeNode(GroupClause);
 
@@ -915,8 +927,8 @@ transformSortClause(ParseState *pstate,
 
 	foreach(olitem, orderlist)
 	{
-		SortGroupBy	   *sortby = lfirst(olitem);
-		TargetEntry	   *tle;
+		SortGroupBy *sortby = lfirst(olitem);
+		TargetEntry *tle;
 
 		tle = findTargetlistEntry(pstate, sortby->node,
 								  targetlist, ORDER_CLAUSE);
@@ -933,7 +945,7 @@ transformSortClause(ParseState *pstate,
  *	  transform a DISTINCT or DISTINCT ON clause
  *
  * Since we may need to add items to the query's sortClause list, that list
- * is passed by reference.  We might also need to add items to the query's
+ * is passed by reference.	We might also need to add items to the query's
  * targetlist, but we assume that cannot be empty initially, so we can
  * lappend to it even though the pointer is passed by value.
  */
@@ -955,10 +967,10 @@ transformDistinctClause(ParseState *pstate, List *distinctlist,
 
 		/*
 		 * All non-resjunk elements from target list that are not already
-		 * in the sort list should be added to it.  (We don't really care
+		 * in the sort list should be added to it.	(We don't really care
 		 * what order the DISTINCT fields are checked in, so we can leave
-		 * the user's ORDER BY spec alone, and just add additional sort keys
-		 * to it to ensure that all targetlist items get sorted.)
+		 * the user's ORDER BY spec alone, and just add additional sort
+		 * keys to it to ensure that all targetlist items get sorted.)
 		 */
 		*sortClause = addAllTargetsToSortList(*sortClause, targetlist);
 
@@ -966,8 +978,8 @@ transformDistinctClause(ParseState *pstate, List *distinctlist,
 		 * Now, DISTINCT list consists of all non-resjunk sortlist items.
 		 * Actually, all the sortlist items had better be non-resjunk!
 		 * Otherwise, user wrote SELECT DISTINCT with an ORDER BY item
-		 * that does not appear anywhere in the SELECT targetlist, and
-		 * we can't implement that with only one sorting pass...
+		 * that does not appear anywhere in the SELECT targetlist, and we
+		 * can't implement that with only one sorting pass...
 		 */
 		foreach(slitem, *sortClause)
 		{
@@ -988,11 +1000,12 @@ transformDistinctClause(ParseState *pstate, List *distinctlist,
 		 * If the user writes both DISTINCT ON and ORDER BY, then the two
 		 * expression lists must match (until one or the other runs out).
 		 * Otherwise the ORDER BY requires a different sort order than the
-		 * DISTINCT does, and we can't implement that with only one sort pass
-		 * (and if we do two passes, the results will be rather unpredictable).
-		 * However, it's OK to have more DISTINCT ON expressions than ORDER BY
-		 * expressions; we can just add the extra DISTINCT values to the sort
-		 * list, much as we did above for ordinary DISTINCT fields.
+		 * DISTINCT does, and we can't implement that with only one sort
+		 * pass (and if we do two passes, the results will be rather
+		 * unpredictable). However, it's OK to have more DISTINCT ON
+		 * expressions than ORDER BY expressions; we can just add the
+		 * extra DISTINCT values to the sort list, much as we did above
+		 * for ordinary DISTINCT fields.
 		 *
 		 * Actually, it'd be OK for the common prefixes of the two lists to
 		 * match in any order, but implementing that check seems like more
@@ -1020,7 +1033,9 @@ transformDistinctClause(ParseState *pstate, List *distinctlist,
 			{
 				*sortClause = addTargetToSortList(tle, *sortClause,
 												  targetlist, NULL);
-				/* Probably, the tle should always have been added at the
+
+				/*
+				 * Probably, the tle should always have been added at the
 				 * end of the sort list ... but search to be safe.
 				 */
 				foreach(slitem, *sortClause)
@@ -1059,7 +1074,7 @@ addAllTargetsToSortList(List *sortlist, List *targetlist)
 	{
 		TargetEntry *tle = (TargetEntry *) lfirst(i);
 
-		if (! tle->resdom->resjunk)
+		if (!tle->resdom->resjunk)
 			sortlist = addTargetToSortList(tle, sortlist, targetlist, NULL);
 	}
 	return sortlist;
@@ -1078,7 +1093,7 @@ addTargetToSortList(TargetEntry *tle, List *sortlist, List *targetlist,
 					char *opname)
 {
 	/* avoid making duplicate sortlist entries */
-	if (! exprIsInSortList(tle->expr, sortlist, targetlist))
+	if (!exprIsInSortList(tle->expr, sortlist, targetlist))
 	{
 		SortClause *sortcl = makeNode(SortClause);
 
@@ -1109,14 +1124,14 @@ assignSortGroupRef(TargetEntry *tle, List *tlist)
 	Index		maxRef;
 	List	   *l;
 
-	if (tle->resdom->ressortgroupref)		/* already has one? */
+	if (tle->resdom->ressortgroupref)	/* already has one? */
 		return tle->resdom->ressortgroupref;
 
 	/* easiest way to pick an unused refnumber: max used + 1 */
 	maxRef = 0;
 	foreach(l, tlist)
 	{
-		Index	ref = ((TargetEntry *) lfirst(l))->resdom->ressortgroupref;
+		Index		ref = ((TargetEntry *) lfirst(l))->resdom->ressortgroupref;
 
 		if (ref > maxRef)
 			maxRef = ref;
@@ -1250,4 +1265,5 @@ transformUnionClause(List *unionClause, List *targetlist)
 	else
 		return NIL;
 }
+
 #endif
diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c
index 26b6934b3d555c99b75108071da3f92b6a84aa56..880a849f2d838a30bdb360e32506c4728a3a3888 100644
--- a/src/backend/parser/parse_coerce.c
+++ b/src/backend/parser/parse_coerce.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.41 2000/04/08 19:29:40 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.42 2000/04/12 17:15:26 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -47,21 +47,22 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId,
 	}
 	else if (inputTypeId == UNKNOWNOID && IsA(node, Const))
 	{
+
 		/*
 		 * Input is a string constant with previously undetermined type.
-		 * Apply the target type's typinput function to it to produce
-		 * a constant of the target type.
+		 * Apply the target type's typinput function to it to produce a
+		 * constant of the target type.
 		 *
 		 * NOTE: this case cannot be folded together with the other
 		 * constant-input case, since the typinput function does not
-		 * necessarily behave the same as a type conversion function.
-		 * For example, int4's typinput function will reject "1.2",
-		 * whereas float-to-int type conversion will round to integer.
+		 * necessarily behave the same as a type conversion function. For
+		 * example, int4's typinput function will reject "1.2", whereas
+		 * float-to-int type conversion will round to integer.
 		 *
-		 * XXX if the typinput function is not cachable, we really ought
-		 * to postpone evaluation of the function call until runtime.
-		 * But there is no way to represent a typinput function call as
-		 * an expression tree, because C-string values are not Datums.
+		 * XXX if the typinput function is not cachable, we really ought to
+		 * postpone evaluation of the function call until runtime. But
+		 * there is no way to represent a typinput function call as an
+		 * expression tree, because C-string values are not Datums.
 		 */
 		Const	   *con = (Const *) node;
 		Const	   *newcon = makeNode(Const);
@@ -73,10 +74,11 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId,
 		newcon->constisnull = con->constisnull;
 		newcon->constisset = false;
 
-		if (! con->constisnull)
+		if (!con->constisnull)
 		{
 			/* We know the source constant is really of type 'text' */
 			char	   *val = textout((text *) con->constvalue);
+
 			newcon->constvalue = stringTypeDatum(targetType, val, atttypmod);
 			pfree(val);
 		}
@@ -85,15 +87,17 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId,
 	}
 	else if (IS_BINARY_COMPATIBLE(inputTypeId, targetTypeId))
 	{
+
 		/*
-		 * We don't really need to do a conversion, but we do need to attach
-		 * a RelabelType node so that the expression will be seen to have
-		 * the intended type when inspected by higher-level code.
+		 * We don't really need to do a conversion, but we do need to
+		 * attach a RelabelType node so that the expression will be seen
+		 * to have the intended type when inspected by higher-level code.
 		 */
 		RelabelType *relabel = makeNode(RelabelType);
 
 		relabel->arg = node;
 		relabel->resulttype = targetTypeId;
+
 		/*
 		 * XXX could we label result with exprTypmod(node) instead of
 		 * default -1 typmod, to save a possible length-coercion later?
@@ -111,11 +115,12 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId,
 	}
 	else
 	{
+
 		/*
 		 * Otherwise, find the appropriate type conversion function
-		 * (caller should have determined that there is one), and
-		 * generate an expression tree representing run-time
-		 * application of the conversion function.
+		 * (caller should have determined that there is one), and generate
+		 * an expression tree representing run-time application of the
+		 * conversion function.
 		 */
 		FuncCall   *n = makeNode(FuncCall);
 		Type		targetType = typeidType(targetTypeId);
@@ -135,20 +140,20 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId,
 
 		/*
 		 * If the input is a constant, apply the type conversion function
-		 * now instead of delaying to runtime.  (We could, of course,
-		 * just leave this to be done during planning/optimization;
-		 * but it's a very frequent special case, and we save cycles
-		 * in the rewriter if we fold the expression now.)
+		 * now instead of delaying to runtime.	(We could, of course, just
+		 * leave this to be done during planning/optimization; but it's a
+		 * very frequent special case, and we save cycles in the rewriter
+		 * if we fold the expression now.)
 		 *
-		 * Note that no folding will occur if the conversion function is
-		 * not marked 'iscachable'.
+		 * Note that no folding will occur if the conversion function is not
+		 * marked 'iscachable'.
 		 *
-		 * HACK: if constant is NULL, don't fold it here.  This is needed
-		 * by make_subplan(), which calls this routine on placeholder Const
-		 * nodes that mustn't be collapsed.  (It'd be a lot cleaner to make
-		 * a separate node type for that purpose...)
+		 * HACK: if constant is NULL, don't fold it here.  This is needed by
+		 * make_subplan(), which calls this routine on placeholder Const
+		 * nodes that mustn't be collapsed.  (It'd be a lot cleaner to
+		 * make a separate node type for that purpose...)
 		 */
-		if (IsA(node, Const) && ! ((Const *) node)->constisnull)
+		if (IsA(node, Const) &&!((Const *) node)->constisnull)
 			result = eval_const_expressions(result);
 	}
 
@@ -181,8 +186,8 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids)
 	/* run through argument list... */
 	for (i = 0; i < nargs; i++)
 	{
-		Oid		inputTypeId = input_typeids[i];
-		Oid		targetTypeId = func_typeids[i];
+		Oid			inputTypeId = input_typeids[i];
+		Oid			targetTypeId = func_typeids[i];
 
 		/* no problem if same type */
 		if (inputTypeId == targetTypeId)
@@ -203,8 +208,8 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids)
 			return false;
 
 		/*
-		 * If input is an untyped string constant, assume we can
-		 * convert it to anything except a class type.
+		 * If input is an untyped string constant, assume we can convert
+		 * it to anything except a class type.
 		 */
 		if (inputTypeId == UNKNOWNOID)
 		{
@@ -220,15 +225,15 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids)
 			continue;
 
 		/*
-		 * Else, try for explicit conversion using functions:
-		 * look for a single-argument function named with the
-		 * target type name and accepting the source type.
+		 * Else, try for explicit conversion using functions: look for a
+		 * single-argument function named with the target type name and
+		 * accepting the source type.
 		 */
 		MemSet(oid_array, 0, FUNC_MAX_ARGS * sizeof(Oid));
 		oid_array[0] = inputTypeId;
 
 		ftup = SearchSysCacheTuple(PROCNAME,
-							PointerGetDatum(typeidTypeName(targetTypeId)),
+						   PointerGetDatum(typeidTypeName(targetTypeId)),
 								   Int32GetDatum(1),
 								   PointerGetDatum(oid_array),
 								   0);
@@ -331,14 +336,14 @@ TypeCategory(Oid inType)
 			result = STRING_TYPE;
 			break;
 
-		/*
-		 * Kluge added 4/8/00 by tgl: treat the new BIT types as strings,
-		 * so that 'unknown' || 'unknown' continues to resolve as textcat
-		 * rather than generating an ambiguous-operator error.  Probably
-		 * BIT types should have their own type category, or maybe they
-		 * should be numeric?  Need a better way of handling unknown types
-		 * first.
-		 */
+			/*
+			 * Kluge added 4/8/00 by tgl: treat the new BIT types as
+			 * strings, so that 'unknown' || 'unknown' continues to
+			 * resolve as textcat rather than generating an
+			 * ambiguous-operator error.  Probably BIT types should have
+			 * their own type category, or maybe they should be numeric?
+			 * Need a better way of handling unknown types first.
+			 */
 		case (ZPBITOID):
 		case (VARBITOID):
 			result = STRING_TYPE;
diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c
index 12c10988dfe9b8a35eba6d2c467eef7d7771db15..0bb81dd24756475b256c4464cbeb5675b8e567df 100644
--- a/src/backend/parser/parse_expr.c
+++ b/src/backend/parser/parse_expr.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.75 2000/03/19 07:13:58 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.76 2000/04/12 17:15:26 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -33,17 +33,17 @@
 #include "utils/syscache.h"
 
 
-int	max_expr_depth = DEFAULT_MAX_EXPR_DEPTH;
+int			max_expr_depth = DEFAULT_MAX_EXPR_DEPTH;
 
 static int	expr_depth_counter = 0;
 
 static Node *parser_typecast_constant(Value *expr, TypeName *typename);
 static Node *parser_typecast_expression(ParseState *pstate,
-										Node *expr, TypeName *typename);
+						   Node *expr, TypeName *typename);
 static Node *transformAttr(ParseState *pstate, Attr *att, int precedence);
 static Node *transformIdent(ParseState *pstate, Ident *ident, int precedence);
 static Node *transformIndirection(ParseState *pstate, Node *basenode,
-								  List *indirection);
+					 List *indirection);
 
 
 /*
@@ -92,8 +92,8 @@ transformExpr(ParseState *pstate, Node *expr, int precedence)
 		return NULL;
 
 	/*
-	 * Guard against an overly complex expression leading to coredump
-	 * due to stack overflow here, or in later recursive routines that
+	 * Guard against an overly complex expression leading to coredump due
+	 * to stack overflow here, or in later recursive routines that
 	 * traverse expression trees.  Note that this is very unlikely to
 	 * happen except with pathological queries; but we don't want someone
 	 * to be able to crash the backend quite that easily...
@@ -172,7 +172,7 @@ transformExpr(ParseState *pstate, Node *expr, int precedence)
 													   "nullvalue",
 													   lcons(lexpr, NIL),
 													   false, false,
-													   &pstate->p_last_resno,
+												   &pstate->p_last_resno,
 													   precedence);
 						}
 						break;
@@ -184,7 +184,7 @@ transformExpr(ParseState *pstate, Node *expr, int precedence)
 													   "nonnullvalue",
 													   lcons(lexpr, NIL),
 													   false, false,
-													   &pstate->p_last_resno,
+												   &pstate->p_last_resno,
 													   precedence);
 						}
 						break;
@@ -289,7 +289,9 @@ transformExpr(ParseState *pstate, Node *expr, int precedence)
 
 				if (sublink->subLinkType == EXISTS_SUBLINK)
 				{
-					/* EXISTS needs no lefthand or combining operator.
+
+					/*
+					 * EXISTS needs no lefthand or combining operator.
 					 * These fields should be NIL already, but make sure.
 					 */
 					sublink->lefthand = NIL;
@@ -299,7 +301,8 @@ transformExpr(ParseState *pstate, Node *expr, int precedence)
 				{
 					List	   *tlist = qtree->targetList;
 
-					/* Make sure the subselect delivers a single column
+					/*
+					 * Make sure the subselect delivers a single column
 					 * (ignoring resjunk targets).
 					 */
 					if (tlist == NIL ||
@@ -307,11 +310,13 @@ transformExpr(ParseState *pstate, Node *expr, int precedence)
 						elog(ERROR, "Subselect must have a field");
 					while ((tlist = lnext(tlist)) != NIL)
 					{
-						if (! ((TargetEntry *) lfirst(tlist))->resdom->resjunk)
+						if (!((TargetEntry *) lfirst(tlist))->resdom->resjunk)
 							elog(ERROR, "Subselect must have only one field");
 					}
-					/* EXPR needs no lefthand or combining operator.
-					 * These fields should be NIL already, but make sure.
+
+					/*
+					 * EXPR needs no lefthand or combining operator. These
+					 * fields should be NIL already, but make sure.
 					 */
 					sublink->lefthand = NIL;
 					sublink->oper = NIL;
@@ -336,10 +341,12 @@ transformExpr(ParseState *pstate, Node *expr, int precedence)
 
 					sublink->oper = NIL;
 
-					/* Scan subquery's targetlist to find values that will be
-					 * matched against lefthand values.  We need to ignore
-					 * resjunk targets, so doing the outer iteration over
-					 * right_list is easier than doing it over left_list.
+					/*
+					 * Scan subquery's targetlist to find values that will
+					 * be matched against lefthand values.	We need to
+					 * ignore resjunk targets, so doing the outer
+					 * iteration over right_list is easier than doing it
+					 * over left_list.
 					 */
 					while (right_list != NIL)
 					{
@@ -370,8 +377,8 @@ transformExpr(ParseState *pstate, Node *expr, int precedence)
 								 op, typeidTypeName(opform->oprresult),
 								 typeidTypeName(BOOLOID));
 
-						newop = makeOper(oprid(optup),/* opno */
-										 InvalidOid, /* opid */
+						newop = makeOper(oprid(optup),	/* opno */
+										 InvalidOid,	/* opid */
 										 opform->oprresult,
 										 0,
 										 NULL);
@@ -453,9 +460,10 @@ transformExpr(ParseState *pstate, Node *expr, int precedence)
 								 || ((TypeCategory(wtype) == USER_TYPE)
 							&& (TypeCategory(c->casetype) == USER_TYPE)))
 						{
+
 							/*
-							 * both types in different categories?
-							 * then not much hope...
+							 * both types in different categories? then
+							 * not much hope...
 							 */
 							elog(ERROR, "CASE/WHEN types '%s' and '%s' not matched",
 								 typeidTypeName(c->casetype), typeidTypeName(wtype));
@@ -463,9 +471,10 @@ transformExpr(ParseState *pstate, Node *expr, int precedence)
 						else if (IsPreferredType(pcategory, wtype)
 								 && can_coerce_type(1, &ptype, &wtype))
 						{
+
 							/*
-							 * new one is preferred and can convert?
-							 * then take it...
+							 * new one is preferred and can convert? then
+							 * take it...
 							 */
 							ptype = wtype;
 							pcategory = TypeCategory(ptype);
@@ -478,6 +487,7 @@ transformExpr(ParseState *pstate, Node *expr, int precedence)
 				{
 					if (!c->casetype || c->casetype == UNKNOWNOID)
 					{
+
 						/*
 						 * default clause is NULL, so assign preferred
 						 * type from WHEN clauses...
@@ -553,14 +563,14 @@ transformExpr(ParseState *pstate, Node *expr, int precedence)
 				break;
 			}
 
-		/*
-		 * Quietly accept node types that may be presented when we are called
-		 * on an already-transformed tree.
-		 *
-		 * Do any other node types need to be accepted?  For now we are taking
-		 * a conservative approach, and only accepting node types that are
- 		 * demonstrably necessary to accept.
-		 */
+			/*
+			 * Quietly accept node types that may be presented when we are
+			 * called on an already-transformed tree.
+			 *
+			 * Do any other node types need to be accepted?  For now we are
+			 * taking a conservative approach, and only accepting node
+			 * types that are demonstrably necessary to accept.
+			 */
 		case T_Expr:
 		case T_Var:
 		case T_Const:
@@ -610,7 +620,10 @@ transformIdent(ParseState *pstate, Ident *ident, int precedence)
 	Node	   *result = NULL;
 	RangeTblEntry *rte;
 
-	/* try to find the ident as a relation ... but not if subscripts appear */
+	/*
+	 * try to find the ident as a relation ... but not if subscripts
+	 * appear
+	 */
 	if (ident->indirection == NIL &&
 		refnameRangeTableEntry(pstate, ident->name) != NULL)
 	{
@@ -625,6 +638,7 @@ transformIdent(ParseState *pstate, Ident *ident, int precedence)
 		{
 			/* Convert it to a fully qualified Attr, and transform that */
 			Attr	   *att = makeAttr(rte->eref->relname, ident->name);
+
 			att->indirection = ident->indirection;
 			return transformAttr(pstate, att, precedence);
 		}
@@ -687,7 +701,7 @@ exprType(Node *expr)
 					Query	   *qtree = (Query *) sublink->subselect;
 					TargetEntry *tent;
 
-					if (! qtree || ! IsA(qtree, Query))
+					if (!qtree || !IsA(qtree, Query))
 						elog(ERROR, "Cannot get type for untransformed sublink");
 					tent = (TargetEntry *) lfirst(qtree->targetList);
 					type = tent->resdom->restype;
@@ -735,11 +749,12 @@ exprTypmod(Node *expr)
 		case T_Const:
 			{
 				/* Be smart about string constants... */
-				Const  *con = (Const *) expr;
+				Const	   *con = (Const *) expr;
+
 				switch (con->consttype)
 				{
 					case BPCHAROID:
-						if (! con->constisnull)
+						if (!con->constisnull)
 							return VARSIZE(DatumGetPointer(con->constvalue));
 						break;
 					default:
@@ -749,7 +764,7 @@ exprTypmod(Node *expr)
 			break;
 		case T_Expr:
 			{
-				int32	coercedTypmod;
+				int32		coercedTypmod;
 
 				/* Be smart about length-coercion functions... */
 				if (exprIsLengthCoercion(expr, &coercedTypmod))
@@ -794,7 +809,7 @@ exprIsLengthCoercion(Node *expr, int32 *coercedTypmod)
 
 	/* Is it a function-call at all? */
 	if (expr == NULL ||
-		! IsA(expr, Expr) ||
+		!IsA(expr, Expr) ||
 		((Expr *) expr)->opType != FUNC_EXPR)
 		return false;
 	func = (Func *) (((Expr *) expr)->oper);
@@ -802,12 +817,13 @@ exprIsLengthCoercion(Node *expr, int32 *coercedTypmod)
 
 	/*
 	 * If it's not a two-argument function with the second argument being
-	 * an int4 constant, it can't have been created from a length coercion.
+	 * an int4 constant, it can't have been created from a length
+	 * coercion.
 	 */
 	if (length(((Expr *) expr)->args) != 2)
 		return false;
 	second_arg = (Const *) lsecond(((Expr *) expr)->args);
-	if (! IsA(second_arg, Const) ||
+	if (!IsA(second_arg, Const) ||
 		second_arg->consttype != INT4OID ||
 		second_arg->constisnull)
 		return false;
@@ -823,9 +839,9 @@ exprIsLengthCoercion(Node *expr, int32 *coercedTypmod)
 	procStruct = (Form_pg_proc) GETSTRUCT(tup);
 
 	/*
-	 * It must be a function with two arguments where the first is of
-	 * the same type as the return value and the second is an int4.
-	 * Also, just to be sure, check return type agrees with expr node.
+	 * It must be a function with two arguments where the first is of the
+	 * same type as the return value and the second is an int4. Also, just
+	 * to be sure, check return type agrees with expr node.
 	 */
 	if (procStruct->pronargs != 2 ||
 		procStruct->prorettype != procStruct->proargtypes[0] ||
@@ -834,8 +850,8 @@ exprIsLengthCoercion(Node *expr, int32 *coercedTypmod)
 		return false;
 
 	/*
-	 * Furthermore, the name of the function must be the same
-	 * as the argument/result type's name.
+	 * Furthermore, the name of the function must be the same as the
+	 * argument/result type's name.
 	 */
 	tup = SearchSysCacheTuple(TYPEOID,
 							  ObjectIdGetDatum(procStruct->prorettype),
@@ -891,7 +907,7 @@ parser_typecast_constant(Value *expr, TypeName *typename)
 
 	if (typename->arrayBounds != NIL)
 	{
-		char		type_string[NAMEDATALEN+2];
+		char		type_string[NAMEDATALEN + 2];
 
 		sprintf(type_string, "_%s", typename->name);
 		tp = (Type) typenameType(type_string);
@@ -936,7 +952,7 @@ parser_typecast_expression(ParseState *pstate,
 
 	if (typename->arrayBounds != NIL)
 	{
-		char		type_string[NAMEDATALEN+2];
+		char		type_string[NAMEDATALEN + 2];
 
 		sprintf(type_string, "_%s", typename->name);
 		tp = (Type) typenameType(type_string);
@@ -957,9 +973,10 @@ parser_typecast_expression(ParseState *pstate,
 				 typeidTypeName(inputType),
 				 typeidTypeName(targetType));
 	}
+
 	/*
-	 * If the target is a fixed-length type, it may need a length
-	 * coercion as well as a type coercion.
+	 * If the target is a fixed-length type, it may need a length coercion
+	 * as well as a type coercion.
 	 */
 	expr = coerce_type_typmod(pstate, expr,
 							  targetType, typename->typmod);
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c
index 67d5aea77ad35a39005265c057ddb66e18cdb128..3b543c3d6137dcf8d6badcd1040f673b79539888 100644
--- a/src/backend/parser/parse_func.c
+++ b/src/backend/parser/parse_func.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.77 2000/03/23 07:38:30 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.78 2000/04/12 17:15:26 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -45,13 +45,14 @@ static Oid **argtype_inherit(int nargs, Oid *oid_array);
 
 static int	find_inheritors(Oid relid, Oid **supervec);
 static CandidateList func_get_candidates(char *funcname, int nargs);
-static bool func_get_detail(char *funcname,
-							int nargs,
-							Oid *oid_array,
-							Oid *funcid,	/* return value */
-							Oid *rettype,	/* return value */
-							bool *retset,	/* return value */
-							Oid **true_typeids);
+static bool
+func_get_detail(char *funcname,
+				int nargs,
+				Oid *oid_array,
+				Oid *funcid,	/* return value */
+				Oid *rettype,	/* return value */
+				bool *retset,	/* return value */
+				Oid **true_typeids);
 static Oid **gen_cross_product(InhPaths *arginh, int nargs);
 static void make_arguments(ParseState *pstate,
 			   int nargs,
@@ -127,7 +128,7 @@ agg_get_candidates(char *aggname,
 	HeapTuple	tup;
 	Form_pg_aggregate agg;
 	int			ncandidates = 0;
-	ScanKeyData	aggKey[1];
+	ScanKeyData aggKey[1];
 
 	*candidates = NULL;
 
@@ -179,8 +180,8 @@ agg_select_candidate(Oid typeid, CandidateList candidates)
 				current_category;
 
 	/*
-	 * First look for exact matches or binary compatible matches.
-	 * (Of course exact matches shouldn't even get here, but anyway.)
+	 * First look for exact matches or binary compatible matches. (Of
+	 * course exact matches shouldn't even get here, but anyway.)
 	 */
 	ncandidates = 0;
 	last_candidate = NULL;
@@ -191,18 +192,18 @@ agg_select_candidate(Oid typeid, CandidateList candidates)
 		current_typeid = current_candidate->args[0];
 
 		if (current_typeid == typeid
-            || IS_BINARY_COMPATIBLE(current_typeid, typeid))
+			|| IS_BINARY_COMPATIBLE(current_typeid, typeid))
 		{
 			last_candidate = current_candidate;
 			ncandidates++;
-        }
-    }
+		}
+	}
 	if (ncandidates == 1)
 		return last_candidate->args[0];
 
 	/*
-	 * If no luck that way, look for candidates which allow coercion
-	 * and have a preferred type. Keep all candidates if none match.
+	 * If no luck that way, look for candidates which allow coercion and
+	 * have a preferred type. Keep all candidates if none match.
 	 */
 	category = TypeCategory(typeid);
 	ncandidates = 0;
@@ -290,11 +291,11 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
 	if (nargs == 1 && !must_be_agg)
 	{
 		/* Is it a plain Relation name from the parser? */
-		if (IsA(first_arg, Ident) && ((Ident *) first_arg)->isRel)
+		if (IsA(first_arg, Ident) &&((Ident *) first_arg)->isRel)
 		{
 			Ident	   *ident = (Ident *) first_arg;
 			RangeTblEntry *rte;
-			AttrNumber attnum;
+			AttrNumber	attnum;
 
 			/*
 			 * first arg is a relation. This could be a projection.
@@ -308,9 +309,9 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
 										 makeAttr(refname, NULL),
 										 FALSE, FALSE, TRUE);
 #ifdef WARN_FROM
-				elog(NOTICE,"Adding missing FROM-clause entry%s for table %s",
-					pstate->parentParseState != NULL ? " in subquery" : "",
-					refname);
+				elog(NOTICE, "Adding missing FROM-clause entry%s for table %s",
+				  pstate->parentParseState != NULL ? " in subquery" : "",
+					 refname);
 #endif
 			}
 
@@ -320,35 +321,39 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
 
 			/*
 			 * If the attr isn't a set, just make a var for it.  If it is
-			 * a set, treat it like a function and drop through.
-			 * Look through the explicit column list first, since we
-			 * now allow column aliases.
-			 * - thomas 2000-02-07
+			 * a set, treat it like a function and drop through. Look
+			 * through the explicit column list first, since we now allow
+			 * column aliases. - thomas 2000-02-07
 			 */
 			if (rte->eref->attrs != NULL)
 			{
-				List   *c;
-				/* start counting attributes/columns from one.
-				 * zero is reserved for InvalidAttrNumber.
-				 * - thomas 2000-01-27
+				List	   *c;
+
+				/*
+				 * start counting attributes/columns from one. zero is
+				 * reserved for InvalidAttrNumber. - thomas 2000-01-27
 				 */
-				int		i = 1;
-				foreach (c, rte->eref->attrs)
+				int			i = 1;
+
+				foreach(c, rte->eref->attrs)
 				{
-					char *colname = strVal(lfirst(c));
+					char	   *colname = strVal(lfirst(c));
+
 					/* found a match? */
 					if (strcmp(colname, funcname) == 0)
 					{
-						char *basename = get_attname(relid, i);
+						char	   *basename = get_attname(relid, i);
 
 						if (basename != NULL)
 						{
 							funcname = basename;
 							attnum = i;
 						}
-						/* attnum was initialized to InvalidAttrNumber
-						 * earlier, so no need to reset it if the
-						 * above test fails. - thomas 2000-02-07
+
+						/*
+						 * attnum was initialized to InvalidAttrNumber
+						 * earlier, so no need to reset it if the above
+						 * test fails. - thomas 2000-02-07
 						 */
 						break;
 					}
@@ -358,9 +363,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
 					attnum = specialAttNum(funcname);
 			}
 			else
-			{
 				attnum = get_attnum(relid, funcname);
-			}
 
 			if (attnum != InvalidAttrNumber)
 			{
@@ -373,6 +376,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
 		}
 		else if (ISCOMPLEX(exprType(first_arg)))
 		{
+
 			/*
 			 * Attempt to handle projection of a complex argument. If
 			 * ParseComplexProjection can't handle the projection, we have
@@ -411,6 +415,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
 
 	if (nargs == 1 || must_be_agg)
 	{
+
 		/*
 		 * See if it's an aggregate.
 		 */
@@ -423,8 +428,8 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
 			elog(ERROR, "Aggregate functions may only have one parameter");
 
 		/*
-		 * the aggregate COUNT is a special case, ignore its base
-		 * type.  Treat it as zero.   XXX mighty ugly --- FIXME
+		 * the aggregate COUNT is a special case, ignore its base type.
+		 * Treat it as zero.   XXX mighty ugly --- FIXME
 		 */
 		if (strcmp(funcname, "count") == 0)
 			basetype = 0;
@@ -469,6 +474,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
 
 		if (must_be_agg)
 		{
+
 			/*
 			 * No matching agg, but we had '*' or DISTINCT, so a plain
 			 * function could not have been meant.
@@ -491,7 +497,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
 	{
 		Node	   *arg = lfirst(i);
 
-		if (IsA(arg, Ident) && ((Ident *) arg)->isRel)
+		if (IsA(arg, Ident) &&((Ident *) arg)->isRel)
 		{
 			RangeTblEntry *rte;
 			int			vnum;
@@ -509,9 +515,9 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
 										 makeAttr(refname, NULL),
 										 FALSE, FALSE, TRUE);
 #ifdef WARN_FROM
-				elog(NOTICE,"Adding missing FROM-clause entry%s for table %s",
-					pstate->parentParseState != NULL ? " in subquery" : "",
-					refname);
+				elog(NOTICE, "Adding missing FROM-clause entry%s for table %s",
+				  pstate->parentParseState != NULL ? " in subquery" : "",
+					 refname);
 #endif
 			}
 
@@ -532,17 +538,16 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
 			lfirst(i) = makeVar(vnum, 0, toid, -1, sublevels_up);
 		}
 		else if (!attisset)
-		{
 			toid = exprType(arg);
-		}
 		else
 		{
 			/* if attisset is true, we already set toid for the single arg */
 		}
 
-		/* Most of the rest of the parser just assumes that functions do not
-		 * have more than FUNC_MAX_ARGS parameters.  We have to test here
-		 * to protect against array overruns, etc.
+		/*
+		 * Most of the rest of the parser just assumes that functions do
+		 * not have more than FUNC_MAX_ARGS parameters.  We have to test
+		 * here to protect against array overruns, etc.
 		 */
 		if (nargs >= FUNC_MAX_ARGS)
 			elog(ERROR, "Cannot pass more than %d arguments to a function",
@@ -585,23 +590,26 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
 								 &rettype, &retset, &true_oid_array);
 		if (!exists)
 		{
+
 			/*
-			 * If we can't find a function (or can't find a unique function),
-			 * see if this is really a type-coercion request: single-argument
-			 * function call where the function name is a type name.  If so,
-			 * and if we can do the coercion trivially, just go ahead and do
-			 * it without requiring there to be a real function for it.
+			 * If we can't find a function (or can't find a unique
+			 * function), see if this is really a type-coercion request:
+			 * single-argument function call where the function name is a
+			 * type name.  If so, and if we can do the coercion trivially,
+			 * just go ahead and do it without requiring there to be a
+			 * real function for it.
 			 *
 			 * "Trivial" coercions are ones that involve binary-compatible
 			 * types and ones that are coercing a previously-unknown-type
 			 * literal constant to a specific type.
 			 *
 			 * DO NOT try to generalize this code to nontrivial coercions,
-			 * because you'll just set up an infinite recursion between this
-			 * routine and coerce_type!  We have already failed to find a
-			 * suitable "real" coercion function, so we have to fail unless
-			 * this is a coercion that coerce_type can handle by itself.
-			 * Make sure this code stays in sync with what coerce_type does!
+			 * because you'll just set up an infinite recursion between
+			 * this routine and coerce_type!  We have already failed to
+			 * find a suitable "real" coercion function, so we have to
+			 * fail unless this is a coercion that coerce_type can handle
+			 * by itself. Make sure this code stays in sync with what
+			 * coerce_type does!
 			 */
 			if (nargs == 1)
 			{
@@ -612,15 +620,17 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
 										 0, 0, 0);
 				if (HeapTupleIsValid(tp))
 				{
-					Oid		sourceType = oid_array[0];
-					Oid		targetType = typeTypeId(tp);
-					Node   *arg1 = lfirst(fargs);
+					Oid			sourceType = oid_array[0];
+					Oid			targetType = typeTypeId(tp);
+					Node	   *arg1 = lfirst(fargs);
 
 					if ((sourceType == UNKNOWNOID && IsA(arg1, Const)) ||
 						sourceType == targetType ||
 						IS_BINARY_COMPATIBLE(sourceType, targetType))
 					{
-						/* Ah-hah, we can do it as a trivial coercion.
+
+						/*
+						 * Ah-hah, we can do it as a trivial coercion.
 						 * coerce_type can handle these cases, so why
 						 * duplicate code...
 						 */
@@ -640,7 +650,8 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
 			 */
 			if (nargs == 1)
 			{
-				Type	tp = typeidType(oid_array[0]);
+				Type		tp = typeidType(oid_array[0]);
+
 				if (typeTypeFlag(tp) == 'c')
 					elog(ERROR, "No such attribute or function '%s'",
 						 funcname);
@@ -911,8 +922,8 @@ func_select_candidate(int nargs,
 				current_type;
 
 	/*
-	 * Run through all candidates and keep those with the most matches
-	 * on exact types. Keep all candidates if none match.
+	 * Run through all candidates and keep those with the most matches on
+	 * exact types. Keep all candidates if none match.
 	 */
 	ncandidates = 0;
 	nbestMatch = 0;
@@ -955,10 +966,9 @@ func_select_candidate(int nargs,
 		return candidates->args;
 
 	/*
-	 * Still too many candidates?
-	 * Run through all candidates and keep those with the most matches
-	 * on exact types + binary-compatible types.
-	 * Keep all candidates if none match.
+	 * Still too many candidates? Run through all candidates and keep
+	 * those with the most matches on exact types + binary-compatible
+	 * types. Keep all candidates if none match.
 	 */
 	ncandidates = 0;
 	nbestMatch = 0;
@@ -1005,10 +1015,9 @@ func_select_candidate(int nargs,
 		return candidates->args;
 
 	/*
-	 * Still too many candidates?
-	 * Now look for candidates which are preferred types at the args that
-	 * will require coercion.
-	 * Keep all candidates if none match.
+	 * Still too many candidates? Now look for candidates which are
+	 * preferred types at the args that will require coercion. Keep all
+	 * candidates if none match.
 	 */
 	ncandidates = 0;
 	nbestMatch = 0;
@@ -1052,19 +1061,19 @@ func_select_candidate(int nargs,
 		return candidates->args;
 
 	/*
-	 * Still too many candidates?
-	 * Try assigning types for the unknown columns.
+	 * Still too many candidates? Try assigning types for the unknown
+	 * columns.
 	 *
-	 * We do this by examining each unknown argument position to see if all the
-	 * candidates agree on the type category of that slot.  If so, and if some
-	 * candidates accept the preferred type in that category, eliminate the
-	 * candidates with other input types.  If we are down to one candidate
-	 * at the end, we win.
+	 * We do this by examining each unknown argument position to see if all
+	 * the candidates agree on the type category of that slot.	If so, and
+	 * if some candidates accept the preferred type in that category,
+	 * eliminate the candidates with other input types.  If we are down to
+	 * one candidate at the end, we win.
 	 *
 	 * XXX It's kinda bogus to do this left-to-right, isn't it?  If we
-	 * eliminate some candidates because they are non-preferred at the first
-	 * slot, we won't notice that they didn't have the same type category for
-	 * a later slot.
+	 * eliminate some candidates because they are non-preferred at the
+	 * first slot, we won't notice that they didn't have the same type
+	 * category for a later slot.
 	 */
 	for (i = 0; i < nargs; i++)
 	{
@@ -1117,7 +1126,7 @@ func_select_candidate(int nargs,
 					last_candidate = current_candidate;
 				}
 			}
-			if (last_candidate)			/* terminate rebuilt list */
+			if (last_candidate) /* terminate rebuilt list */
 				last_candidate->next = NULL;
 		}
 	}
@@ -1174,7 +1183,11 @@ func_get_detail(char *funcname,
 	}
 	else
 	{
-		/* didn't find an exact match, so now try to match up candidates... */
+
+		/*
+		 * didn't find an exact match, so now try to match up
+		 * candidates...
+		 */
 		CandidateList function_typeids;
 
 		function_typeids = func_get_candidates(funcname, nargs);
@@ -1234,7 +1247,9 @@ func_get_detail(char *funcname,
 												   0);
 						Assert(HeapTupleIsValid(ftup));
 					}
-					/* otherwise, ambiguous function call, so fail by
+
+					/*
+					 * otherwise, ambiguous function call, so fail by
 					 * exiting loop with ftup still NULL.
 					 */
 					break;
@@ -1242,7 +1257,8 @@ func_get_detail(char *funcname,
 
 				/*
 				 * No match here, so try the next inherited type vector.
-				 * First time through, we need to compute the list of vectors.
+				 * First time through, we need to compute the list of
+				 * vectors.
 				 */
 				if (input_typeid_vector == NULL)
 					input_typeid_vector = argtype_inherit(nargs, oid_array);
@@ -1341,10 +1357,10 @@ find_inheritors(Oid relid, Oid **supervec)
 
 	/*
 	 * Use queue to do a breadth-first traversal of the inheritance graph
-	 * from the relid supplied up to the root.  At the top of the loop,
-	 * relid is the OID of the reltype to check next, queue is the list
-	 * of pending rels to check after this one, and visited is the list
-	 * of relids we need to output.
+	 * from the relid supplied up to the root.	At the top of the loop,
+	 * relid is the OID of the reltype to check next, queue is the list of
+	 * pending rels to check after this one, and visited is the list of
+	 * relids we need to output.
 	 */
 	do
 	{
@@ -1372,7 +1388,7 @@ find_inheritors(Oid relid, Oid **supervec)
 		{
 			relid = lfirsti(queue);
 			queue = lnext(queue);
-			if (! intMember(relid, visited))
+			if (!intMember(relid, visited))
 			{
 				newrelid = true;
 				break;
@@ -1401,7 +1417,7 @@ find_inheritors(Oid relid, Oid **supervec)
 
 			relid = lfirsti(elt);
 			rd = heap_open(relid, NoLock);
-			if (! RelationIsValid(rd))
+			if (!RelationIsValid(rd))
 				elog(ERROR, "Relid %u does not exist", relid);
 			trelid = typeTypeId(typenameType(RelationGetRelationName(rd)));
 			heap_close(rd, NoLock);
@@ -1412,7 +1428,9 @@ find_inheritors(Oid relid, Oid **supervec)
 		*supervec = (Oid *) NULL;
 
 	freeList(visited);
-	/* there doesn't seem to be any equally easy way to release the queue
+
+	/*
+	 * there doesn't seem to be any equally easy way to release the queue
 	 * list cells, but since they're palloc'd space it's not critical.
 	 */
 
diff --git a/src/backend/parser/parse_node.c b/src/backend/parser/parse_node.c
index 2d365db91d5a5c0d39dca1157e6e09fcddf8c216..0f386b84c71c180359afffe58b3a405b02bbff5d 100644
--- a/src/backend/parser/parse_node.c
+++ b/src/backend/parser/parse_node.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.38 2000/02/24 01:59:17 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.39 2000/04/12 17:15:27 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -225,7 +225,7 @@ make_var(ParseState *pstate, Oid relid, char *refname,
  *
  * In an array assignment, we are given a destination array value plus a
  * source value that is to be assigned to a single element or a slice of
- * that array.  We produce an expression that represents the new array value
+ * that array.	We produce an expression that represents the new array value
  * with the source data inserted into the right part of the array.
  *
  * pstate		Parse state
@@ -234,7 +234,7 @@ make_var(ParseState *pstate, Oid relid, char *refname,
  * forceSlice	If true, treat subscript as array slice in all cases
  * assignFrom	NULL for array fetch, else transformed expression for source.
  */
-ArrayRef *
+ArrayRef   *
 transformArraySubscripts(ParseState *pstate,
 						 Node *arrayBase,
 						 List *indirection,
@@ -281,19 +281,19 @@ transformArraySubscripts(ParseState *pstate,
 	/*
 	 * A list containing only single subscripts refers to a single array
 	 * element.  If any of the items are double subscripts (lower:upper),
-	 * then the subscript expression means an array slice operation.
-	 * In this case, we supply a default lower bound of 1 for any items
-	 * that contain only a single subscript.
-	 * The forceSlice parameter forces us to treat the operation as a
-	 * slice, even if no lower bounds are mentioned.  Otherwise,
-	 * we have to prescan the indirection list to see if there are any
-	 * double subscripts.
+	 * then the subscript expression means an array slice operation. In
+	 * this case, we supply a default lower bound of 1 for any items that
+	 * contain only a single subscript. The forceSlice parameter forces us
+	 * to treat the operation as a slice, even if no lower bounds are
+	 * mentioned.  Otherwise, we have to prescan the indirection list to
+	 * see if there are any double subscripts.
 	 */
-	if (! isSlice)
+	if (!isSlice)
 	{
-		foreach (idx, indirection)
+		foreach(idx, indirection)
 		{
 			A_Indices  *ai = (A_Indices *) lfirst(idx);
+
 			if (ai->lidx != NULL)
 			{
 				isSlice = true;
@@ -302,9 +302,10 @@ transformArraySubscripts(ParseState *pstate,
 		}
 	}
 
-	/* The type represented by the subscript expression is the element type
-	 * if we are fetching a single element, but it is the same as the array
-	 * type if we are fetching a slice or storing.
+	/*
+	 * The type represented by the subscript expression is the element
+	 * type if we are fetching a single element, but it is the same as the
+	 * array type if we are fetching a slice or storing.
 	 */
 	if (isSlice || assignFrom != NULL)
 		typeresult = typearray;
@@ -314,7 +315,7 @@ transformArraySubscripts(ParseState *pstate,
 	/*
 	 * Transform the subscript expressions.
 	 */
-	foreach (idx, indirection)
+	foreach(idx, indirection)
 	{
 		A_Indices  *ai = (A_Indices *) lfirst(idx);
 		Node	   *subexpr;
@@ -337,7 +338,7 @@ transformArraySubscripts(ParseState *pstate,
 											 sizeof(int32),
 											 Int32GetDatum(1),
 											 false,
-											 true, /* pass by value */
+											 true,		/* pass by value */
 											 false,
 											 false);
 			}
@@ -371,7 +372,7 @@ transformArraySubscripts(ParseState *pstate,
 				if (assignFrom == NULL)
 					elog(ERROR, "Array assignment requires type '%s'"
 						 " but expression is of type '%s'"
-						 "\n\tYou will need to rewrite or cast the expression",
+					"\n\tYou will need to rewrite or cast the expression",
 						 typeidTypeName(typeneeded),
 						 typeidTypeName(typesource));
 			}
@@ -384,7 +385,8 @@ transformArraySubscripts(ParseState *pstate,
 	aref = makeNode(ArrayRef);
 	aref->refattrlength = type_struct_array->typlen;
 	aref->refelemlength = type_struct_element->typlen;
-	aref->refelemtype = typeresult; /* XXX should save element type too */
+	aref->refelemtype = typeresult;		/* XXX should save element type
+										 * too */
 	aref->refelembyval = type_struct_element->typbyval;
 	aref->refupperindexpr = upperIndexpr;
 	aref->reflowerindexpr = lowerIndexpr;
@@ -407,7 +409,7 @@ transformArraySubscripts(ParseState *pstate,
  *	resolution that we're not sure that it should be considered text.
  *	Explicit "NULL" constants are also typed as UNKNOWN.
  *
- *  For integers and floats we produce int4, float8, or numeric depending
+ *	For integers and floats we produce int4, float8, or numeric depending
  *	on the value of the number.  XXX In some cases it would be nice to take
  *	context into account when determining the type to convert to, but in
  *	other cases we can't delay the type choice.  One possibility is to invent
@@ -462,7 +464,7 @@ make_const(Value *value)
 		case T_String:
 			val = PointerGetDatum(textin(strVal(value)));
 
-			typeid = UNKNOWNOID; /* will be coerced later */
+			typeid = UNKNOWNOID;/* will be coerced later */
 			typelen = -1;		/* variable len */
 			typebyval = false;
 			break;
@@ -496,7 +498,7 @@ make_const(Value *value)
 
 /*
  * Decide whether a T_Float value fits in float8, or must be treated as
- * type "numeric".  We check the number of digits and check for overflow/
+ * type "numeric".	We check the number of digits and check for overflow/
  * underflow.  (With standard compilation options, Postgres' NUMERIC type
  * can handle decimal exponents up to 1000, considerably more than most
  * implementations of float8, so this is a sensible test.)
@@ -504,9 +506,9 @@ make_const(Value *value)
 static bool
 fitsInFloat(Value *value)
 {
-	const char	   *ptr;
-	int				ndigits;
-	char		   *endptr;
+	const char *ptr;
+	int			ndigits;
+	char	   *endptr;
 
 	/*
 	 * Count digits, ignoring leading zeroes (but not trailing zeroes).
@@ -525,6 +527,7 @@ fitsInFloat(Value *value)
 	}
 	if (ndigits > DBL_DIG)
 		return false;
+
 	/*
 	 * Use strtod() to check for overflow/underflow.
 	 */
diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c
index fd41f4f3a0fa05c2bb2e475965434732d2e1f9da..2a9de556b266c5754b1b6a54be943f31cf71414b 100644
--- a/src/backend/parser/parse_oper.c
+++ b/src/backend/parser/parse_oper.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.39 2000/03/19 00:19:39 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.40 2000/04/12 17:15:27 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -29,10 +29,10 @@ static Oid *oper_select_candidate(int nargs, Oid *input_typeids,
 static Operator oper_exact(char *op, Oid arg1, Oid arg2);
 static Operator oper_inexact(char *op, Oid arg1, Oid arg2);
 static int binary_oper_get_candidates(char *opname,
-									  CandidateList *candidates);
+						   CandidateList *candidates);
 static int unary_oper_get_candidates(char *opname,
-									 CandidateList *candidates,
-									 char rightleft);
+						  CandidateList *candidates,
+						  char rightleft);
 static void op_error(char *op, Oid arg1, Oid arg2);
 static void unary_op_error(char *op, Oid arg, bool is_left_op);
 
@@ -229,8 +229,8 @@ oper_select_candidate(int nargs,
 		return candidates->args;
 
 	/*
-	 * Run through all candidates and keep those with the most matches
-	 * on exact types. Keep all candidates if none match.
+	 * Run through all candidates and keep those with the most matches on
+	 * exact types. Keep all candidates if none match.
 	 */
 	ncandidates = 0;
 	nbestMatch = 0;
@@ -273,10 +273,9 @@ oper_select_candidate(int nargs,
 		return candidates->args;
 
 	/*
-	 * Still too many candidates?
-	 * Run through all candidates and keep those with the most matches
-	 * on exact types + binary-compatible types.
-	 * Keep all candidates if none match.
+	 * Still too many candidates? Run through all candidates and keep
+	 * those with the most matches on exact types + binary-compatible
+	 * types. Keep all candidates if none match.
 	 */
 	ncandidates = 0;
 	nbestMatch = 0;
@@ -323,10 +322,9 @@ oper_select_candidate(int nargs,
 		return candidates->args;
 
 	/*
-	 * Still too many candidates?
-	 * Now look for candidates which are preferred types at the args that
-	 * will require coercion.
-	 * Keep all candidates if none match.
+	 * Still too many candidates? Now look for candidates which are
+	 * preferred types at the args that will require coercion. Keep all
+	 * candidates if none match.
 	 */
 	ncandidates = 0;
 	nbestMatch = 0;
@@ -370,15 +368,16 @@ oper_select_candidate(int nargs,
 		return candidates->args;
 
 	/*
-	 * Still too many candidates?
-	 * Try assigning types for the unknown columns.
+	 * Still too many candidates? Try assigning types for the unknown
+	 * columns.
 	 *
 	 * First try: if we have an unknown and a non-unknown input, see whether
-	 * there is a candidate all of whose input types are the same as the known
-	 * input type (there can be at most one such candidate).  If so, use that
-	 * candidate.  NOTE that this is cool only because operators can't
-	 * have more than 2 args, so taking the last non-unknown as current_type
-	 * can yield only one possibility if there is also an unknown.
+	 * there is a candidate all of whose input types are the same as the
+	 * known input type (there can be at most one such candidate).	If so,
+	 * use that candidate.	NOTE that this is cool only because operators
+	 * can't have more than 2 args, so taking the last non-unknown as
+	 * current_type can yield only one possibility if there is also an
+	 * unknown.
 	 */
 	unknownOids = FALSE;
 	current_type = UNKNOWNOID;
@@ -410,16 +409,16 @@ oper_select_candidate(int nargs,
 	}
 
 	/*
-	 * Second try: examine each unknown argument position to see if all the
-	 * candidates agree on the type category of that slot.  If so, and if some
-	 * candidates accept the preferred type in that category, eliminate the
-	 * candidates with other input types.  If we are down to one candidate
-	 * at the end, we win.
+	 * Second try: examine each unknown argument position to see if all
+	 * the candidates agree on the type category of that slot.	If so, and
+	 * if some candidates accept the preferred type in that category,
+	 * eliminate the candidates with other input types.  If we are down to
+	 * one candidate at the end, we win.
 	 *
 	 * XXX It's kinda bogus to do this left-to-right, isn't it?  If we
-	 * eliminate some candidates because they are non-preferred at the first
-	 * slot, we won't notice that they didn't have the same type category for
-	 * a later slot.
+	 * eliminate some candidates because they are non-preferred at the
+	 * first slot, we won't notice that they didn't have the same type
+	 * category for a later slot.
 	 */
 	for (i = 0; i < nargs; i++)
 	{
@@ -472,7 +471,7 @@ oper_select_candidate(int nargs,
 					last_candidate = current_candidate;
 				}
 			}
-			if (last_candidate)			/* terminate rebuilt list */
+			if (last_candidate) /* terminate rebuilt list */
 				last_candidate->next = NULL;
 		}
 	}
@@ -588,9 +587,7 @@ oper(char *opname, Oid ltypeId, Oid rtypeId, bool noWarnings)
 	{
 	}
 	else if (!noWarnings)
-	{
 		op_error(opname, ltypeId, rtypeId);
-	}
 
 	return (Operator) tup;
 }	/* oper() */
@@ -679,14 +676,12 @@ right_oper(char *op, Oid arg)
 		/* Try for inexact matches */
 		ncandidates = unary_oper_get_candidates(op, &candidates, 'r');
 		if (ncandidates == 0)
-		{
 			unary_op_error(op, arg, FALSE);
-		}
 		else if (ncandidates == 1)
 		{
 			tup = SearchSysCacheTuple(OPERNAME,
 									  PointerGetDatum(op),
-									  ObjectIdGetDatum(candidates->args[0]),
+								   ObjectIdGetDatum(candidates->args[0]),
 									  ObjectIdGetDatum(InvalidOid),
 									  CharGetDatum('r'));
 		}
@@ -731,15 +726,13 @@ left_oper(char *op, Oid arg)
 		/* Try for inexact matches */
 		ncandidates = unary_oper_get_candidates(op, &candidates, 'l');
 		if (ncandidates == 0)
-		{
 			unary_op_error(op, arg, TRUE);
-		}
 		else if (ncandidates == 1)
 		{
 			tup = SearchSysCacheTuple(OPERNAME,
 									  PointerGetDatum(op),
 									  ObjectIdGetDatum(InvalidOid),
-									  ObjectIdGetDatum(candidates->args[0]),
+								   ObjectIdGetDatum(candidates->args[0]),
 									  CharGetDatum('l'));
 		}
 		else
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 76c79de6c6d88c5ac49562f0b149e741823482c1..4bb65cf27e808d98ecf01aceee2b1adf3e7bb66a 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.39 2000/03/23 07:38:30 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.40 2000/04/12 17:15:27 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -76,7 +76,7 @@ static char *attnum_type[SPECIALS] = {
  * - thomas 2000-03-04
  */
 List *
-refnameRangeTableEntries(ParseState *pstate, char *refname);
+			refnameRangeTableEntries(ParseState *pstate, char *refname);
 
 List *
 refnameRangeTableEntries(ParseState *pstate, char *refname)
@@ -119,7 +119,7 @@ refnameRangeTableEntry(ParseState *pstate, char *refname)
 }
 
 /* given refname, return RT index (starting with 1) of the relation,
- * and optionally get its nesting depth (0 = current).  If sublevels_up
+ * and optionally get its nesting depth (0 = current).	If sublevels_up
  * is NULL, only consider rels at the current nesting level.
  */
 int
@@ -179,8 +179,9 @@ colnameRangeTableEntry(ParseState *pstate, char *colname)
 
 			if (rte->eref->attrs != NULL)
 			{
-				List *c;
-				foreach (c, rte->ref->attrs)
+				List	   *c;
+
+				foreach(c, rte->ref->attrs)
 				{
 					if (strcmp(strVal(lfirst(c)), colname) == 0)
 					{
@@ -192,16 +193,14 @@ colnameRangeTableEntry(ParseState *pstate, char *colname)
 				}
 			}
 
-			/* Even if we have an attribute list in the RTE,
-			 * look for the column here anyway. This is the only
-			 * way we will find implicit columns like "oid".
-			 * - thomas 2000-02-07
+			/*
+			 * Even if we have an attribute list in the RTE, look for the
+			 * column here anyway. This is the only way we will find
+			 * implicit columns like "oid". - thomas 2000-02-07
 			 */
 			if ((rte_candidate == NULL)
 				&& (get_attnum(rte->relid, colname) != InvalidAttrNumber))
-			{
 				rte_candidate = rte;
-			}
 
 			if (rte_candidate == NULL)
 				continue;
@@ -236,18 +235,18 @@ addRangeTableEntry(ParseState *pstate,
 				   bool inFromCl,
 				   bool inJoinSet)
 {
-	Relation		rel;
-	RangeTblEntry  *rte;
-	Attr		   *eref;
-	int				maxattrs;
-	int				sublevels_up;
-	int				varattno;
+	Relation	rel;
+	RangeTblEntry *rte;
+	Attr	   *eref;
+	int			maxattrs;
+	int			sublevels_up;
+	int			varattno;
 
 	/* Look for an existing rte, if available... */
 	if (pstate != NULL)
 	{
-		int rt_index = refnameRangeTablePosn(pstate, ref->relname,
-											 &sublevels_up);
+		int			rt_index = refnameRangeTablePosn(pstate, ref->relname,
+													 &sublevels_up);
 
 		if (rt_index != 0 && (!inFromCl || sublevels_up == 0))
 		{
@@ -262,12 +261,11 @@ addRangeTableEntry(ParseState *pstate,
 	rte->relname = relname;
 	rte->ref = ref;
 
-	/* Get the rel's OID.  This access also ensures that we have an
-	 * up-to-date relcache entry for the rel.  We don't need to keep
-	 * it open, however.
-	 * Since this is open anyway, let's check that the number of column
-	 * aliases is reasonable.
-	 * - Thomas 2000-02-04
+	/*
+	 * Get the rel's OID.  This access also ensures that we have an
+	 * up-to-date relcache entry for the rel.  We don't need to keep it
+	 * open, however. Since this is open anyway, let's check that the
+	 * number of column aliases is reasonable. - Thomas 2000-02-04
 	 */
 	rel = heap_openr(relname, AccessShareLock);
 	rte->relid = RelationGetRelid(rel);
@@ -290,10 +288,9 @@ addRangeTableEntry(ParseState *pstate,
 	rte->eref = eref;
 
 	/*
-	 * Flags:
-	 * - this RTE should be expanded to include descendant tables,
-	 * - this RTE is in the FROM clause,
-	 * - this RTE should be included in the planner's final join.
+	 * Flags: - this RTE should be expanded to include descendant tables,
+	 * - this RTE is in the FROM clause, - this RTE should be included in
+	 * the planner's final join.
 	 */
 	rte->inh = inh;
 	rte->inFromCl = inFromCl;
@@ -318,18 +315,16 @@ addRangeTableEntry(ParseState *pstate,
 Attr *
 expandTable(ParseState *pstate, char *refname, bool getaliases)
 {
-	Attr			   *attr;
-	RangeTblEntry	   *rte;
-	Relation			rel;
+	Attr	   *attr;
+	RangeTblEntry *rte;
+	Relation	rel;
 	int			varattno,
 				maxattrs;
 
 	rte = refnameRangeTableEntry(pstate, refname);
 
 	if (getaliases && (rte != NULL))
-	{
 		return rte->eref;
-	}
 
 	if (rte != NULL)
 		rel = heap_open(rte->relid, AccessShareLock);
@@ -350,7 +345,7 @@ expandTable(ParseState *pstate, char *refname, bool getaliases)
 #ifdef	_DROP_COLUMN_HACK__
 		if (COLUMN_IS_DROPPED(rel->rd_att->attrs[varattno]))
 			continue;
-#endif	/* _DROP_COLUMN_HACK__ */
+#endif	 /* _DROP_COLUMN_HACK__ */
 		attrname = pstrdup(NameStr(rel->rd_att->attrs[varattno]->attname));
 		attr->attrs = lappend(attr->attrs, makeString(attrname));
 	}
@@ -367,11 +362,11 @@ expandTable(ParseState *pstate, char *refname, bool getaliases)
 List *
 expandAll(ParseState *pstate, char *relname, Attr *ref, int *this_resno)
 {
-	List		   *te_list = NIL;
-	RangeTblEntry  *rte;
-	Relation		rel;
-	int				varattno,
-					maxattrs;
+	List	   *te_list = NIL;
+	RangeTblEntry *rte;
+	Relation	rel;
+	int			varattno,
+				maxattrs;
 
 	rte = refnameRangeTableEntry(pstate, ref->relname);
 	if (rte == NULL)
@@ -379,9 +374,9 @@ expandAll(ParseState *pstate, char *relname, Attr *ref, int *this_resno)
 		rte = addRangeTableEntry(pstate, relname, ref,
 								 FALSE, FALSE, TRUE);
 #ifdef WARN_FROM
-		elog(NOTICE,"Adding missing FROM-clause entry%s for table %s",
-			pstate->parentParseState != NULL ? " in subquery" : "",
-			refname);
+		elog(NOTICE, "Adding missing FROM-clause entry%s for table %s",
+			 pstate->parentParseState != NULL ? " in subquery" : "",
+			 refname);
 #endif
 	}
 
@@ -391,18 +386,21 @@ expandAll(ParseState *pstate, char *relname, Attr *ref, int *this_resno)
 
 	for (varattno = 0; varattno < maxattrs; varattno++)
 	{
-		char		   *attrname;
-		char		   *label;
-		Var			   *varnode;
-		TargetEntry	   *te = makeNode(TargetEntry);
+		char	   *attrname;
+		char	   *label;
+		Var		   *varnode;
+		TargetEntry *te = makeNode(TargetEntry);
 
 #ifdef	_DROP_COLUMN_HACK__
 		if (COLUMN_IS_DROPPED(rel->rd_att->attrs[varattno]))
 			continue;
-#endif	/* _DROP_COLUMN_HACK__ */
+#endif	 /* _DROP_COLUMN_HACK__ */
 		attrname = pstrdup(NameStr(rel->rd_att->attrs[varattno]->attname));
 
-		/* varattno is zero-based, so check that length() is always greater */
+		/*
+		 * varattno is zero-based, so check that length() is always
+		 * greater
+		 */
 		if (length(rte->eref->attrs) > varattno)
 			label = pstrdup(strVal(nth(varattno, rte->eref->attrs)));
 		else
@@ -452,7 +450,7 @@ attnameAttNum(Relation rd, char *a)
 	/* on failure */
 	elog(ERROR, "Relation '%s' does not have attribute '%s'",
 		 RelationGetRelationName(rd), a);
-	return InvalidAttrNumber;		/* lint */
+	return InvalidAttrNumber;	/* lint */
 }
 
 /* specialAttNum()
@@ -528,8 +526,3 @@ attnumTypeId(Relation rd, int attid)
 	 */
 	return rd->rd_att->attrs[attid - 1]->atttypid;
 }
-
-
-
-
-
diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c
index 65a5b33d58c174c43fdc3a8d0bc1f3d063e9e5ec..d8ba6aedb7d63df9914b8f21e9c5c5357781c5fe 100644
--- a/src/backend/parser/parse_target.c
+++ b/src/backend/parser/parse_target.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.57 2000/03/14 23:06:33 thomas Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.58 2000/04/12 17:15:27 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -61,7 +61,9 @@ transformTargetEntry(ParseState *pstate,
 
 	if (colname == NULL)
 	{
-		/* Generate a suitable column name for a column without any
+
+		/*
+		 * Generate a suitable column name for a column without any
 		 * explicit 'AS ColumnName' clause.
 		 */
 		colname = FigureColname(expr, node);
@@ -101,14 +103,16 @@ transformTargetList(ParseState *pstate, List *targetlist)
 
 			if (att->relname != NULL && strcmp(att->relname, "*") == 0)
 			{
+
 				/*
-				 * Target item is a single '*', expand all tables
-				 * (eg. SELECT * FROM emp)
+				 * Target item is a single '*', expand all tables (eg.
+				 * SELECT * FROM emp)
 				 */
 				if (pstate->p_shape != NULL)
 				{
-					List *s, *a;
-					int i;
+					List	   *s,
+							   *a;
+					int			i;
 
 					Assert(length(pstate->p_shape) == length(pstate->p_alias));
 
@@ -116,12 +120,12 @@ transformTargetList(ParseState *pstate, List *targetlist)
 					a = pstate->p_alias;
 					for (i = 0; i < length(pstate->p_shape); i++)
 					{
-						TargetEntry	   *te;
-						char		   *colname;
-						Attr *shape = lfirst(s);
-						Attr *alias = lfirst(a);
+						TargetEntry *te;
+						char	   *colname;
+						Attr	   *shape = lfirst(s);
+						Attr	   *alias = lfirst(a);
 
-						Assert(IsA(shape, Attr) && IsA(alias, Attr));
+						Assert(IsA(shape, Attr) &&IsA(alias, Attr));
 
 						colname = strVal(lfirst(alias->attrs));
 						te = transformTargetEntry(pstate, (Node *) shape,
@@ -138,9 +142,10 @@ transformTargetList(ParseState *pstate, List *targetlist)
 			else if (att->attrs != NIL &&
 					 strcmp(strVal(lfirst(att->attrs)), "*") == 0)
 			{
+
 				/*
-				 * Target item is relation.*, expand that table
-				 * (eg. SELECT emp.*, dname FROM emp, dept)
+				 * Target item is relation.*, expand that table (eg.
+				 * SELECT emp.*, dname FROM emp, dept)
 				 */
 				p_target = nconc(p_target,
 								 expandAll(pstate, att->relname,
@@ -178,7 +183,7 @@ transformTargetList(ParseState *pstate, List *targetlist)
 
 /*
  * updateTargetListEntry()
- *	This is used in INSERT and UPDATE statements only.  It prepares a
+ *	This is used in INSERT and UPDATE statements only.	It prepares a
  *	TargetEntry for assignment to a column of the target table.
  *	This includes coercing the given value to the target column's type
  *	(if necessary), and dealing with any subscripts attached to the target
@@ -197,7 +202,7 @@ updateTargetListEntry(ParseState *pstate,
 					  int attrno,
 					  List *indirection)
 {
-	Oid			type_id = exprType(tle->expr); /* type of value provided */
+	Oid			type_id = exprType(tle->expr);	/* type of value provided */
 	Oid			attrtype;		/* type of target column */
 	int32		attrtypmod;
 	Resdom	   *resnode = tle->resdom;
@@ -210,18 +215,20 @@ updateTargetListEntry(ParseState *pstate,
 	attrtypmod = rd->rd_att->attrs[attrno - 1]->atttypmod;
 
 	/*
-	 * If there are subscripts on the target column, prepare an
-	 * array assignment expression.  This will generate an array value
-	 * that the source value has been inserted into, which can then
-	 * be placed in the new tuple constructed by INSERT or UPDATE.
-	 * Note that transformArraySubscripts takes care of type coercion.
+	 * If there are subscripts on the target column, prepare an array
+	 * assignment expression.  This will generate an array value that the
+	 * source value has been inserted into, which can then be placed in
+	 * the new tuple constructed by INSERT or UPDATE. Note that
+	 * transformArraySubscripts takes care of type coercion.
 	 */
 	if (indirection)
 	{
 #ifndef DISABLE_JOIN_SYNTAX
 		Attr	   *att = makeAttr(pstrdup(RelationGetRelationName(rd)), colname);
+
 #else
 		Attr	   *att = makeNode(Attr);
+
 #endif
 		Node	   *arrayBase;
 		ArrayRef   *aref;
@@ -239,24 +246,26 @@ updateTargetListEntry(ParseState *pstate,
 										tle->expr);
 		if (pstate->p_is_insert)
 		{
+
 			/*
 			 * The command is INSERT INTO table (arraycol[subscripts]) ...
 			 * so there is not really a source array value to work with.
-			 * Let the executor do something reasonable, if it can.
-			 * Notice that we forced transformArraySubscripts to treat
-			 * the subscripting op as an array-slice op above, so the
-			 * source data will have been coerced to array type.
+			 * Let the executor do something reasonable, if it can. Notice
+			 * that we forced transformArraySubscripts to treat the
+			 * subscripting op as an array-slice op above, so the source
+			 * data will have been coerced to array type.
 			 */
-			aref->refexpr = NULL; /* signal there is no source array */
+			aref->refexpr = NULL;		/* signal there is no source array */
 		}
 		tle->expr = (Node *) aref;
 	}
 	else
 	{
+
 		/*
-		 * For normal non-subscripted target column, do type checking
-		 * and coercion.  But accept InvalidOid, which indicates the
-		 * source is a NULL constant.
+		 * For normal non-subscripted target column, do type checking and
+		 * coercion.  But accept InvalidOid, which indicates the source is
+		 * a NULL constant.
 		 */
 		if (type_id != InvalidOid)
 		{
@@ -267,11 +276,12 @@ updateTargetListEntry(ParseState *pstate,
 				if (tle->expr == NULL)
 					elog(ERROR, "Attribute '%s' is of type '%s'"
 						 " but expression is of type '%s'"
-						 "\n\tYou will need to rewrite or cast the expression",
+					"\n\tYou will need to rewrite or cast the expression",
 						 colname,
 						 typeidTypeName(attrtype),
 						 typeidTypeName(type_id));
 			}
+
 			/*
 			 * If the target is a fixed-length type, it may need a length
 			 * coercion as well as a type coercion.
@@ -282,9 +292,10 @@ updateTargetListEntry(ParseState *pstate,
 	}
 
 	/*
-	 * The result of the target expression should now match the destination
-	 * column's type.  Also, reset the resname and resno to identify
-	 * the destination column --- rewriter and planner depend on that!
+	 * The result of the target expression should now match the
+	 * destination column's type.  Also, reset the resname and resno to
+	 * identify the destination column --- rewriter and planner depend on
+	 * that!
 	 */
 	resnode->restype = attrtype;
 	resnode->restypmod = attrtypmod;
@@ -344,6 +355,7 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos)
 
 	if (cols == NIL)
 	{
+
 		/*
 		 * Generate default column list for INSERT.
 		 */
@@ -357,20 +369,19 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos)
 
 #ifdef	_DROP_COLUMN_HACK__
 			if (COLUMN_IS_DROPPED(attr[i]))
-			{
 				continue;
-			}
-#endif	/* _DROP_COLUMN_HACK__ */
+#endif	 /* _DROP_COLUMN_HACK__ */
 			id->name = palloc(NAMEDATALEN);
 			StrNCpy(id->name, NameStr(attr[i]->attname), NAMEDATALEN);
 			id->indirection = NIL;
 			id->isRel = false;
 			cols = lappend(cols, id);
-			*attrnos = lappendi(*attrnos, i+1);
+			*attrnos = lappendi(*attrnos, i + 1);
 		}
 	}
 	else
 	{
+
 		/*
 		 * Do initial validation of user-supplied INSERT column list.
 		 */
@@ -407,6 +418,7 @@ ExpandAllTables(ParseState *pstate)
 	rtable = pstate->p_rtable;
 	if (pstate->p_is_rule)
 	{
+
 		/*
 		 * skip first two entries, "*new*" and "*current*"
 		 */
@@ -422,9 +434,9 @@ ExpandAllTables(ParseState *pstate)
 		RangeTblEntry *rte = lfirst(rt);
 
 		/*
-		 * we only expand those listed in the from clause. (This will
-		 * also prevent us from using the wrong table in inserts: eg.
-		 * tenk2 in "insert into tenk2 select * from tenk1;")
+		 * we only expand those listed in the from clause. (This will also
+		 * prevent us from using the wrong table in inserts: eg. tenk2 in
+		 * "insert into tenk2 select * from tenk1;")
 		 */
 		if (!rte->inFromCl)
 			continue;
@@ -449,11 +461,12 @@ FigureColname(Node *expr, Node *resval)
 	/* Some of these are easiest to do with the untransformed node */
 	switch (nodeTag(resval))
 	{
-		case T_Ident:
+			case T_Ident:
 			return ((Ident *) resval)->name;
 		case T_Attr:
 			{
 				List	   *attrs = ((Attr *) resval)->attrs;
+
 				if (attrs)
 				{
 					while (lnext(attrs) != NIL)
diff --git a/src/backend/parser/parser.c b/src/backend/parser/parser.c
index 488df8a8c9f5969676f5e4414f057962f8bc6ca6..a7652407b73252f8fdc98661529e3f9188f73a65 100644
--- a/src/backend/parser/parser.c
+++ b/src/backend/parser/parser.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.44 2000/03/17 05:29:05 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.45 2000/04/12 17:15:27 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -20,6 +20,7 @@
 
 #if defined(FLEX_SCANNER)
 extern void DeleteBuffer(void);
+
 #endif	 /* FLEX_SCANNER */
 
 char	   *parseString;		/* the char* which holds the string to be
diff --git a/src/backend/parser/scansup.c b/src/backend/parser/scansup.c
index ae05569071d39edce26c9321ec00e5d74783eaf2..3a82ee51b77358e0e1a4352802578ef8e95f00ae 100644
--- a/src/backend/parser/scansup.c
+++ b/src/backend/parser/scansup.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.18 2000/01/26 05:56:43 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.19 2000/04/12 17:15:27 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -44,7 +44,7 @@ scanstr(char *s)
 
 	len = strlen(s);
 
-	newStr = palloc(len+1);		/* string cannot get longer */
+	newStr = palloc(len + 1);	/* string cannot get longer */
 
 	for (i = 0, j = 0; i < len; i++)
 	{
diff --git a/src/backend/port/isinf.c b/src/backend/port/isinf.c
index 5bcb813a60da66485647b269134026124bd37a47..208cef53494fe673f6b2f787b20bad8f2d3839ef 100644
--- a/src/backend/port/isinf.c
+++ b/src/backend/port/isinf.c
@@ -1,10 +1,11 @@
-/* $Id: isinf.c,v 1.14 1999/12/16 01:25:02 momjian Exp $ */
+/* $Id: isinf.c,v 1.15 2000/04/12 17:15:28 momjian Exp $ */
 
 #include <math.h>
 
 #include "config.h"
 
-#if HAVE_FPCLASS /* this is _not_ HAVE_FP_CLASS, and not typo */
+#if HAVE_FPCLASS				/* this is _not_ HAVE_FP_CLASS, and not
+								 * typo */
 
 #if HAVE_IEEEFP_H
 #include <ieeefp.h>
@@ -73,11 +74,11 @@ isinf(double x)
 int
 isinf(double x)
 {
-        if (x == HUGE_VAL)
-                return 1;
-        if (x == -HUGE_VAL)
-                return -1;
-        return 0;
+	if (x == HUGE_VAL)
+		return 1;
+	if (x == -HUGE_VAL)
+		return -1;
+	return 0;
 }
 
 #endif
diff --git a/src/backend/port/qnx4/ipc.h b/src/backend/port/qnx4/ipc.h
index 00681a7188619d5f25b1d3c0646ba58b1655e2ac..0911cc352733e4cb24eb00c62317ff5ff9ef1b1f 100644
--- a/src/backend/port/qnx4/ipc.h
+++ b/src/backend/port/qnx4/ipc.h
@@ -7,24 +7,24 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/ipc.h,v 1.1 1999/12/16 16:52:52 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/ipc.h,v 1.2 2000/04/12 17:15:30 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 
-#ifndef	_SYS_IPC_H
-#define	_SYS_IPC_H
+#ifndef _SYS_IPC_H
+#define _SYS_IPC_H
 
 /* Common IPC definitions. */
 /* Mode bits. */
 #define IPC_CREAT	0001000		/* create entry if key doesn't exist */
-#define IPC_EXCL 	0002000		/* fail if key exists */
-#define IPC_NOWAIT 	0004000		/* error if request must wait */
+#define IPC_EXCL	0002000		/* fail if key exists */
+#define IPC_NOWAIT	0004000		/* error if request must wait */
 
 /* Keys. */
-#define IPC_PRIVATE	(key_t)0        /* private key */
+#define IPC_PRIVATE (key_t)0	/* private key */
 
 /* Control Commands. */
-#define IPC_RMID	0		/* remove identifier */
+#define IPC_RMID	0			/* remove identifier */
 
-#endif	/* _SYS_IPC_H */
+#endif	 /* _SYS_IPC_H */
diff --git a/src/backend/port/qnx4/isnan.c b/src/backend/port/qnx4/isnan.c
index 2c001bb2c19a251d288c2df512857aa30b53ea17..a0afb3d184962c8cea5b09acb0417b3cf12607cb 100644
--- a/src/backend/port/qnx4/isnan.c
+++ b/src/backend/port/qnx4/isnan.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/isnan.c,v 1.1 1999/12/16 16:52:52 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/isnan.c,v 1.2 2000/04/12 17:15:30 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -16,7 +16,8 @@
 
 unsigned char __nan[8] = __nan_bytes;
 
-int isnan(double dsrc)
+int
+isnan(double dsrc)
 {
-  return !memcmp( &dsrc, &NAN, sizeof( double ) );
+	return !memcmp(&dsrc, &NAN, sizeof(double));
 }
diff --git a/src/backend/port/qnx4/rint.c b/src/backend/port/qnx4/rint.c
index 2683ce849b741a0881de15d4657c078ad57f08e7..4450d8c0567bc3ebfcedec04f5b4bb9b3d50737b 100644
--- a/src/backend/port/qnx4/rint.c
+++ b/src/backend/port/qnx4/rint.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/rint.c,v 1.1 1999/12/16 16:52:52 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/rint.c,v 1.2 2000/04/12 17:15:30 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -15,17 +15,23 @@
 #include <math.h>
 #include "os.h"
 
-double rint(double x)
+double
+rint(double x)
 {
-  double f, n = 0.;
+	double		f,
+				n = 0.;
 
-  f = modf( x, &n );
+	f = modf(x, &n);
 
-  if( x > 0. )  {
-    if( f > .5 ) n += 1.;
-  }
-  else if( x < 0. )  {
-    if( f < -.5 ) n -= 1.;
-  }
-  return n;
+	if (x > 0.)
+	{
+		if (f > .5)
+			n += 1.;
+	}
+	else if (x < 0.)
+	{
+		if (f < -.5)
+			n -= 1.;
+	}
+	return n;
 }
diff --git a/src/backend/port/qnx4/sem.c b/src/backend/port/qnx4/sem.c
index 426329469ff8aaca1dc8b558196943646ec3ec30..bcd784e6c215d654f86fea3de5fdd373e3679ada 100644
--- a/src/backend/port/qnx4/sem.c
+++ b/src/backend/port/qnx4/sem.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/sem.c,v 1.2 2000/03/14 18:12:06 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/sem.c,v 1.3 2000/04/12 17:15:30 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -29,282 +29,321 @@
 #define SEMMAX	(PROC_NSEMS_PER_SET)
 #define OPMAX	8
 
-#define MODE    0700
-#define SHM_INFO_NAME   "SysV_Sem_Info"
+#define MODE	0700
+#define SHM_INFO_NAME	"SysV_Sem_Info"
 
 
-struct pending_ops {
-    int         	op[OPMAX];		/* array of pending operations */
-    int         	idx;			/* index of first free array member */
+struct pending_ops
+{
+	int			op[OPMAX];		/* array of pending operations */
+	int			idx;			/* index of first free array member */
 };
 
-struct sem_info {
-  sem_t sem;
-  struct {
-    key_t		key;
-    int			nsems;
-    sem_t		sem[SEMMAX];		/* array of POSIX semaphores */
-    struct sem		semV[SEMMAX];		/* array of System V semaphore structures */
-    struct pending_ops	pendingOps[SEMMAX];	/* array of pending operations */
-  } set[SETMAX];
+struct sem_info
+{
+	sem_t		sem;
+	struct
+	{
+		key_t		key;
+		int			nsems;
+		sem_t		sem[SEMMAX];/* array of POSIX semaphores */
+		struct sem	semV[SEMMAX];		/* array of System V semaphore
+										 * structures */
+		struct pending_ops pendingOps[SEMMAX];	/* array of pending
+												 * operations */
+	}			set[SETMAX];
 };
 
-static struct sem_info  *SemInfo = ( struct sem_info * )-1;
+static struct sem_info *SemInfo = (struct sem_info *) - 1;
 
 
-int semctl( int semid, int semnum, int cmd, /*...*/union semun arg )
+int
+semctl(int semid, int semnum, int cmd, /* ... */ union semun arg)
 {
-  int r = 0;
-
-  sem_wait( &SemInfo->sem );
-
-  if( semid < 0 || semid >= SETMAX ||
-      semnum < 0 || semnum >= SemInfo->set[semid].nsems )  {
-    sem_post( &SemInfo->sem );
-    errno = EINVAL;
-    return -1;
-  }
-
-  switch( cmd )  {
-    case GETNCNT:
-      r = SemInfo->set[semid].semV[semnum].semncnt;
-      break;
-
-    case GETPID:
-      r = SemInfo->set[semid].semV[semnum].sempid;
-      break;
-
-    case GETVAL:
-      r = SemInfo->set[semid].semV[semnum].semval;
-      break;
-
-    case GETALL:
-      for( semnum = 0; semnum < SemInfo->set[semid].nsems; semnum++ )  {
-        arg.array[semnum] = SemInfo->set[semid].semV[semnum].semval;
-      }
-      break;
-
-    case SETVAL:
-      SemInfo->set[semid].semV[semnum].semval = arg.val;
-      break;
-
-    case SETALL:
-      for( semnum = 0; semnum < SemInfo->set[semid].nsems; semnum++ )  {
-        SemInfo->set[semid].semV[semnum].semval = arg.array[semnum];
-      }
-      break;
-
-    case GETZCNT:
-      r = SemInfo->set[semid].semV[semnum].semzcnt;
-      break;
-
-    case IPC_RMID:
-      for( semnum = 0; semnum < SemInfo->set[semid].nsems; semnum++ )  {
-        if( sem_destroy( &SemInfo->set[semid].sem[semnum] ) == -1 )  {
-          r = -1;
-        }
-      }
-      SemInfo->set[semid].key   = -1;
-      SemInfo->set[semid].nsems = 0;
-      break;
-
-    default:
-      sem_post( &SemInfo->sem );
-      errno = EINVAL;
-      return -1;
-  }
-
-  sem_post( &SemInfo->sem );
-
-  return r;
+	int			r = 0;
+
+	sem_wait(&SemInfo->sem);
+
+	if (semid < 0 || semid >= SETMAX ||
+		semnum < 0 || semnum >= SemInfo->set[semid].nsems)
+	{
+		sem_post(&SemInfo->sem);
+		errno = EINVAL;
+		return -1;
+	}
+
+	switch (cmd)
+	{
+		case GETNCNT:
+			r = SemInfo->set[semid].semV[semnum].semncnt;
+			break;
+
+		case GETPID:
+			r = SemInfo->set[semid].semV[semnum].sempid;
+			break;
+
+		case GETVAL:
+			r = SemInfo->set[semid].semV[semnum].semval;
+			break;
+
+		case GETALL:
+			for (semnum = 0; semnum < SemInfo->set[semid].nsems; semnum++)
+				arg.array[semnum] = SemInfo->set[semid].semV[semnum].semval;
+			break;
+
+		case SETVAL:
+			SemInfo->set[semid].semV[semnum].semval = arg.val;
+			break;
+
+		case SETALL:
+			for (semnum = 0; semnum < SemInfo->set[semid].nsems; semnum++)
+				SemInfo->set[semid].semV[semnum].semval = arg.array[semnum];
+			break;
+
+		case GETZCNT:
+			r = SemInfo->set[semid].semV[semnum].semzcnt;
+			break;
+
+		case IPC_RMID:
+			for (semnum = 0; semnum < SemInfo->set[semid].nsems; semnum++)
+			{
+				if (sem_destroy(&SemInfo->set[semid].sem[semnum]) == -1)
+					r = -1;
+			}
+			SemInfo->set[semid].key = -1;
+			SemInfo->set[semid].nsems = 0;
+			break;
+
+		default:
+			sem_post(&SemInfo->sem);
+			errno = EINVAL;
+			return -1;
+	}
+
+	sem_post(&SemInfo->sem);
+
+	return r;
 }
 
-int semget( key_t key, int nsems, int semflg )
+int
+semget(key_t key, int nsems, int semflg)
 {
-  int fd, semid, semnum/*, semnum1*/;
-  int exist = 0;
-
-  if( nsems < 0 || nsems > SEMMAX )  {
-    errno = EINVAL;
-    return -1;
-  }
-
-  /* open and map shared memory */
-  if( SemInfo == ( struct sem_info * )-1 )  {
-    /* test if the shared memory already exists */
-    fd = shm_open( SHM_INFO_NAME, O_RDWR | O_CREAT | O_EXCL, MODE );
-    if( fd == -1 && errno == EEXIST )  {
-      exist = 1;
-      fd = shm_open( SHM_INFO_NAME, O_RDWR | O_CREAT, MODE );
-    }
-    if( fd == -1 ) {
-      return fd;
-    }
-    /* The size may only be set once. Ignore errors. */
-    ltrunc( fd, sizeof( struct sem_info ), SEEK_SET );
-    SemInfo = mmap( NULL, sizeof( struct sem_info ),
-                    PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 );
-    if( SemInfo == MAP_FAILED )  {
-      return -1;
-    }
-    if( !exist )  {
-      /* create semaphore for locking */
-      sem_init( &SemInfo->sem, 1, 1 );
-      sem_wait( &SemInfo->sem );
-      /* initilize shared memory */
-      memset( SemInfo->set, 0, sizeof( SemInfo->set ) );
-      for( semid = 0; semid < SETMAX; semid++ )  {
-        SemInfo->set[semid].key = -1;
-      }
-      sem_post( &SemInfo->sem );
-    }
-  }
-
-  sem_wait( &SemInfo->sem );
-
-  if( key != IPC_PRIVATE )   {
-    /* search existing element */
-    semid = 0;
-    while( semid < SETMAX && SemInfo->set[semid].key != key ) semid++;
-    if( !( semflg & IPC_CREAT ) && semid >= SETMAX )  {
-      sem_post( &SemInfo->sem );
-      errno = ENOENT;
-      return -1;
-    }
-    else if( semid < SETMAX )  {
-      if( semflg & IPC_CREAT && semflg & IPC_EXCL )  {
-        sem_post( &SemInfo->sem );
-        errno = EEXIST;
-        return -1;
-      }
-      else  {
-        if( nsems != 0 && SemInfo->set[semid].nsems < nsems )  {
-          sem_post( &SemInfo->sem );
-          errno = EINVAL;
-          return -1;
-        }
-        sem_post( &SemInfo->sem );
-        return semid;
-      }
-    }
-  }
-
-  /* search first free element */
-  semid = 0;
-  while( semid < SETMAX && SemInfo->set[semid].key != -1 ) semid++;
-  if( semid >= SETMAX )  {
-    sem_post( &SemInfo->sem );
-    errno = ENOSPC;
-    return -1;
-  }
-
-  for( semnum = 0; semnum < nsems; semnum++ )  {
-    sem_init( &SemInfo->set[semid].sem[semnum], 1, 0 );
+	int			fd,
+				semid,
+				semnum /* , semnum1 */ ;
+	int			exist = 0;
+
+	if (nsems < 0 || nsems > SEMMAX)
+	{
+		errno = EINVAL;
+		return -1;
+	}
+
+	/* open and map shared memory */
+	if (SemInfo == (struct sem_info *) - 1)
+	{
+		/* test if the shared memory already exists */
+		fd = shm_open(SHM_INFO_NAME, O_RDWR | O_CREAT | O_EXCL, MODE);
+		if (fd == -1 && errno == EEXIST)
+		{
+			exist = 1;
+			fd = shm_open(SHM_INFO_NAME, O_RDWR | O_CREAT, MODE);
+		}
+		if (fd == -1)
+			return fd;
+		/* The size may only be set once. Ignore errors. */
+		ltrunc(fd, sizeof(struct sem_info), SEEK_SET);
+		SemInfo = mmap(NULL, sizeof(struct sem_info),
+					   PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+		if (SemInfo == MAP_FAILED)
+			return -1;
+		if (!exist)
+		{
+			/* create semaphore for locking */
+			sem_init(&SemInfo->sem, 1, 1);
+			sem_wait(&SemInfo->sem);
+			/* initilize shared memory */
+			memset(SemInfo->set, 0, sizeof(SemInfo->set));
+			for (semid = 0; semid < SETMAX; semid++)
+				SemInfo->set[semid].key = -1;
+			sem_post(&SemInfo->sem);
+		}
+	}
+
+	sem_wait(&SemInfo->sem);
+
+	if (key != IPC_PRIVATE)
+	{
+		/* search existing element */
+		semid = 0;
+		while (semid < SETMAX && SemInfo->set[semid].key != key)
+			semid++;
+		if (!(semflg & IPC_CREAT) && semid >= SETMAX)
+		{
+			sem_post(&SemInfo->sem);
+			errno = ENOENT;
+			return -1;
+		}
+		else if (semid < SETMAX)
+		{
+			if (semflg & IPC_CREAT && semflg & IPC_EXCL)
+			{
+				sem_post(&SemInfo->sem);
+				errno = EEXIST;
+				return -1;
+			}
+			else
+			{
+				if (nsems != 0 && SemInfo->set[semid].nsems < nsems)
+				{
+					sem_post(&SemInfo->sem);
+					errno = EINVAL;
+					return -1;
+				}
+				sem_post(&SemInfo->sem);
+				return semid;
+			}
+		}
+	}
+
+	/* search first free element */
+	semid = 0;
+	while (semid < SETMAX && SemInfo->set[semid].key != -1)
+		semid++;
+	if (semid >= SETMAX)
+	{
+		sem_post(&SemInfo->sem);
+		errno = ENOSPC;
+		return -1;
+	}
+
+	for (semnum = 0; semnum < nsems; semnum++)
+	{
+		sem_init(&SemInfo->set[semid].sem[semnum], 1, 0);
 /* Currently sem_init always returns -1.
-    if( sem_init( &SemInfo->set[semid].sem[semnum], 1, 0 ) == -1 )  {
-      for( semnum1 = 0; semnum1 < semnum; semnum1++ )  {
-        sem_destroy( &SemInfo->set[semid].sem[semnum1] );
-      }
-      sem_post( &SemInfo->sem );
-      return -1;
-    }
+	if( sem_init( &SemInfo->set[semid].sem[semnum], 1, 0 ) == -1 )	{
+	  for( semnum1 = 0; semnum1 < semnum; semnum1++ )  {
+		sem_destroy( &SemInfo->set[semid].sem[semnum1] );
+	  }
+	  sem_post( &SemInfo->sem );
+	  return -1;
+	}
 */
-  }
+	}
 
-  SemInfo->set[semid].key   = key;
-  SemInfo->set[semid].nsems = nsems;
+	SemInfo->set[semid].key = key;
+	SemInfo->set[semid].nsems = nsems;
 
-  sem_post( &SemInfo->sem );
+	sem_post(&SemInfo->sem);
 
-  return semid;
+	return semid;
 }
 
-int semop( int semid, struct sembuf *sops, size_t nsops )
+int
+semop(int semid, struct sembuf * sops, size_t nsops)
 {
-  int i, r = 0, r1, errno1 = 0, op;
-
-  sem_wait( &SemInfo->sem );
-
-  if( semid < 0 || semid >= SETMAX )  {
-    sem_post( &SemInfo->sem );
-    errno = EINVAL;
-    return -1;
-  }
-  for( i = 0; i < nsops; i++ )  {
-    if( /*sops[i].sem_num < 0 ||*/ sops[i].sem_num >= SemInfo->set[semid].nsems )  {
-      sem_post( &SemInfo->sem );
-      errno = EFBIG;
-      return -1;
-    }
-  }
-
-  for( i = 0; i < nsops; i++ )  {
-    if( sops[i].sem_op < 0 )  {
-      if( SemInfo->set[semid].semV[sops[i].sem_num].semval < -sops[i].sem_op )  {
-        if( sops[i].sem_flg & IPC_NOWAIT )  {
-          sem_post( &SemInfo->sem );
-          errno = EAGAIN;
-          return -1;
-        }
-        SemInfo->set[semid].semV[sops[i].sem_num].semncnt++;
-        if( SemInfo->set[semid].pendingOps[sops[i].sem_num].idx >= OPMAX )  {
-          /* pending operations array overflow */
-          sem_post( &SemInfo->sem );
-          errno = ERANGE;
-          return -1;
-        }
-        SemInfo->set[semid].pendingOps[sops[i].sem_num].op[SemInfo->set[semid].pendingOps[sops[i].sem_num].idx++] = sops[i].sem_op;
-        /* suspend */
-        sem_post( &SemInfo->sem ); /* avoid deadlock */
-        r1 = sem_wait( &SemInfo->set[semid].sem[sops[i].sem_num] );
-        sem_wait( &SemInfo->sem );
-        if( r1 )  {
-          errno1 = errno;
-          r = r1;
-          /* remove pending operation */
-          SemInfo->set[semid].pendingOps[sops[i].sem_num].op[--SemInfo->set[semid].pendingOps[sops[i].sem_num].idx] = 0;
-        }
-        else  {
-          SemInfo->set[semid].semV[sops[i].sem_num].semval -= -sops[i].sem_op;
-        }
-        SemInfo->set[semid].semV[sops[i].sem_num].semncnt--;
-      }
-      else  {
-        SemInfo->set[semid].semV[sops[i].sem_num].semval -= -sops[i].sem_op;
-      }
-    }
-    else if( sops[i].sem_op > 0 )  {
-      SemInfo->set[semid].semV[sops[i].sem_num].semval += sops[i].sem_op;
-      op = sops[i].sem_op;
-      while( op > 0 && SemInfo->set[semid].pendingOps[sops[i].sem_num].idx > 0 )  {	/* operations pending */
-        if( SemInfo->set[semid].pendingOps[sops[i].sem_num].op[SemInfo->set[semid].pendingOps[sops[i].sem_num].idx-1] + op >= 0 )  {
-          /* unsuspend processes */
-          if( sem_post( &SemInfo->set[semid].sem[sops[i].sem_num] ) )  {
-            errno1 = errno;
-            r = -1;
-          }
-          /* adjust pending operations */
-          op += SemInfo->set[semid].pendingOps[sops[i].sem_num].op[--SemInfo->set[semid].pendingOps[sops[i].sem_num].idx];
-          SemInfo->set[semid].pendingOps[sops[i].sem_num].op[SemInfo->set[semid].pendingOps[sops[i].sem_num].idx] = 0;
-        }
-        else  {
-          /* adjust pending operations */
-          SemInfo->set[semid].pendingOps[sops[i].sem_num].op[SemInfo->set[semid].pendingOps[sops[i].sem_num].idx-1] += op;
-          op = 0;
-        }
-      }
-    }
-    else /* sops[i].sem_op == 0 */  {
-      /* not supported */
-      sem_post( &SemInfo->sem );
-      errno = ENOSYS;
-      return -1;
-    }
-    SemInfo->set[semid].semV[sops[i].sem_num].sempid = getpid( );
-  }
-
-  sem_post( &SemInfo->sem );
-
-  errno = errno1;
-  return r;
+	int			i,
+				r = 0,
+				r1,
+				errno1 = 0,
+				op;
+
+	sem_wait(&SemInfo->sem);
+
+	if (semid < 0 || semid >= SETMAX)
+	{
+		sem_post(&SemInfo->sem);
+		errno = EINVAL;
+		return -1;
+	}
+	for (i = 0; i < nsops; i++)
+	{
+		if ( /* sops[i].sem_num < 0 || */ sops[i].sem_num >= SemInfo->set[semid].nsems)
+		{
+			sem_post(&SemInfo->sem);
+			errno = EFBIG;
+			return -1;
+		}
+	}
+
+	for (i = 0; i < nsops; i++)
+	{
+		if (sops[i].sem_op < 0)
+		{
+			if (SemInfo->set[semid].semV[sops[i].sem_num].semval < -sops[i].sem_op)
+			{
+				if (sops[i].sem_flg & IPC_NOWAIT)
+				{
+					sem_post(&SemInfo->sem);
+					errno = EAGAIN;
+					return -1;
+				}
+				SemInfo->set[semid].semV[sops[i].sem_num].semncnt++;
+				if (SemInfo->set[semid].pendingOps[sops[i].sem_num].idx >= OPMAX)
+				{
+					/* pending operations array overflow */
+					sem_post(&SemInfo->sem);
+					errno = ERANGE;
+					return -1;
+				}
+				SemInfo->set[semid].pendingOps[sops[i].sem_num].op[SemInfo->set[semid].pendingOps[sops[i].sem_num].idx++] = sops[i].sem_op;
+				/* suspend */
+				sem_post(&SemInfo->sem);		/* avoid deadlock */
+				r1 = sem_wait(&SemInfo->set[semid].sem[sops[i].sem_num]);
+				sem_wait(&SemInfo->sem);
+				if (r1)
+				{
+					errno1 = errno;
+					r = r1;
+					/* remove pending operation */
+					SemInfo->set[semid].pendingOps[sops[i].sem_num].op[--SemInfo->set[semid].pendingOps[sops[i].sem_num].idx] = 0;
+				}
+				else
+					SemInfo->set[semid].semV[sops[i].sem_num].semval -= -sops[i].sem_op;
+				SemInfo->set[semid].semV[sops[i].sem_num].semncnt--;
+			}
+			else
+				SemInfo->set[semid].semV[sops[i].sem_num].semval -= -sops[i].sem_op;
+		}
+		else if (sops[i].sem_op > 0)
+		{
+			SemInfo->set[semid].semV[sops[i].sem_num].semval += sops[i].sem_op;
+			op = sops[i].sem_op;
+			while (op > 0 && SemInfo->set[semid].pendingOps[sops[i].sem_num].idx > 0)
+			{					/* operations pending */
+				if (SemInfo->set[semid].pendingOps[sops[i].sem_num].op[SemInfo->set[semid].pendingOps[sops[i].sem_num].idx - 1] + op >= 0)
+				{
+					/* unsuspend processes */
+					if (sem_post(&SemInfo->set[semid].sem[sops[i].sem_num]))
+					{
+						errno1 = errno;
+						r = -1;
+					}
+					/* adjust pending operations */
+					op += SemInfo->set[semid].pendingOps[sops[i].sem_num].op[--SemInfo->set[semid].pendingOps[sops[i].sem_num].idx];
+					SemInfo->set[semid].pendingOps[sops[i].sem_num].op[SemInfo->set[semid].pendingOps[sops[i].sem_num].idx] = 0;
+				}
+				else
+				{
+					/* adjust pending operations */
+					SemInfo->set[semid].pendingOps[sops[i].sem_num].op[SemInfo->set[semid].pendingOps[sops[i].sem_num].idx - 1] += op;
+					op = 0;
+				}
+			}
+		}
+		else
+			/* sops[i].sem_op == 0 */
+		{
+			/* not supported */
+			sem_post(&SemInfo->sem);
+			errno = ENOSYS;
+			return -1;
+		}
+		SemInfo->set[semid].semV[sops[i].sem_num].sempid = getpid();
+	}
+
+	sem_post(&SemInfo->sem);
+
+	errno = errno1;
+	return r;
 }
diff --git a/src/backend/port/qnx4/sem.h b/src/backend/port/qnx4/sem.h
index a42d7fdf86efa9f1c9c7d98b31f865c41350ec58..c9fd18a05a6d8eaa721c5c73a3e0ece146126625 100644
--- a/src/backend/port/qnx4/sem.h
+++ b/src/backend/port/qnx4/sem.h
@@ -7,59 +7,63 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/sem.h,v 1.2 2000/03/14 18:12:06 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/sem.h,v 1.3 2000/04/12 17:15:30 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 
-#ifndef	_SYS_SEM_H
-#define	_SYS_SEM_H
+#ifndef _SYS_SEM_H
+#define _SYS_SEM_H
 
 #include <sys/ipc.h>
 
 #ifdef __cplusplus
-extern "C" {
+extern		"C"
+{
 #endif
 
 /*
  *	Semctl Command Definitions.
  */
 
-#define GETNCNT	3	/* get semncnt */
-#define GETPID	4	/* get sempid */
-#define GETVAL	5	/* get semval */
-#define GETALL	6	/* get all semval's */
-#define GETZCNT	7	/* get semzcnt */
-#define SETVAL	8	/* set semval */
-#define SETALL	9	/* set all semval's */
+#define GETNCNT 3				/* get semncnt */
+#define GETPID	4				/* get sempid */
+#define GETVAL	5				/* get semval */
+#define GETALL	6				/* get all semval's */
+#define GETZCNT 7				/* get semzcnt */
+#define SETVAL	8				/* set semval */
+#define SETALL	9				/* set all semval's */
 
 /*
  *	There is one semaphore structure for each semaphore in the system.
  */
 
-struct sem {
-	ushort_t	semval;		/* semaphore text map address	*/
-	pid_t		sempid;		/* pid of last operation	*/
-	ushort_t	semncnt;	/* # awaiting semval > cval	*/
-	ushort_t	semzcnt;	/* # awaiting semval = 0	*/
-};
+	struct sem
+	{
+		ushort_t	semval;		/* semaphore text map address	*/
+		pid_t		sempid;		/* pid of last operation	*/
+		ushort_t	semncnt;	/* # awaiting semval > cval */
+		ushort_t	semzcnt;	/* # awaiting semval = 0	*/
+	};
 
 /*
  * User semaphore template for semop system calls.
  */
 
-struct sembuf {
-	ushort_t	sem_num;	/* semaphore #			*/
-	short		sem_op;		/* semaphore operation		*/
-	short		sem_flg;	/* operation flags		*/
-};
+	struct sembuf
+	{
+		ushort_t	sem_num;	/* semaphore #			*/
+		short		sem_op;		/* semaphore operation		*/
+		short		sem_flg;	/* operation flags		*/
+	};
 
-extern int semctl( int semid, int semnum, int cmd, /*...*/union semun arg );
-extern int semget( key_t key, int nsems, int semflg );
-extern int semop( int semid, struct sembuf *sops, size_t nsops );
+	extern int	semctl(int semid, int semnum, int cmd, /* ... */ union semun arg);
+	extern int	semget(key_t key, int nsems, int semflg);
+	extern int	semop(int semid, struct sembuf * sops, size_t nsops);
 
 #ifdef __cplusplus
 }
+
 #endif
 
-#endif /* _SYS_SEM_H */
+#endif	 /* _SYS_SEM_H */
diff --git a/src/backend/port/qnx4/shm.c b/src/backend/port/qnx4/shm.c
index 5df3ebc8c285c2e3b1505fc3dc646e218c5e2c7c..4cf0486544b5dbdae13a55406099671596f4eaf7 100644
--- a/src/backend/port/qnx4/shm.c
+++ b/src/backend/port/qnx4/shm.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/shm.c,v 1.1 1999/12/16 16:52:52 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/shm.c,v 1.2 2000/04/12 17:15:30 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -25,169 +25,202 @@
 #define SHMMAX	1024
 
 
-struct shm_info {
-  int    shmid;
-  key_t  key;
-  size_t size;
-  void   *addr;
+struct shm_info
+{
+	int			shmid;
+	key_t		key;
+	size_t		size;
+	void	   *addr;
 };
 
-static struct shm_info  *ShmInfo;
+static struct shm_info *ShmInfo;
 
 
-static int shm_putinfo( struct shm_info *info );
-static int shm_updinfo( int i, struct shm_info *info );
-static int shm_getinfo( int shmid, struct shm_info *info );
-static int shm_getinfobyaddr( const void *addr, struct shm_info *info );
+static int	shm_putinfo(struct shm_info * info);
+static int	shm_updinfo(int i, struct shm_info * info);
+static int	shm_getinfo(int shmid, struct shm_info * info);
+static int	shm_getinfobyaddr(const void *addr, struct shm_info * info);
 
 
-static int shm_putinfo( struct shm_info *info )
+static int
+shm_putinfo(struct shm_info * info)
 {
-  int i;
-
-  if( ShmInfo == NULL )  {
-    ShmInfo = calloc( SHMMAX, sizeof( struct shm_info ) );
-    if( ShmInfo == NULL ) return -1;
-    /* initialize ShmInfo */
-    for( i = 0; i < SHMMAX; i++ )  {
-      ShmInfo[i].shmid = -1;
-    }
-  }
-
-  /* search first free element */
-  i = 0;
-  while( i < SHMMAX && ShmInfo[i].shmid != -1 ) i++;
-  if( i >= SHMMAX )  {
-    errno = ENOSPC;
-    return -1;
-  }
-
-  memcpy( &ShmInfo[i], info, sizeof( struct shm_info ) );
-  
-  return i;
+	int			i;
+
+	if (ShmInfo == NULL)
+	{
+		ShmInfo = calloc(SHMMAX, sizeof(struct shm_info));
+		if (ShmInfo == NULL)
+			return -1;
+		/* initialize ShmInfo */
+		for (i = 0; i < SHMMAX; i++)
+			ShmInfo[i].shmid = -1;
+	}
+
+	/* search first free element */
+	i = 0;
+	while (i < SHMMAX && ShmInfo[i].shmid != -1)
+		i++;
+	if (i >= SHMMAX)
+	{
+		errno = ENOSPC;
+		return -1;
+	}
+
+	memcpy(&ShmInfo[i], info, sizeof(struct shm_info));
+
+	return i;
 }
 
-static int shm_updinfo( int i, struct shm_info *info )
+static int
+shm_updinfo(int i, struct shm_info * info)
 {
-  if( i >= SHMMAX ) return -1;
-  if( ShmInfo == NULL ) return -1;
+	if (i >= SHMMAX)
+		return -1;
+	if (ShmInfo == NULL)
+		return -1;
+
+	memcpy(&ShmInfo[i], info, sizeof(struct shm_info));
 
-  memcpy( &ShmInfo[i], info, sizeof( struct shm_info ) );
-  
-  return i;
+	return i;
 }
 
-static int shm_getinfo( int shmid, struct shm_info *info )
+static int
+shm_getinfo(int shmid, struct shm_info * info)
 {
-  int i;
+	int			i;
+
+	if (ShmInfo == NULL)
+		return -1;
 
-  if( ShmInfo == NULL ) return -1;
+	/* search element */
+	i = 0;
+	while (i < SHMMAX && ShmInfo[i].shmid != shmid)
+		i++;
+	if (i >= SHMMAX)
+		return -1;
 
-  /* search element */
-  i = 0;
-  while( i < SHMMAX && ShmInfo[i].shmid != shmid ) i++;
-  if( i >= SHMMAX ) return -1;
+	memcpy(info, &ShmInfo[i], sizeof(struct shm_info));
 
-  memcpy( info, &ShmInfo[i], sizeof( struct shm_info ) );
-  
-  return i;
+	return i;
 }
 
-static int shm_getinfobyaddr( const void *addr, struct shm_info *info )
+static int
+shm_getinfobyaddr(const void *addr, struct shm_info * info)
 {
-  int i;
+	int			i;
 
-  if( ShmInfo == ( struct shm_info * )-1 ) return -1;
+	if (ShmInfo == (struct shm_info *) - 1)
+		return -1;
 
-  /* search element */
-  i = 0;
-  while( i < SHMMAX && ShmInfo[i].addr != addr ) i++;
-  if( i >= SHMMAX ) return -1;
+	/* search element */
+	i = 0;
+	while (i < SHMMAX && ShmInfo[i].addr != addr)
+		i++;
+	if (i >= SHMMAX)
+		return -1;
 
-  memcpy( info, &ShmInfo[i], sizeof( struct shm_info ) );
-  
-  return i;
+	memcpy(info, &ShmInfo[i], sizeof(struct shm_info));
+
+	return i;
 }
 
 
-void *shmat( int shmid, const void *shmaddr, int shmflg )
+void *
+shmat(int shmid, const void *shmaddr, int shmflg)
 {
-  struct shm_info info;
-  int i;
-
-  i = shm_getinfo( shmid, &info );
-  if( i == -1 )  {
-    errno = EACCES;
-    return ( void * )-1;
-  }
-
-  info.addr = mmap( ( void * )shmaddr, info.size, 
-                    PROT_READ | PROT_WRITE, MAP_SHARED, shmid, 0 );
-  if( info.addr == MAP_FAILED ) return info.addr;
-
-  if( shm_updinfo( i, &info ) == -1 )  {
-    errno = EACCES;
-    return ( void * )-1;
-  }
-
-  return info.addr;
+	struct shm_info info;
+	int			i;
+
+	i = shm_getinfo(shmid, &info);
+	if (i == -1)
+	{
+		errno = EACCES;
+		return (void *) -1;
+	}
+
+	info.addr = mmap((void *) shmaddr, info.size,
+					 PROT_READ | PROT_WRITE, MAP_SHARED, shmid, 0);
+	if (info.addr == MAP_FAILED)
+		return info.addr;
+
+	if (shm_updinfo(i, &info) == -1)
+	{
+		errno = EACCES;
+		return (void *) -1;
+	}
+
+	return info.addr;
 }
 
-int shmdt( const void *addr )
+int
+shmdt(const void *addr)
 {
-  struct shm_info info;
+	struct shm_info info;
 
-  if( shm_getinfobyaddr( addr, &info ) == -1 )  {
-    errno = EACCES;
-    return -1;
-  }
+	if (shm_getinfobyaddr(addr, &info) == -1)
+	{
+		errno = EACCES;
+		return -1;
+	}
 
-  return munmap( ( void * )addr, info.size );
+	return munmap((void *) addr, info.size);
 }
 
-int shmctl( int shmid, int cmd, struct shmid_ds *buf )
+int
+shmctl(int shmid, int cmd, struct shmid_ds * buf)
 {
-  struct shm_info info;
-  char name[NAME_MAX+1];
-
-  /* IPC_RMID supported only */
-  if( cmd != IPC_RMID )  {
-    errno = EINVAL;
-    return -1;
-  }
-
-  if( shm_getinfo( shmid, &info ) == -1 )  {
-    errno = EACCES;
-    return -1;
-  }
-
-  return shm_unlink( itoa( info.key, name, 16 ) );
+	struct shm_info info;
+	char		name[NAME_MAX + 1];
+
+	/* IPC_RMID supported only */
+	if (cmd != IPC_RMID)
+	{
+		errno = EINVAL;
+		return -1;
+	}
+
+	if (shm_getinfo(shmid, &info) == -1)
+	{
+		errno = EACCES;
+		return -1;
+	}
+
+	return shm_unlink(itoa(info.key, name, 16));
 }
 
-int shmget( key_t key, size_t size, int flags )
+int
+shmget(key_t key, size_t size, int flags)
 {
-  char name[NAME_MAX+1];
-  int  oflag = 0;
-  struct shm_info info;
-
-  if( flags & IPC_CREAT ) oflag |= O_CREAT;
-  if( flags & IPC_EXCL  ) oflag |= O_EXCL;
-  if( flags & SHM_R )  {
-    if( flags & SHM_W ) oflag |= O_RDWR;
-    else oflag |= O_RDONLY;
-  }
-  info.shmid = shm_open( itoa( key, name, 16 ), oflag, MODE );
-
-  /* store shared memory information */
-  if( info.shmid != -1 )  {
-    info.key  = key;
-    info.size = size;
-    info.addr = NULL;
-    if( shm_putinfo( &info ) == -1 ) return -1;
-  }
-
-  /* The size may only be set once. Ignore errors. */
-  ltrunc( info.shmid, size, SEEK_SET );
-
-  return info.shmid;
+	char		name[NAME_MAX + 1];
+	int			oflag = 0;
+	struct shm_info info;
+
+	if (flags & IPC_CREAT)
+		oflag |= O_CREAT;
+	if (flags & IPC_EXCL)
+		oflag |= O_EXCL;
+	if (flags & SHM_R)
+	{
+		if (flags & SHM_W)
+			oflag |= O_RDWR;
+		else
+			oflag |= O_RDONLY;
+	}
+	info.shmid = shm_open(itoa(key, name, 16), oflag, MODE);
+
+	/* store shared memory information */
+	if (info.shmid != -1)
+	{
+		info.key = key;
+		info.size = size;
+		info.addr = NULL;
+		if (shm_putinfo(&info) == -1)
+			return -1;
+	}
+
+	/* The size may only be set once. Ignore errors. */
+	ltrunc(info.shmid, size, SEEK_SET);
+
+	return info.shmid;
 }
diff --git a/src/backend/port/qnx4/shm.h b/src/backend/port/qnx4/shm.h
index e66cd6327d01adcea3e7770873e52bfea8184a0f..6fafb223785103f311dd6a15a0e88eaa938a8d8e 100644
--- a/src/backend/port/qnx4/shm.h
+++ b/src/backend/port/qnx4/shm.h
@@ -7,34 +7,37 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/shm.h,v 1.1 1999/12/16 16:52:52 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/shm.h,v 1.2 2000/04/12 17:15:30 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 
-#ifndef	_SYS_SHM_H
-#define	_SYS_SHM_H
+#ifndef _SYS_SHM_H
+#define _SYS_SHM_H
 
 #include <sys/ipc.h>
 
 #ifdef	__cplusplus
-extern "C" {
+extern		"C"
+{
 #endif
 
-#define SHM_R	0400	/* read permission */
-#define SHM_W	0200	/* write permission */
+#define SHM_R	0400			/* read permission */
+#define SHM_W	0200			/* write permission */
 
-struct shmid_ds {
-  int dummy;
-};
+	struct shmid_ds
+	{
+		int			dummy;
+	};
 
-extern void *shmat( int shmid, const void *shmaddr, int shmflg );
-extern int shmdt( const void *addr );
-extern int shmctl( int shmid, int cmd, struct shmid_ds *buf );
-extern int shmget( key_t key, size_t size, int flags );
+	extern void *shmat(int shmid, const void *shmaddr, int shmflg);
+	extern int	shmdt(const void *addr);
+	extern int	shmctl(int shmid, int cmd, struct shmid_ds * buf);
+	extern int	shmget(key_t key, size_t size, int flags);
 
 #ifdef	__cplusplus
 }
+
 #endif
 
-#endif /* _SYS_SHM_H */
+#endif	 /* _SYS_SHM_H */
diff --git a/src/backend/port/qnx4/tstrint.c b/src/backend/port/qnx4/tstrint.c
index f91ca7c1379e37ed4b68a42e33ba4a9d439517de..222051692a8f3db97a9556c795302770e7cf8f11 100644
--- a/src/backend/port/qnx4/tstrint.c
+++ b/src/backend/port/qnx4/tstrint.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/tstrint.c,v 1.1 1999/12/16 16:52:52 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/tstrint.c,v 1.2 2000/04/12 17:15:30 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -18,14 +18,16 @@
 #include "os.h"
 
 
-int main( int argc, char **argv )
+int
+main(int argc, char **argv)
 {
-  double x;
+	double		x;
 
-  if( argc != 2 ) exit( 1 );
+	if (argc != 2)
+		exit(1);
 
-  x = strtod( argv[1], NULL );
-  printf( "rint( %f ) = %f\n", x, rint( x ) );
+	x = strtod(argv[1], NULL);
+	printf("rint( %f ) = %f\n", x, rint(x));
 
-  return 0;
+	return 0;
 }
diff --git a/src/backend/port/qnx4/tstsem.c b/src/backend/port/qnx4/tstsem.c
index a604d950178e7df19346f632f925c2a3f37db773..dc697ceaed5b82954e201d992ae2d21f58a85df7 100644
--- a/src/backend/port/qnx4/tstsem.c
+++ b/src/backend/port/qnx4/tstsem.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/tstsem.c,v 1.2 2000/03/14 18:12:06 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/tstsem.c,v 1.3 2000/04/12 17:15:30 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -26,137 +26,177 @@
 #define SEMMAX	16
 #define OPSMAX	1
 
-static int semid;
+static int	semid;
 
-static void sig_handler( int sig_no )
+static void
+sig_handler(int sig_no)
 {
-  union semun arg;
-  int i = semctl( semid, 0, GETNCNT, arg );
-  if( i == -1 ) perror( "semctl" );
-  else printf( "semval = %d\n", i );
+	union semun arg;
+	int			i = semctl(semid, 0, GETNCNT, arg);
+
+	if (i == -1)
+		perror("semctl");
+	else
+		printf("semval = %d\n", i);
 }
 
-int main( int argc, char **argv )
+int
+main(int argc, char **argv)
 {
-  int     c, errflg = 0;
-  char    s[80];
-  key_t   key = IPC_PRIVATE;
-  int     nsems = SEMMAX;
-  int     semflg = 0;
-  int     unlink = 0;
-  int     i;
-  struct sembuf sops[OPSMAX];
-  u_short array[SEMMAX];
-  union semun arg;
-
-  optarg = NULL;
-  while( !errflg && ( c = getopt( argc, argv, "k:n:cxu" ) ) != -1 )  {
-    switch( c )  {
-      case 'k': key  = atoi( optarg ); break;
-      case 'n': nsems = atoi( optarg ); break;
-      case 'c': semflg |= IPC_CREAT; break;
-      case 'x': semflg |= IPC_EXCL; break;
-      case 'u': unlink = 1; break;
-      default: errflg++;
-    }
-  }
-  if( errflg )  {
-    printf( "usage: tstsem [-k key] [-n nsems] [-cxu]\n" );
-    exit( 1 );
-  }
-
-  if( unlink )  {
-    i = shm_unlink( "SysV_Sem_Info" );
-    if( i == -1 ) perror( "shm_unlink" );
-    exit( i );
-  }
-
-  semid = semget( key, nsems, semflg );
-  if( semid == -1 )  {
-    perror( "semget" );
-    exit( semid );
-  }
-
-  /* test signal interrupts */
-  signal( SIGTERM, sig_handler );
-
-  do  {
-    printf( "(-)sem_op, (+)sem_op, (G)ETVAL, (S)ETVAL, GET(P)ID, GET(A)LL, SETA(L)L, GET(N)CNT, GET(Z)CNT, e(x)it: " );
-    scanf( "%s", s );
-    switch( s[0] )  {
-      case '-': 
-      case '+': 
-        sops[0].sem_num = 0;
-        sops[0].sem_op  = atoi( s );
-        if( sops[0].sem_op == 0 ) sops[0].sem_op = s[0] == '+' ? +1 : -1;
-        sops[0].sem_flg = 0;
-        if( semop( semid, sops, 1 ) == -1 ) perror( "semop" );
-        break;
-
-      case 'G': 
-      case 'g': 
-        i = semctl( semid, 0, GETVAL, arg );
-        if( i == -1 ) perror( "semctl" );
-        else printf( "semval = %d\n", i );
-        break;
-
-      case 'S': 
-      case 's': 
-        printf( "semval = " );
-        scanf( "%d", &arg.val );
-        if( semctl( semid, 0, SETVAL, arg ) == -1 ) perror( "semctl" );
-        break;
-
-      case 'P': 
-      case 'p': 
-        i = semctl( semid, 0, GETPID, arg );
-        if( i == -1 ) perror( "semctl" );
-        else printf( "PID = %d\n", i );
-        break;
-
-      case 'A': 
-      case 'a': 
-        arg.array = array;
-        i = semctl( semid, 0, GETALL, arg );
-        if( i == -1 ) perror( "semctl" );
-        else  {
-          for( i = 0; i < nsems; i++ )  {
-            printf( "semval[%d] = %hu\n", i, arg.array[i] );
-          }
-        }
-        break;
-
-      case 'L': 
-      case 'l': 
-        arg.array = array;
-        for( i = 0; i < nsems; i++ )  {
-          printf( "semval[%d] = ", i );
-          scanf( "%hu", &arg.array[i] );
-        }
-        if( semctl( semid, 0, SETALL, arg ) == -1 )perror( "semctl" );
-        break;
-
-      case 'N': 
-      case 'n': 
-        i = semctl( semid, 0, GETNCNT, arg );
-        if( i == -1 ) perror( "semctl" );
-        else printf( "semval = %d\n", i );
-        break;
-
-      case 'Z': 
-      case 'z': 
-        i = semctl( semid, 0, GETZCNT, arg );
-        if( i == -1 ) perror( "semctl" );
-        else printf( "semval = %d\n", i );
-        break;
-    }
-  }
-  while( s[0] != 'x' );
-
-  if( semctl( semid, 0, IPC_RMID, arg ) == -1 )  {
-    perror( "semctl" );
-    exit( -1 );
-  }
-
-  exit( 0 );
+	int			c,
+				errflg = 0;
+	char		s[80];
+	key_t		key = IPC_PRIVATE;
+	int			nsems = SEMMAX;
+	int			semflg = 0;
+	int			unlink = 0;
+	int			i;
+	struct sembuf sops[OPSMAX];
+	u_short		array[SEMMAX];
+	union semun arg;
+
+	optarg = NULL;
+	while (!errflg && (c = getopt(argc, argv, "k:n:cxu")) != -1)
+	{
+		switch (c)
+		{
+			case 'k':
+				key = atoi(optarg);
+				break;
+			case 'n':
+				nsems = atoi(optarg);
+				break;
+			case 'c':
+				semflg |= IPC_CREAT;
+				break;
+			case 'x':
+				semflg |= IPC_EXCL;
+				break;
+			case 'u':
+				unlink = 1;
+				break;
+			default:
+				errflg++;
+		}
+	}
+	if (errflg)
+	{
+		printf("usage: tstsem [-k key] [-n nsems] [-cxu]\n");
+		exit(1);
+	}
+
+	if (unlink)
+	{
+		i = shm_unlink("SysV_Sem_Info");
+		if (i == -1)
+			perror("shm_unlink");
+		exit(i);
+	}
+
+	semid = semget(key, nsems, semflg);
+	if (semid == -1)
+	{
+		perror("semget");
+		exit(semid);
+	}
+
+	/* test signal interrupts */
+	signal(SIGTERM, sig_handler);
+
+	do
+	{
+		printf("(-)sem_op, (+)sem_op, (G)ETVAL, (S)ETVAL, GET(P)ID, GET(A)LL, SETA(L)L, GET(N)CNT, GET(Z)CNT, e(x)it: ");
+		scanf("%s", s);
+		switch (s[0])
+		{
+			case '-':
+			case '+':
+				sops[0].sem_num = 0;
+				sops[0].sem_op = atoi(s);
+				if (sops[0].sem_op == 0)
+					sops[0].sem_op = s[0] == '+' ? +1 : -1;
+				sops[0].sem_flg = 0;
+				if (semop(semid, sops, 1) == -1)
+					perror("semop");
+				break;
+
+			case 'G':
+			case 'g':
+				i = semctl(semid, 0, GETVAL, arg);
+				if (i == -1)
+					perror("semctl");
+				else
+					printf("semval = %d\n", i);
+				break;
+
+			case 'S':
+			case 's':
+				printf("semval = ");
+				scanf("%d", &arg.val);
+				if (semctl(semid, 0, SETVAL, arg) == -1)
+					perror("semctl");
+				break;
+
+			case 'P':
+			case 'p':
+				i = semctl(semid, 0, GETPID, arg);
+				if (i == -1)
+					perror("semctl");
+				else
+					printf("PID = %d\n", i);
+				break;
+
+			case 'A':
+			case 'a':
+				arg.array = array;
+				i = semctl(semid, 0, GETALL, arg);
+				if (i == -1)
+					perror("semctl");
+				else
+				{
+					for (i = 0; i < nsems; i++)
+						printf("semval[%d] = %hu\n", i, arg.array[i]);
+				}
+				break;
+
+			case 'L':
+			case 'l':
+				arg.array = array;
+				for (i = 0; i < nsems; i++)
+				{
+					printf("semval[%d] = ", i);
+					scanf("%hu", &arg.array[i]);
+				}
+				if (semctl(semid, 0, SETALL, arg) == -1)
+					perror("semctl");
+				break;
+
+			case 'N':
+			case 'n':
+				i = semctl(semid, 0, GETNCNT, arg);
+				if (i == -1)
+					perror("semctl");
+				else
+					printf("semval = %d\n", i);
+				break;
+
+			case 'Z':
+			case 'z':
+				i = semctl(semid, 0, GETZCNT, arg);
+				if (i == -1)
+					perror("semctl");
+				else
+					printf("semval = %d\n", i);
+				break;
+		}
+	}
+	while (s[0] != 'x');
+
+	if (semctl(semid, 0, IPC_RMID, arg) == -1)
+	{
+		perror("semctl");
+		exit(-1);
+	}
+
+	exit(0);
 }
diff --git a/src/backend/port/qnx4/tstshm.c b/src/backend/port/qnx4/tstshm.c
index e7421f5f87b9c2c711fcd65a18ec1ee6f85e2452..d6e577f2924354da189a5a7095c274e95067f510 100644
--- a/src/backend/port/qnx4/tstshm.c
+++ b/src/backend/port/qnx4/tstshm.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/tstshm.c,v 1.1 1999/12/16 16:52:52 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/tstshm.c,v 1.2 2000/04/12 17:15:30 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -18,63 +18,81 @@
 #include <sys/shm.h>
 
 
-int main( int argc, char **argv )
+int
+main(int argc, char **argv)
 {
-  int     c, errflg = 0;
-  char    s[80];
-  key_t   key = 0x1000;
-  size_t  size = 256;
-  int     shmid = -1;
-  caddr_t addr = NULL;
+	int			c,
+				errflg = 0;
+	char		s[80];
+	key_t		key = 0x1000;
+	size_t		size = 256;
+	int			shmid = -1;
+	caddr_t		addr = NULL;
 
-  optarg = NULL;
-  while( !errflg && ( c = getopt( argc, argv, "k:s:" ) ) != -1 )  {
-    switch( c )  {
-      case 'k': key  = atoi( optarg ); break;
-      case 's': size = atoi( optarg ); break;
-      default: errflg++;
-    }
-  }
-  if( errflg )  {
-    printf( "usage: tstshm [-k key] [-s size]\n" );
-    exit( 1 );
-  }
+	optarg = NULL;
+	while (!errflg && (c = getopt(argc, argv, "k:s:")) != -1)
+	{
+		switch (c)
+		{
+			case 'k':
+				key = atoi(optarg);
+				break;
+			case 's':
+				size = atoi(optarg);
+				break;
+			default:
+				errflg++;
+		}
+	}
+	if (errflg)
+	{
+		printf("usage: tstshm [-k key] [-s size]\n");
+		exit(1);
+	}
 
-  do  {
-    printf( "shm(g)et, shm(a)t, shm(d)t, shm(c)tl, (w)rite, (r)ead, e(x)it: " );
-    scanf( "%s", s );
-    switch( s[0] )  {
-      case 'g': 
-        shmid = shmget( key, size, IPC_CREAT | SHM_R | SHM_W );
-        if( shmid == -1 ) perror( "shmget" );
-        break;
+	do
+	{
+		printf("shm(g)et, shm(a)t, shm(d)t, shm(c)tl, (w)rite, (r)ead, e(x)it: ");
+		scanf("%s", s);
+		switch (s[0])
+		{
+			case 'g':
+				shmid = shmget(key, size, IPC_CREAT | SHM_R | SHM_W);
+				if (shmid == -1)
+					perror("shmget");
+				break;
 
-      case 'a': 
-        addr = shmat( shmid, NULL, 0 );
-        if( addr == ( void * )-1 ) perror( "shmat" );
-        break;
+			case 'a':
+				addr = shmat(shmid, NULL, 0);
+				if (addr == (void *) -1)
+					perror("shmat");
+				break;
 
-      case 'd': 
-        if( shmdt( addr ) == -1 ) perror( "shmdt" );
-        else addr = NULL;
-        break;
+			case 'd':
+				if (shmdt(addr) == -1)
+					perror("shmdt");
+				else
+					addr = NULL;
+				break;
 
-      case 'c': 
-        if( shmctl( shmid, IPC_RMID, NULL ) == -1 ) perror( "shmctl" );
-        else shmid = -1;
-        break;
+			case 'c':
+				if (shmctl(shmid, IPC_RMID, NULL) == -1)
+					perror("shmctl");
+				else
+					shmid = -1;
+				break;
 
-      case 'w': 
-        printf( "String to write: " );
-        scanf( "%s", addr );
-        break;
+			case 'w':
+				printf("String to write: ");
+				scanf("%s", addr);
+				break;
 
-      case 'r': 
-        puts( addr );
-        break;
-    }
-  }
-  while( s[0] != 'x' );
+			case 'r':
+				puts(addr);
+				break;
+		}
+	}
+	while (s[0] != 'x');
 
-  return 0;
+	return 0;
 }
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 7c44dbc7f9b29508b13ccfbb2c35c43baab6ad3e..9505d3599f78f6b53d77f715cd25be02483ec080 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.138 2000/03/19 22:10:08 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.139 2000/04/12 17:15:31 momjian Exp $
  *
  * NOTES
  *
@@ -109,9 +109,11 @@
 #ifdef HAVE_SIGPROCMASK
 sigset_t	UnBlockSig,
 			BlockSig;
+
 #else
 int			UnBlockSig,
 			BlockSig;
+
 #endif
 
 /*
@@ -176,12 +178,12 @@ static int	MaxBackends = DEF_MAXBACKENDS;
   * semaphores, even if you never actually use that many backends.
   */
 
-static int		NextBackendTag = MAXINT;	/* XXX why count down not up? */
-static char	   *progname = (char *) NULL;
-static char	  **real_argv;
-static int		real_argc;
+static int	NextBackendTag = MAXINT;	/* XXX why count down not up? */
+static char *progname = (char *) NULL;
+static char **real_argv;
+static int	real_argc;
 
-static time_t	tnow;
+static time_t tnow;
 
 /*
  * Default Values
@@ -196,7 +198,8 @@ static int	ServerSock_UNIX = INVALID_SOCK;		/* stream socket server */
 #endif
 
 #ifdef USE_SSL
-static SSL_CTX  *SSL_context = NULL;                    /* Global SSL context */
+static SSL_CTX *SSL_context = NULL;		/* Global SSL context */
+
 #endif
 
 /*
@@ -216,21 +219,24 @@ static int	SendStop = false;
 
 static bool NetServer = false;	/* if not zero, postmaster listen for
 								 * non-local connections */
+
 #ifdef USE_SSL
-static bool SecureNetServer = false; /* if not zero, postmaster listens for only SSL
-                                      * non-local connections */
+static bool SecureNetServer = false;	/* if not zero, postmaster listens
+										 * for only SSL non-local
+										 * connections */
+
 #endif
 
-static pid_t	StartupPID = 0,
-				ShutdownPID = 0;
+static pid_t StartupPID = 0,
+			ShutdownPID = 0;
 
 #define			NoShutdown		0
 #define			SmartShutdown	1
 #define			FastShutdown	2
 
-static int		Shutdown = NoShutdown;
+static int	Shutdown = NoShutdown;
 
-static bool		FatalError = false;
+static bool FatalError = false;
 
 /*
  * State for assigning random salts and cancel keys.
@@ -247,51 +253,55 @@ extern int	optind,
 /*
  * postmaster.c - function prototypes
  */
-static void		pmdaemonize(char *extraoptions);
-static Port	   *ConnCreate(int serverFd);
-static void		ConnFree(Port *port);
-static void 	reset_shared(unsigned short port);
-static void 	pmdie(SIGNAL_ARGS);
-static void 	reaper(SIGNAL_ARGS);
-static void 	dumpstatus(SIGNAL_ARGS);
-static void 	CleanupProc(int pid, int exitstatus);
-static int		DoBackend(Port *port);
-static void 	ExitPostmaster(int status);
-static void 	usage(const char *);
-static int		ServerLoop(void);
-static int		BackendStartup(Port *port);
-static int		readStartupPacket(void *arg, PacketLen len, void *pkt);
-static int		processCancelRequest(Port *port, PacketLen len, void *pkt);
-static int		initMasks(fd_set *rmask, fd_set *wmask);
-static long 	PostmasterRandom(void);
-static void 	RandomSalt(char *salt);
-static void 	SignalChildren(SIGNAL_ARGS);
-static int		CountChildren(void);
-static int SetOptsFile(char *progname, int port, char *datadir,
-		      int assert, int nbuf, char *execfile,
-		      int debuglvl, int netserver,
+static void pmdaemonize(char *extraoptions);
+static Port *ConnCreate(int serverFd);
+static void ConnFree(Port *port);
+static void reset_shared(unsigned short port);
+static void pmdie(SIGNAL_ARGS);
+static void reaper(SIGNAL_ARGS);
+static void dumpstatus(SIGNAL_ARGS);
+static void CleanupProc(int pid, int exitstatus);
+static int	DoBackend(Port *port);
+static void ExitPostmaster(int status);
+static void usage(const char *);
+static int	ServerLoop(void);
+static int	BackendStartup(Port *port);
+static int	readStartupPacket(void *arg, PacketLen len, void *pkt);
+static int	processCancelRequest(Port *port, PacketLen len, void *pkt);
+static int	initMasks(fd_set *rmask, fd_set *wmask);
+static long PostmasterRandom(void);
+static void RandomSalt(char *salt);
+static void SignalChildren(SIGNAL_ARGS);
+static int	CountChildren(void);
+static int
+SetOptsFile(char *progname, int port, char *datadir,
+			int assert, int nbuf, char *execfile,
+			int debuglvl, int netserver,
 #ifdef USE_SSL
-		      int securenetserver,
+			int securenetserver,
 #endif
-		      int maxbackends, int reinit,
-		      int silent, int sendstop, char *extraoptions);
+			int maxbackends, int reinit,
+			int silent, int sendstop, char *extraoptions);
 
-extern int		BootstrapMain(int argc, char *argv[]);
-static pid_t	SSDataBase(bool startup);
-#define	StartupDataBase()	SSDataBase(true)
-#define	ShutdownDataBase()	SSDataBase(false)
+extern int	BootstrapMain(int argc, char *argv[]);
+static pid_t SSDataBase(bool startup);
+
+#define StartupDataBase()	SSDataBase(true)
+#define ShutdownDataBase()	SSDataBase(false)
 
 #ifdef USE_SSL
 static void InitSSL(void);
+
 #endif
 
 #ifdef CYR_RECODE
 void		GetCharSetByHost(char *, int, char *);
+
 #endif
 
 #ifdef USE_ASSERT_CHECKING
 
-int	assert_enabled = 1;
+int			assert_enabled = 1;
 
 #endif
 
@@ -313,7 +323,7 @@ checkDataDir(const char *DataDir, bool *DataDirOK)
 		FILE	   *fp;
 
 		snprintf(path, sizeof(path), "%s%cbase%ctemplate1%cpg_class",
-				DataDir, SEP_CHAR, SEP_CHAR, SEP_CHAR);
+				 DataDir, SEP_CHAR, SEP_CHAR, SEP_CHAR);
 #ifndef __CYGWIN32__
 		fp = AllocateFile(path, "r");
 #else
@@ -366,7 +376,7 @@ PostmasterMain(int argc, char *argv[])
 	bool		DataDirOK;		/* We have a usable PGDATA value */
 	char		hostbuf[MAXHOSTNAMELEN];
 	int			nonblank_argc;
-	char original_extraoptions[MAXPGPATH];
+	char		original_extraoptions[MAXPGPATH];
 
 	*original_extraoptions = '\0';
 
@@ -478,6 +488,7 @@ PostmasterMain(int argc, char *argv[])
 				DataDir = optarg;
 				break;
 			case 'd':
+
 				/*
 				 * Turn on debugging for the postmaster and the backend
 				 * servers descended from it.
@@ -565,15 +576,18 @@ PostmasterMain(int argc, char *argv[])
 	 * Select default values for switches where needed
 	 */
 	if (PostPortName == 0)
-		PostPortName = (unsigned short)pq_getport();
+		PostPortName = (unsigned short) pq_getport();
 
 	/*
 	 * Check for invalid combinations of switches
 	 */
 	if (NBuffers < 2 * MaxBackends || NBuffers < 16)
 	{
-		/* Do not accept -B so small that backends are likely to starve for
-		 * lack of buffers.  The specific choices here are somewhat arbitrary.
+
+		/*
+		 * Do not accept -B so small that backends are likely to starve
+		 * for lack of buffers.  The specific choices here are somewhat
+		 * arbitrary.
 		 */
 		fprintf(stderr, "%s: -B must be at least twice -N and at least 16.\n",
 				progname);
@@ -608,11 +622,11 @@ PostmasterMain(int argc, char *argv[])
 	{
 		status = StreamServerPort(hostName, PostPortName, &ServerSock_INET);
 		if (status != STATUS_OK)
-	    {
+		{
 			fprintf(stderr, "%s: cannot create INET stream port\n",
 					progname);
 			exit(1);
-	    }
+		}
 	}
 
 #if !defined(__CYGWIN32__) && !defined(__QNX__)
@@ -635,65 +649,74 @@ PostmasterMain(int argc, char *argv[])
 	BackendList = DLNewList();
 	PortList = DLNewList();
 
-	if (silentflag) {
+	if (silentflag)
 		pmdaemonize(original_extraoptions);
-	} else {
+	else
+	{
+
 		/*
 		 * create pid file. if the file has already existed, exits.
 		 */
-	  SetPidFname(DataDir);
-	  if (SetPidFile(getpid()) == 0) {
-	    if (SetOptsFile(
-		       progname,	/* postmaster executable file */
-		       PostPortName,	/* port number */
-		       DataDir,		/* PGDATA */
-		       assert_enabled,	/* whether -A is specified or not */
-		       NBuffers,	/* -B: number of shared buffers */
-		       Execfile,	/* -b: postgres executable file */
-		       DebugLvl,	/* -d: debug level */
-		       NetServer,	/* -i: accept connection from INET */
+		SetPidFname(DataDir);
+		if (SetPidFile(getpid()) == 0)
+		{
+			if (SetOptsFile(
+							progname,	/* postmaster executable file */
+							PostPortName,		/* port number */
+							DataDir,	/* PGDATA */
+							assert_enabled,		/* whether -A is specified
+												 * or not */
+							NBuffers,	/* -B: number of shared buffers */
+							Execfile,	/* -b: postgres executable file */
+							DebugLvl,	/* -d: debug level */
+							NetServer,	/* -i: accept connection from INET */
 #ifdef USE_SSL
-		       SecureNetServer,	/* -l: use SSL */
+							SecureNetServer,	/* -l: use SSL */
 #endif
-		       MaxBackends,	/* -N: max number of backends */
-		       Reinit,		/* -n: reinit shared mem after failure */
-		       silentflag,	/* -S: detach tty */
-		       SendStop,	/* -s: send SIGSTOP */
-		       original_extraoptions	/* options for backend */
-		       ) != 0) {
-		    UnlinkPidFile();
-		    ExitPostmaster(1);
-		    return 0;	/* not reached */
-	    }
-	  }
-	  else {
-	    ExitPostmaster(1);
-	    return 0;	/* not reached */
-	  }
-	    
-	  /*
-	   * register clean up proc
-	   */
-	  on_proc_exit(UnlinkPidFile, NULL);
+							MaxBackends,		/* -N: max number of
+												 * backends */
+							Reinit,		/* -n: reinit shared mem after
+										 * failure */
+							silentflag, /* -S: detach tty */
+							SendStop,	/* -s: send SIGSTOP */
+							original_extraoptions		/* options for backend */
+							) != 0)
+			{
+				UnlinkPidFile();
+				ExitPostmaster(1);
+				return 0;		/* not reached */
+			}
+		}
+		else
+		{
+			ExitPostmaster(1);
+			return 0;			/* not reached */
+		}
+
+		/*
+		 * register clean up proc
+		 */
+		on_proc_exit(UnlinkPidFile, NULL);
 	}
+
 	/*
 	 * Set up signal handlers for the postmaster process.
 	 */
 	PG_INITMASK();
 	PG_SETMASK(&BlockSig);
 
-	pqsignal(SIGHUP, pmdie);		/* send SIGHUP, don't die */
-	pqsignal(SIGINT, pmdie);		/* send SIGTERM and ShutdownDataBase */
-	pqsignal(SIGQUIT, pmdie);		/* send SIGUSR1 and die */
-	pqsignal(SIGTERM, pmdie);		/* wait for children and ShutdownDataBase */
-	pqsignal(SIGALRM, SIG_IGN);		/* ignored */
-	pqsignal(SIGPIPE, SIG_IGN); 	/* ignored */
-	pqsignal(SIGUSR1, SIG_IGN);		/* ignored */
-	pqsignal(SIGUSR2, pmdie);		/* send SIGUSR2, don't die */
-	pqsignal(SIGCHLD, reaper);		/* handle child termination */
-	pqsignal(SIGTTIN, SIG_IGN); 	/* ignored */
-	pqsignal(SIGTTOU, SIG_IGN); 	/* ignored */
-	pqsignal(SIGWINCH, dumpstatus);	/* dump port status */
+	pqsignal(SIGHUP, pmdie);	/* send SIGHUP, don't die */
+	pqsignal(SIGINT, pmdie);	/* send SIGTERM and ShutdownDataBase */
+	pqsignal(SIGQUIT, pmdie);	/* send SIGUSR1 and die */
+	pqsignal(SIGTERM, pmdie);	/* wait for children and ShutdownDataBase */
+	pqsignal(SIGALRM, SIG_IGN); /* ignored */
+	pqsignal(SIGPIPE, SIG_IGN); /* ignored */
+	pqsignal(SIGUSR1, SIG_IGN); /* ignored */
+	pqsignal(SIGUSR2, pmdie);	/* send SIGUSR2, don't die */
+	pqsignal(SIGCHLD, reaper);	/* handle child termination */
+	pqsignal(SIGTTIN, SIG_IGN); /* ignored */
+	pqsignal(SIGTTOU, SIG_IGN); /* ignored */
+	pqsignal(SIGWINCH, dumpstatus);		/* dump port status */
 
 	StartupPID = StartupDataBase();
 
@@ -707,58 +730,69 @@ static void
 pmdaemonize(char *extraoptions)
 {
 	int			i;
-	pid_t	pid;
+	pid_t		pid;
 
 	SetPidFname(DataDir);
 
 	pid = fork();
-	if (pid == -1) {
+	if (pid == -1)
+	{
 		perror("Failed to fork postmaster");
 		ExitPostmaster(1);
-		return;	/* not reached */
-	} else if (pid) {	/* parent */
-	  /*
-	   * create pid file. if the file has already existed, exits.
-	   */
-	  if (SetPidFile(pid) == 0) {
-	    if (SetOptsFile(
-		       progname,	/* postmaster executable file */
-		       PostPortName,	/* port number */
-		       DataDir,		/* PGDATA */
-		       assert_enabled,	/* whether -A is specified or not */
-		       NBuffers,	/* -B: number of shared buffers */
-		       Execfile,	/* -b: postgres executable file */
-		       DebugLvl,	/* -d: debug level */
-		       NetServer,	/* -i: accept connection from INET */
+		return;					/* not reached */
+	}
+	else if (pid)
+	{							/* parent */
+
+		/*
+		 * create pid file. if the file has already existed, exits.
+		 */
+		if (SetPidFile(pid) == 0)
+		{
+			if (SetOptsFile(
+							progname,	/* postmaster executable file */
+							PostPortName,		/* port number */
+							DataDir,	/* PGDATA */
+							assert_enabled,		/* whether -A is specified
+												 * or not */
+							NBuffers,	/* -B: number of shared buffers */
+							Execfile,	/* -b: postgres executable file */
+							DebugLvl,	/* -d: debug level */
+							NetServer,	/* -i: accept connection from INET */
 #ifdef USE_SSL
-		       SecureNetServer,	/* -l: use SSL */
+							SecureNetServer,	/* -l: use SSL */
 #endif
-		       MaxBackends,	/* -N: max number of backends */
-		       Reinit,		/* -n: reinit shared mem after failure */
-		       1,		/* -S: detach tty */
-		       SendStop,	/* -s: send SIGSTOP */
-		       extraoptions	/* options for backend */
-		       ) != 0) {
-	      /*
-	       * Failed to create opts file. kill the child and
-	       * exit now.
-	       */
-	      UnlinkPidFile();
-	      kill(pid, SIGTERM);
-	      ExitPostmaster(1);
-	      return;	/* not reached */
-	    }
-	    _exit(0);
-	  }
-	  else {
-	      /*
-	       * Failed to create pid file. kill the child and
-	       * exit now.
-	       */
-	      kill(pid, SIGTERM);
-	      ExitPostmaster(1);
-	      return;	/* not reached */
-	  }
+							MaxBackends,		/* -N: max number of
+												 * backends */
+							Reinit,		/* -n: reinit shared mem after
+										 * failure */
+							1,	/* -S: detach tty */
+							SendStop,	/* -s: send SIGSTOP */
+							extraoptions		/* options for backend */
+							) != 0)
+			{
+
+				/*
+				 * Failed to create opts file. kill the child and exit
+				 * now.
+				 */
+				UnlinkPidFile();
+				kill(pid, SIGTERM);
+				ExitPostmaster(1);
+				return;			/* not reached */
+			}
+			_exit(0);
+		}
+		else
+		{
+
+			/*
+			 * Failed to create pid file. kill the child and exit now.
+			 */
+			kill(pid, SIGTERM);
+			ExitPostmaster(1);
+			return;				/* not reached */
+		}
 	}
 
 /* GH: If there's no setsid(), we hopefully don't need silent mode.
@@ -803,7 +837,7 @@ usage(const char *progname)
 	fprintf(stderr, "\t-d [1-5]\tset debugging level\n");
 	fprintf(stderr, "\t-i \t\tlisten on TCP/IP sockets as well as Unix domain socket\n");
 #ifdef USE_SSL
-	fprintf(stderr," \t-l \t\tfor TCP/IP sockets, listen only on SSL connections\n");
+	fprintf(stderr, " \t-l \t\tfor TCP/IP sockets, listen only on SSL connections\n");
 #endif
 	fprintf(stderr, "\t-N nprocs\tset max number of backends (1..%d, default %d)\n",
 			MAXBACKENDS, DEF_MAXBACKENDS);
@@ -834,8 +868,10 @@ ServerLoop(void)
 		Port	   *port;
 		fd_set		rmask,
 					wmask;
+
 #ifdef USE_SSL
-		int no_select = 0;
+		int			no_select = 0;
+
 #endif
 
 		memmove((char *) &rmask, (char *) &readmask, sizeof(fd_set));
@@ -844,16 +880,16 @@ ServerLoop(void)
 #ifdef USE_SSL
 		for (curr = DLGetHead(PortList); curr; curr = DLGetSucc(curr))
 		{
-			if (((Port *)DLE_VAL(curr))->ssl &&
-				SSL_pending(((Port *)DLE_VAL(curr))->ssl) > 0)
+			if (((Port *) DLE_VAL(curr))->ssl &&
+				SSL_pending(((Port *) DLE_VAL(curr))->ssl) > 0)
 			{
-			    no_select = 1;
-			    break;
+				no_select = 1;
+				break;
 			}
 		}
 		PG_SETMASK(&UnBlockSig);
-		if (no_select) 
-		  FD_ZERO(&rmask); /* So we don't accept() anything below */
+		if (no_select)
+			FD_ZERO(&rmask);	/* So we don't accept() anything below */
 		else
 #else
 		PG_SETMASK(&UnBlockSig);
@@ -895,16 +931,18 @@ ServerLoop(void)
 #if !defined(__CYGWIN32__) && !defined(__QNX__)
 		if (ServerSock_UNIX != INVALID_SOCK &&
 			FD_ISSET(ServerSock_UNIX, &rmask) &&
-   		        (port = ConnCreate(ServerSock_UNIX)) != NULL) {
-		        PacketReceiveSetup(&port->pktInfo,
+			(port = ConnCreate(ServerSock_UNIX)) != NULL)
+		{
+			PacketReceiveSetup(&port->pktInfo,
 							   readStartupPacket,
 							   (void *) port);
 		}
 #endif
 
 		if (ServerSock_INET != INVALID_SOCK &&
-		    FD_ISSET(ServerSock_INET, &rmask) &&
-		    (port = ConnCreate(ServerSock_INET)) != NULL) {
+			FD_ISSET(ServerSock_INET, &rmask) &&
+			(port = ConnCreate(ServerSock_INET)) != NULL)
+		{
 			PacketReceiveSetup(&port->pktInfo,
 							   readStartupPacket,
 							   (void *) port);
@@ -921,13 +959,14 @@ ServerLoop(void)
 			Port	   *port = (Port *) DLE_VAL(curr);
 			int			status = STATUS_OK;
 			Dlelem	   *next;
-			int        readyread = 0;
+			int			readyread = 0;
 
 #ifdef USE_SSL
-			if (port->ssl) {
-			  if (SSL_pending(port->ssl) ||
-			      FD_ISSET(port->sock, &rmask))
-			    readyread = 1;
+			if (port->ssl)
+			{
+				if (SSL_pending(port->ssl) ||
+					FD_ISSET(port->sock, &rmask))
+					readyread = 1;
 			}
 			else
 #endif
@@ -966,25 +1005,27 @@ ServerLoop(void)
 
 			if (status == STATUS_OK && port->pktInfo.state == Idle)
 			{
-				/* 
+
+				/*
 				 * Can't start backend if max backend count is exceeded.
-				 * 
+				 *
 				 * The same when shutdowning data base.
 				 */
 				if (Shutdown > NoShutdown)
 					PacketSendError(&port->pktInfo,
-									"The Data Base System is shutting down");
+								"The Data Base System is shutting down");
 				else if (StartupPID)
 					PacketSendError(&port->pktInfo,
-									"The Data Base System is starting up");
+								  "The Data Base System is starting up");
 				else if (FatalError)
 					PacketSendError(&port->pktInfo,
-									"The Data Base System is in recovery mode");
+							 "The Data Base System is in recovery mode");
 				else if (CountChildren() >= MaxBackends)
 					PacketSendError(&port->pktInfo,
 									"Sorry, too many clients already");
 				else
 				{
+
 					/*
 					 * If the backend start fails then keep the connection
 					 * open to report it.  Otherwise, pretend there is an
@@ -1074,7 +1115,7 @@ readStartupPacket(void *arg, PacketLen len, void *pkt)
 
 	port = (Port *) arg;
 	si = (StartupPacket *) pkt;
-	
+
 	/*
 	 * The first field is either a protocol version number or a special
 	 * request code.
@@ -1085,42 +1126,45 @@ readStartupPacket(void *arg, PacketLen len, void *pkt)
 	if (port->proto == CANCEL_REQUEST_CODE)
 		return processCancelRequest(port, len, pkt);
 
-	if (port->proto == NEGOTIATE_SSL_CODE) {
-	  char SSLok;
-	  
+	if (port->proto == NEGOTIATE_SSL_CODE)
+	{
+		char		SSLok;
+
 #ifdef USE_SSL
-	  SSLok = 'S'; /* Support for SSL */
+		SSLok = 'S';			/* Support for SSL */
 #else
-	  SSLok = 'N'; /* No support for SSL */
+		SSLok = 'N';			/* No support for SSL */
 #endif
-	  if (send(port->sock, &SSLok, 1, 0) != 1) {
-	    perror("Failed to send SSL negotiation response");
-	    return STATUS_ERROR; /* Close connection */
-	  }
-	  
+		if (send(port->sock, &SSLok, 1, 0) != 1)
+		{
+			perror("Failed to send SSL negotiation response");
+			return STATUS_ERROR;/* Close connection */
+		}
+
 #ifdef USE_SSL
-	  if (!(port->ssl = SSL_new(SSL_context)) ||
-	      !SSL_set_fd(port->ssl, port->sock) ||
-	      SSL_accept(port->ssl) <= 0)
-	  {
-	    fprintf(stderr,"Failed to initialize SSL connection: %s, errno: %d (%s)\n",
-		    ERR_reason_error_string(ERR_get_error()), errno, strerror(errno));
-	    return STATUS_ERROR;
-	  }
+		if (!(port->ssl = SSL_new(SSL_context)) ||
+			!SSL_set_fd(port->ssl, port->sock) ||
+			SSL_accept(port->ssl) <= 0)
+		{
+			fprintf(stderr, "Failed to initialize SSL connection: %s, errno: %d (%s)\n",
+					ERR_reason_error_string(ERR_get_error()), errno, strerror(errno));
+			return STATUS_ERROR;
+		}
 #endif
-	  /* ready for the normal startup packet */
-	  PacketReceiveSetup(&port->pktInfo,
-			     readStartupPacket,
-			     (void *)port);
-	  return STATUS_OK; /* Do not close connection */
-	} 
+		/* ready for the normal startup packet */
+		PacketReceiveSetup(&port->pktInfo,
+						   readStartupPacket,
+						   (void *) port);
+		return STATUS_OK;		/* Do not close connection */
+	}
 
 	/* Could add additional special packet types here */
 
 #ifdef USE_SSL
-	/* 
-	 * Any SSL negotiation must have taken place here, so drop the connection
-	 * ASAP if we require SSL
+
+	/*
+	 * Any SSL negotiation must have taken place here, so drop the
+	 * connection ASAP if we require SSL
 	 */
 	if (SecureNetServer && !port->ssl)
 	{
@@ -1263,12 +1307,11 @@ ConnCreate(int serverFd)
  * ConnFree -- cree a local connection data structure
  */
 static void
-ConnFree(Port *conn) 
+ConnFree(Port *conn)
 {
 #ifdef USE_SSL
-        if (conn->ssl) {
-	     SSL_free(conn->ssl);
-	}
+	if (conn->ssl)
+		SSL_free(conn->ssl);
 #endif
 	free(conn);
 }
@@ -1293,13 +1336,14 @@ static void
 pmdie(SIGNAL_ARGS)
 {
 	PG_SETMASK(&BlockSig);
-	
+
 	TPRINTF(TRACE_VERBOSE, "pmdie %d", postgres_signal_arg);
 
 	switch (postgres_signal_arg)
 	{
 		case SIGHUP:
-			/* 
+
+			/*
 			 * Send SIGHUP to all children (update options flags)
 			 */
 			if (Shutdown > SmartShutdown)
@@ -1307,8 +1351,9 @@ pmdie(SIGNAL_ARGS)
 			SignalChildren(SIGHUP);
 			return;
 		case SIGUSR2:
-			/* 
-			 * Send SIGUSR2 to all children (AsyncNotifyHandler) 
+
+			/*
+			 * Send SIGUSR2 to all children (AsyncNotifyHandler)
 			 */
 			if (Shutdown > SmartShutdown)
 				return;
@@ -1316,6 +1361,7 @@ pmdie(SIGNAL_ARGS)
 			return;
 
 		case SIGTERM:
+
 			/*
 			 * Smart Shutdown:
 			 *
@@ -1327,12 +1373,14 @@ pmdie(SIGNAL_ARGS)
 			tnow = time(NULL);
 			fprintf(stderr, "Smart Shutdown request at %s", ctime(&tnow));
 			fflush(stderr);
-			if (DLGetHead(BackendList))			/* let reaper() handle this */
+			if (DLGetHead(BackendList)) /* let reaper() handle this */
 				return;
+
 			/*
 			 * No children left. Shutdown data base system.
 			 */
-			if (StartupPID > 0 || FatalError)	/* let reaper() handle this */
+			if (StartupPID > 0 || FatalError)	/* let reaper() handle
+												 * this */
 				return;
 			if (ShutdownPID > 0)
 				abort();
@@ -1341,18 +1389,19 @@ pmdie(SIGNAL_ARGS)
 			return;
 
 		case SIGINT:
+
 			/*
 			 * Fast Shutdown:
-			 * 
-			 * abort all children with SIGTERM (rollback active
-			 * transactions and exit) and ShutdownDataBase.
+			 *
+			 * abort all children with SIGTERM (rollback active transactions
+			 * and exit) and ShutdownDataBase.
 			 */
 			if (Shutdown >= FastShutdown)
 				return;
 			tnow = time(NULL);
 			fprintf(stderr, "Fast Shutdown request at %s", ctime(&tnow));
 			fflush(stderr);
-			if (DLGetHead(BackendList))			/* let reaper() handle this */
+			if (DLGetHead(BackendList)) /* let reaper() handle this */
 			{
 				Shutdown = FastShutdown;
 				if (!FatalError)
@@ -1369,10 +1418,12 @@ pmdie(SIGNAL_ARGS)
 				return;
 			}
 			Shutdown = FastShutdown;
+
 			/*
 			 * No children left. Shutdown data base system.
 			 */
-			if (StartupPID > 0 || FatalError)	/* let reaper() handle this */
+			if (StartupPID > 0 || FatalError)	/* let reaper() handle
+												 * this */
 				return;
 			if (ShutdownPID > 0)
 				abort();
@@ -1381,11 +1432,12 @@ pmdie(SIGNAL_ARGS)
 			return;
 
 		case SIGQUIT:
-			/* 
+
+			/*
 			 * Immediate Shutdown:
-			 * 
-			 * abort all children with SIGUSR1 and exit without
-			 * attempt to properly shutdown data base system.
+			 *
+			 * abort all children with SIGUSR1 and exit without attempt to
+			 * properly shutdown data base system.
 			 */
 			tnow = time(NULL);
 			fprintf(stderr, "Immediate Shutdown request at %s", ctime(&tnow));
@@ -1412,8 +1464,10 @@ reaper(SIGNAL_ARGS)
 /* GH: replace waitpid for !HAVE_WAITPID. Does this work ? */
 #ifdef HAVE_WAITPID
 	int			status;			/* backend exit status */
+
 #else
 	union wait	status;			/* backend exit status */
+
 #endif
 	int			exitstatus;
 	int			pid;			/* process id of dead backend */
@@ -1471,6 +1525,7 @@ reaper(SIGNAL_ARGS)
 
 	if (FatalError)
 	{
+
 		/*
 		 * Wait for all children exit then StartupDataBase.
 		 */
@@ -1480,8 +1535,8 @@ reaper(SIGNAL_ARGS)
 			return;
 		tnow = time(NULL);
 		fprintf(stderr, "Server processes were terminated at %s"
-						"Reinitializing shared memory and semaphores\n",
-						ctime(&tnow));
+				"Reinitializing shared memory and semaphores\n",
+				ctime(&tnow));
 		fflush(stderr);
 		shmem_exit(0);
 		reset_shared(PostPortName);
@@ -1553,8 +1608,8 @@ CleanupProc(int pid,
 	{
 		tnow = time(NULL);
 		fprintf(stderr, "Server process (pid %d) exited with status %d at %s"
-						"Terminating any active server processes...\n",
-						pid, exitstatus, ctime(&tnow));
+				"Terminating any active server processes...\n",
+				pid, exitstatus, ctime(&tnow));
 		fflush(stderr);
 	}
 	FatalError = true;
@@ -1565,11 +1620,11 @@ CleanupProc(int pid,
 		bp = (Backend *) DLE_VAL(curr);
 
 		/*
-		 * SIGUSR1 is the special signal that says exit
-		 * without proc_exit and let the user know what's going on.
-		 * ProcSemaphoreKill() cleans up the backends semaphore.  If
-		 * SendStop is set (-s on command line), then we send a SIGSTOP so
-		 * that we can core dumps from all backends by hand.
+		 * SIGUSR1 is the special signal that says exit without proc_exit
+		 * and let the user know what's going on. ProcSemaphoreKill()
+		 * cleans up the backends semaphore.  If SendStop is set (-s on
+		 * command line), then we send a SIGSTOP so that we can core dumps
+		 * from all backends by hand.
 		 */
 		sig = (SendStop) ? SIGSTOP : SIGUSR1;
 		if (bp->pid != pid)
@@ -1584,13 +1639,14 @@ CleanupProc(int pid,
 		}
 		else
 		{
+
 			/*
-			 * I don't like that we call ProcRemove() here, assuming that 
-			 * shmem may be corrupted! But is there another way to free 
-			 * backend semaphores? Actually, I believe that we need not
-			 * in per backend semaphore at all (we use them to wait on lock
-			 * only, couldn't we just sigpause?), so probably we'll
-			 * remove this call from here someday.	-- vadim 04-10-1999
+			 * I don't like that we call ProcRemove() here, assuming that
+			 * shmem may be corrupted! But is there another way to free
+			 * backend semaphores? Actually, I believe that we need not in
+			 * per backend semaphore at all (we use them to wait on lock
+			 * only, couldn't we just sigpause?), so probably we'll remove
+			 * this call from here someday.  -- vadim 04-10-1999
 			 */
 			ProcRemove(pid);
 
@@ -1827,14 +1883,14 @@ DoBackend(Port *port)
 	 */
 
 	/* We don't want the postmaster's proc_exit() handlers */
-	on_exit_reset();	
+	on_exit_reset();
 
-	/* 
+	/*
 	 * Signal handlers setting is moved to tcop/postgres...
 	 */
 
 	/* Close the postmaster sockets */
-	if (NetServer) 
+	if (NetServer)
 		StreamClose(ServerSock_INET);
 #if !defined(__CYGWIN32__) && !defined(__QNX__)
 	StreamClose(ServerSock_UNIX);
@@ -1885,11 +1941,11 @@ DoBackend(Port *port)
 #endif
 
 	/*
-	 * Pass the requested debugging level along to the backend.
-	 * Level one debugging in the postmaster traces
-	 * postmaster connection activity, and levels two and higher are
-	 * passed along to the backend.  This allows us to watch only the
-	 * postmaster or the postmaster and the backend.
+	 * Pass the requested debugging level along to the backend. Level one
+	 * debugging in the postmaster traces postmaster connection activity,
+	 * and levels two and higher are passed along to the backend.  This
+	 * allows us to watch only the postmaster or the postmaster and the
+	 * backend.
 	 */
 	if (DebugLvl > 1)
 	{
@@ -2071,31 +2127,38 @@ CountChildren(void)
 /*
  * Initialize SSL library and structures
  */
-static void InitSSL(void) {
-  char fnbuf[2048];
-  
-  SSL_load_error_strings();
-  SSL_library_init();
-  SSL_context = SSL_CTX_new(SSLv23_method());
-  if (!SSL_context) {
-    fprintf(stderr, "Failed to create SSL context: %s\n",ERR_reason_error_string(ERR_get_error()));
-    exit(1);
-  }
-  snprintf(fnbuf,sizeof(fnbuf),"%s/server.crt", DataDir);
-  if (!SSL_CTX_use_certificate_file(SSL_context, fnbuf, SSL_FILETYPE_PEM)) {
-    fprintf(stderr, "Failed to load server certificate (%s): %s\n",fnbuf,ERR_reason_error_string(ERR_get_error()));
-    exit(1);
-  }
-  snprintf(fnbuf,sizeof(fnbuf),"%s/server.key", DataDir);
-  if (!SSL_CTX_use_PrivateKey_file(SSL_context, fnbuf, SSL_FILETYPE_PEM)) {
-    fprintf(stderr, "Failed to load private key file (%s): %s\n",fnbuf,ERR_reason_error_string(ERR_get_error()));
-    exit(1);
-  }
-  if (!SSL_CTX_check_private_key(SSL_context)) {
-    fprintf(stderr, "Check of private key failed: %s\n",ERR_reason_error_string(ERR_get_error()));
-    exit(1);
-  }
+static void
+InitSSL(void)
+{
+	char		fnbuf[2048];
+
+	SSL_load_error_strings();
+	SSL_library_init();
+	SSL_context = SSL_CTX_new(SSLv23_method());
+	if (!SSL_context)
+	{
+		fprintf(stderr, "Failed to create SSL context: %s\n", ERR_reason_error_string(ERR_get_error()));
+		exit(1);
+	}
+	snprintf(fnbuf, sizeof(fnbuf), "%s/server.crt", DataDir);
+	if (!SSL_CTX_use_certificate_file(SSL_context, fnbuf, SSL_FILETYPE_PEM))
+	{
+		fprintf(stderr, "Failed to load server certificate (%s): %s\n", fnbuf, ERR_reason_error_string(ERR_get_error()));
+		exit(1);
+	}
+	snprintf(fnbuf, sizeof(fnbuf), "%s/server.key", DataDir);
+	if (!SSL_CTX_use_PrivateKey_file(SSL_context, fnbuf, SSL_FILETYPE_PEM))
+	{
+		fprintf(stderr, "Failed to load private key file (%s): %s\n", fnbuf, ERR_reason_error_string(ERR_get_error()));
+		exit(1);
+	}
+	if (!SSL_CTX_check_private_key(SSL_context))
+	{
+		fprintf(stderr, "Check of private key failed: %s\n", ERR_reason_error_string(ERR_get_error()));
+		exit(1);
+	}
 }
+
 #endif
 
 static pid_t
@@ -2103,7 +2166,7 @@ SSDataBase(bool startup)
 {
 	pid_t		pid;
 	int			i;
-	static char	ssEntry[4][2 * ARGV_SIZE];
+	static char ssEntry[4][2 * ARGV_SIZE];
 
 	for (i = 0; i < 4; ++i)
 		MemSet(ssEntry[i], 0, 2 * ARGV_SIZE);
@@ -2131,8 +2194,8 @@ SSDataBase(bool startup)
 		char		nbbuf[ARGV_SIZE];
 		char		dbbuf[ARGV_SIZE];
 
-		on_exit_reset();	
-		if (NetServer) 
+		on_exit_reset();
+		if (NetServer)
 			StreamClose(ServerSock_INET);
 #if !defined(__CYGWIN32__) && !defined(__QNX__)
 		StreamClose(ServerSock_UNIX);
@@ -2165,7 +2228,7 @@ SSDataBase(bool startup)
 		BlockSig &= ~(sigmask(SIGQUIT));
 #endif
 		PG_SETMASK(&BlockSig);
-	
+
 		BootstrapMain(ac, av);
 		exit(0);
 	}
@@ -2174,92 +2237,93 @@ SSDataBase(bool startup)
 	if (pid < 0)
 	{
 		fprintf(stderr, "%s Data Base: fork failed: %s\n",
-			((startup) ? "Startup" : "Shutdown"), strerror(errno));
+				((startup) ? "Startup" : "Shutdown"), strerror(errno));
 		ExitPostmaster(1);
 	}
 
 	NextBackendTag -= 1;
 
-	return(pid);
+	return (pid);
 }
 
 /*
  * Create the opts file
  */
-static int SetOptsFile(char *progname, int port, char *datadir,
-		      int assert, int nbuf, char *execfile,
-		      int debuglvl, int netserver,
+static int
+SetOptsFile(char *progname, int port, char *datadir,
+			int assert, int nbuf, char *execfile,
+			int debuglvl, int netserver,
 #ifdef USE_SSL
-		      int securenetserver,
+			int securenetserver,
 #endif
-		      int maxbackends, int reinit,
-		      int silent, int sendstop, char *extraoptions)
+			int maxbackends, int reinit,
+			int silent, int sendstop, char *extraoptions)
 {
-	int fd;
-	char optsfile[MAXPGPATH];
-	char opts[1024];
-	char buf[1024];
+	int			fd;
+	char		optsfile[MAXPGPATH];
+	char		opts[1024];
+	char		buf[1024];
 
 	/*
 	 * Creating opts file
 	 */
 	snprintf(optsfile, sizeof(optsfile), "%s/%s", datadir, OPTSFNAME);
 	fd = open(optsfile, O_RDWR | O_TRUNC | O_CREAT, 0600);
-	if (fd < 0) {
+	if (fd < 0)
+	{
 		fprintf(stderr, "Can't create optsfile:%s", optsfile);
-		return(-1);
+		return (-1);
 	}
-	snprintf(opts, sizeof(opts), "%s\n-p %d\n-D %s\n",progname, port, datadir);
-	if (assert) {
+	snprintf(opts, sizeof(opts), "%s\n-p %d\n-D %s\n", progname, port, datadir);
+	if (assert)
+	{
 		sprintf(buf, "-A %d\n", assert);
 		strcat(opts, buf);
 	}
 
-        snprintf(buf, sizeof(buf), "-B %d\n-b %s\n",nbuf, execfile);
+	snprintf(buf, sizeof(buf), "-B %d\n-b %s\n", nbuf, execfile);
 	strcat(opts, buf);
 
-	if (debuglvl) {
+	if (debuglvl)
+	{
 		sprintf(buf, "-d %d\n", debuglvl);
 		strcat(opts, buf);
 	}
 
-	if (netserver) {
+	if (netserver)
 		strcat(opts, "-i\n");
-	}
 
 #ifdef USE_SSL
-	if (securenetserver) {
+	if (securenetserver)
 		strcat(opts, "-l\n");
-	}
 #endif
 
 	snprintf(buf, sizeof(buf), "-N %d\n", maxbackends);
 	strcat(opts, buf);
 
-	if (!reinit) {
+	if (!reinit)
 		strcat(opts, "-n\n");
-	}
 
-	if (silent) {
+	if (silent)
 		strcat(opts, "-S\n");
-	}
 
-	if (sendstop) {
+	if (sendstop)
 		strcat(opts, "-s\n");
-	}
 
-	if (strlen(extraoptions) > 0) {
+	if (strlen(extraoptions) > 0)
+	{
 		strcat(opts, "-o '");
 		strcat(opts, extraoptions);
 		strcat(opts, "'");
 	}
 
-	if (write(fd, opts, strlen(opts)) != strlen(opts)) {
+	if (write(fd, opts, strlen(opts)) != strlen(opts))
+	{
 		perror("Writing to opts file failed");
 		close(fd);
-		return(-1);
+		return (-1);
 	}
 	close(fd);
 
-	return(0);
+	return (0);
 }
diff --git a/src/backend/rewrite/locks.c b/src/backend/rewrite/locks.c
index fbdcc2c4f64f2da230d1fdd45d3bce475b74457a..cd3fa69cd8dd3e5eb69c24b5c1c691da60976896 100644
--- a/src/backend/rewrite/locks.c
+++ b/src/backend/rewrite/locks.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/rewrite/Attic/locks.c,v 1.27 2000/01/26 05:56:49 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/rewrite/Attic/locks.c,v 1.28 2000/04/12 17:15:32 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -34,15 +34,16 @@
  * XXX this should be unified with attribute_used()
  */
 
-typedef struct {
+typedef struct
+{
 	int			varno;
 	int			attnum;
 	int			sublevels_up;
 } thisLockWasTriggered_context;
 
 static bool
-thisLockWasTriggered_walker (Node *node,
-							 thisLockWasTriggered_context *context)
+thisLockWasTriggered_walker(Node *node,
+							thisLockWasTriggered_context *context)
 {
 	if (node == NULL)
 		return false;
@@ -58,9 +59,10 @@ thisLockWasTriggered_walker (Node *node,
 	}
 	if (IsA(node, SubLink))
 	{
+
 		/*
-		 * Standard expression_tree_walker will not recurse into subselect,
-		 * but here we must do so.
+		 * Standard expression_tree_walker will not recurse into
+		 * subselect, but here we must do so.
 		 */
 		SubLink    *sub = (SubLink *) node;
 
@@ -69,7 +71,7 @@ thisLockWasTriggered_walker (Node *node,
 		context->sublevels_up++;
 		if (thisLockWasTriggered_walker((Node *) (sub->subselect), context))
 		{
-			context->sublevels_up--; /* not really necessary */
+			context->sublevels_up--;	/* not really necessary */
 			return true;
 		}
 		context->sublevels_up--;
diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c
index b8aea0400b9576ebf4fe43f5f70b76195c7b096d..69b7800cccc57e4c09dfa890995265be32c85554 100644
--- a/src/backend/rewrite/rewriteDefine.c
+++ b/src/backend/rewrite/rewriteDefine.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.43 2000/02/26 06:36:44 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.44 2000/04/12 17:15:32 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -40,7 +40,8 @@ quoteString(StringInfo buf, char *source)
 	appendStringInfoChar(buf, '\'');
 	for (current = source; *current; current++)
 	{
-		char	ch = *current;
+		char		ch = *current;
+
 		if (ch == '\'' || ch == '\\')
 		{
 			appendStringInfoChar(buf, '\\');
@@ -297,7 +298,7 @@ DefineQueryRewrite(RuleStmt *stmt)
 				rule = event_relation->rd_rules->rules[i];
 				if (rule->event == CMD_SELECT)
 					elog(ERROR, "%s is already a view",
-						RelationGetRelationName(event_relation));
+						 RelationGetRelationName(event_relation));
 			}
 		}
 
diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c
index 7e76498f86a3f29d48c380707d80f4ae893971b0..714f08c26299ff040c4a8cc9361fb906cf66ec66 100644
--- a/src/backend/rewrite/rewriteHandler.c
+++ b/src/backend/rewrite/rewriteHandler.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.70 2000/04/04 02:30:52 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.71 2000/04/12 17:15:32 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -55,19 +55,19 @@ static RewriteInfo *gatherRewriteMeta(Query *parsetree,
 				  bool *instead_flag);
 static bool rangeTableEntry_used(Node *node, int rt_index, int sublevels_up);
 static bool attribute_used(Node *node, int rt_index, int attno,
-						   int sublevels_up);
+			   int sublevels_up);
 static bool modifyAggrefChangeVarnodes(Node *node, int rt_index, int new_index,
-									   int sublevels_up, int new_sublevels_up);
+						   int sublevels_up, int new_sublevels_up);
 static Node *modifyAggrefDropQual(Node *node, Node *targetNode);
 static SubLink *modifyAggrefMakeSublink(Aggref *aggref, Query *parsetree);
 static Node *modifyAggrefQual(Node *node, Query *parsetree);
 static Query *fireRIRrules(Query *parsetree);
 static Query *Except_Intersect_Rewrite(Query *parsetree);
 static void check_targetlists_are_compatible(List *prev_target,
-											 List *current_target);
+								 List *current_target);
 static void create_intersect_list(Node *ptr, List **intersect_list);
 static Node *intersect_tree_analyze(Node *tree, Node *first_select,
-									Node *parsetree);
+					   Node *parsetree);
 
 /*
  * gatherRewriteMeta -
@@ -148,14 +148,15 @@ gatherRewriteMeta(Query *parsetree,
  *	referenced somewhere in var nodes of the query.
  */
 
-typedef struct {
+typedef struct
+{
 	int			rt_index;
 	int			sublevels_up;
 } rangeTableEntry_used_context;
 
 static bool
-rangeTableEntry_used_walker (Node *node,
-							 rangeTableEntry_used_context *context)
+rangeTableEntry_used_walker(Node *node,
+							rangeTableEntry_used_context *context)
 {
 	if (node == NULL)
 		return false;
@@ -170,9 +171,10 @@ rangeTableEntry_used_walker (Node *node,
 	}
 	if (IsA(node, SubLink))
 	{
+
 		/*
-		 * Standard expression_tree_walker will not recurse into subselect,
-		 * but here we must do so.
+		 * Standard expression_tree_walker will not recurse into
+		 * subselect, but here we must do so.
 		 */
 		SubLink    *sub = (SubLink *) node;
 
@@ -218,15 +220,16 @@ rangeTableEntry_used(Node *node, int rt_index, int sublevels_up)
  *	somewhere in the query
  */
 
-typedef struct {
+typedef struct
+{
 	int			rt_index;
 	int			attno;
 	int			sublevels_up;
 } attribute_used_context;
 
 static bool
-attribute_used_walker (Node *node,
-					   attribute_used_context *context)
+attribute_used_walker(Node *node,
+					  attribute_used_context *context)
 {
 	if (node == NULL)
 		return false;
@@ -242,9 +245,10 @@ attribute_used_walker (Node *node,
 	}
 	if (IsA(node, SubLink))
 	{
+
 		/*
-		 * Standard expression_tree_walker will not recurse into subselect,
-		 * but here we must do so.
+		 * Standard expression_tree_walker will not recurse into
+		 * subselect, but here we must do so.
 		 */
 		SubLink    *sub = (SubLink *) node;
 
@@ -296,11 +300,12 @@ attribute_used(Node *node, int rt_index, int attno, int sublevels_up)
  * not having the option to adjust the vars' varlevelsup.
  *
  * NOTE: although this has the form of a walker, we cheat and modify the
- * Var nodes in-place.  The given expression tree should have been copied
+ * Var nodes in-place.	The given expression tree should have been copied
  * earlier to ensure that no unwanted side-effects occur!
  */
 
-typedef struct {
+typedef struct
+{
 	int			rt_index;
 	int			new_index;
 	int			sublevels_up;
@@ -309,7 +314,7 @@ typedef struct {
 
 static bool
 modifyAggrefChangeVarnodes_walker(Node *node,
-								  modifyAggrefChangeVarnodes_context *context)
+							 modifyAggrefChangeVarnodes_context *context)
 {
 	if (node == NULL)
 		return false;
@@ -328,9 +333,10 @@ modifyAggrefChangeVarnodes_walker(Node *node,
 	}
 	if (IsA(node, SubLink))
 	{
+
 		/*
-		 * Standard expression_tree_walker will not recurse into subselect,
-		 * but here we must do so.
+		 * Standard expression_tree_walker will not recurse into
+		 * subselect, but here we must do so.
 		 */
 		SubLink    *sub = (SubLink *) node;
 
@@ -386,7 +392,7 @@ modifyAggrefChangeVarnodes(Node *node, int rt_index, int new_index,
  * targetNode is an Aggref node somewhere within the given expression tree.
  * Find the boolean operator that's presumably somewhere above it, and replace
  * that whole operator expression with a constant TRUE.  (This is NOT really
- * quite the right thing, but it handles simple cases.  This whole set of
+ * quite the right thing, but it handles simple cases.	This whole set of
  * Aggref-in-qual routines needs to be thrown away when we can do subselects
  * in FROM.)
  *
@@ -439,8 +445,10 @@ static SubLink *
 modifyAggrefMakeSublink(Aggref *aggref, Query *parsetree)
 {
 	List	   *aggVarNos;
+
 	/* rte points to old structure: */
 	RangeTblEntry *rte;
+
 	/* these point to newly-created structures: */
 	Query	   *subquery;
 	SubLink    *sublink;
@@ -463,7 +471,7 @@ modifyAggrefMakeSublink(Aggref *aggref, Query *parsetree)
 
 	tle = makeNode(TargetEntry);
 	tle->resdom = resdom;
-	tle->expr = copyObject(aggref);	/* make a modifiable copy! */
+	tle->expr = copyObject(aggref);		/* make a modifiable copy! */
 
 	subquery = makeNode(Query);
 
@@ -488,10 +496,11 @@ modifyAggrefMakeSublink(Aggref *aggref, Query *parsetree)
 	subquery->targetList = lcons(tle, NIL);
 	subquery->qual = modifyAggrefDropQual((Node *) parsetree->qual,
 										  (Node *) aggref);
+
 	/*
-	 * If there are still aggs in the subselect's qual, give up.
-	 * Recursing would be a bad idea --- we'd likely produce an
-	 * infinite recursion.  This whole technique is a crock, really...
+	 * If there are still aggs in the subselect's qual, give up. Recursing
+	 * would be a bad idea --- we'd likely produce an infinite recursion.
+	 * This whole technique is a crock, really...
 	 */
 	if (checkExprHasAggs(subquery->qual))
 		elog(ERROR, "Cannot handle multiple aggregate functions in WHERE clause");
@@ -504,7 +513,8 @@ modifyAggrefMakeSublink(Aggref *aggref, Query *parsetree)
 	/* Increment all varlevelsup fields in the new subquery */
 	IncrementVarSublevelsUp((Node *) subquery, 1, 0);
 
-	/* Replace references to the target table with correct local varno, 1.
+	/*
+	 * Replace references to the target table with correct local varno, 1.
 	 * Note that because of previous line, these references have
 	 * varlevelsup = 1, which must be changed to 0.
 	 */
@@ -537,11 +547,12 @@ modifyAggrefQual(Node *node, Query *parsetree)
 		parsetree->hasSubLinks = true;
 		return (Node *) sub;
 	}
+
 	/*
 	 * Otherwise, fall through and copy the expr normally.
 	 *
-	 * We do NOT recurse into subselects in this routine.  It's sufficient
-	 * to get rid of aggregates that are in the qual expression proper.
+	 * We do NOT recurse into subselects in this routine.  It's sufficient to
+	 * get rid of aggregates that are in the qual expression proper.
 	 */
 	return expression_tree_mutator(node, modifyAggrefQual,
 								   (void *) parsetree);
@@ -585,12 +596,13 @@ make_null(Oid type)
  *	Replace Vars matching a given RT index with copies of TL expressions.
  */
 
-typedef struct {
-	int				rt_index;
-	int				sublevels_up;
-	RangeTblEntry  *rte;
-	List		   *tlist;
-	int			   *modified;
+typedef struct
+{
+	int			rt_index;
+	int			sublevels_up;
+	RangeTblEntry *rte;
+	List	   *tlist;
+	int		   *modified;
 } apply_RIR_view_context;
 
 static Node *
@@ -633,14 +645,15 @@ apply_RIR_view_mutator(Node *node,
 		}
 		/* otherwise fall through to copy the var normally */
 	}
+
 	/*
 	 * Since expression_tree_mutator won't touch subselects, we have to
 	 * handle them specially.
 	 */
 	if (IsA(node, SubLink))
 	{
-		SubLink   *sublink = (SubLink *) node;
-		SubLink   *newnode;
+		SubLink    *sublink = (SubLink *) node;
+		SubLink    *newnode;
 
 		FLATCOPY(newnode, sublink, SubLink);
 		MUTATE(newnode->lefthand, sublink->lefthand, List *,
@@ -653,8 +666,8 @@ apply_RIR_view_mutator(Node *node,
 	}
 	if (IsA(node, Query))
 	{
-		Query  *query = (Query *) node;
-		Query  *newnode;
+		Query	   *query = (Query *) node;
+		Query	   *newnode;
 
 		FLATCOPY(newnode, query, Query);
 		MUTATE(newnode->targetList, query->targetList, List *,
@@ -673,7 +686,7 @@ static Node *
 apply_RIR_view(Node *node, int rt_index, RangeTblEntry *rte, List *tlist,
 			   int *modified, int sublevels_up)
 {
-	apply_RIR_view_context	context;
+	apply_RIR_view_context context;
 
 	context.rt_index = rt_index;
 	context.sublevels_up = sublevels_up;
@@ -718,18 +731,20 @@ ApplyRetrieveRule(Query *parsetree,
 		nothing = TRUE;
 
 	rtable = copyObject(parsetree->rtable);
-	rt_length = length(rtable);	/* original length, not counting rule */
+	rt_length = length(rtable); /* original length, not counting rule */
 
 	addedrtable = copyObject(rule_action->rtable);
 
-	/* If the original rel wasn't in the join set, none of its spawn is.
+	/*
+	 * If the original rel wasn't in the join set, none of its spawn is.
 	 * If it was, then leave the spawn's flags as they are.
 	 */
-	if (! relWasInJoinSet)
+	if (!relWasInJoinSet)
 	{
 		foreach(l, addedrtable)
 		{
 			RangeTblEntry *rte = lfirst(l);
+
 			rte->inJoinSet = false;
 		}
 	}
@@ -789,7 +804,7 @@ ApplyRetrieveRule(Query *parsetree,
 
 	if (relation_level)
 	{
-		RangeTblEntry  *rte = rt_fetch(rt_index, rtable);
+		RangeTblEntry *rte = rt_fetch(rt_index, rtable);
 
 		parsetree = (Query *) apply_RIR_view((Node *) parsetree,
 											 rt_index, rte,
@@ -824,7 +839,7 @@ ApplyRetrieveRule(Query *parsetree,
  *	Apply fireRIRrules() to each subselect found in the given tree.
  *
  * NOTE: although this has the form of a walker, we cheat and modify the
- * SubLink nodes in-place.  It is caller's responsibility to ensure that
+ * SubLink nodes in-place.	It is caller's responsibility to ensure that
  * no unwanted side-effects occur!
  */
 static bool
@@ -883,8 +898,9 @@ fireRIRrules(Query *parsetree)
 	int			i;
 	List	   *l;
 
-	/* don't try to convert this into a foreach loop, because
-	 * rtable list can get changed each time through...
+	/*
+	 * don't try to convert this into a foreach loop, because rtable list
+	 * can get changed each time through...
 	 */
 	rt_index = 0;
 	while (rt_index < length(parsetree->rtable))
@@ -894,13 +910,13 @@ fireRIRrules(Query *parsetree)
 		rte = rt_fetch(rt_index, parsetree->rtable);
 
 		/*
-		 * If the table is not one named in the original FROM clause
-		 * then it must be referenced in the query, or we ignore it.
-		 * This prevents infinite expansion loop due to new rtable
-		 * entries inserted by expansion of a rule.
+		 * If the table is not one named in the original FROM clause then
+		 * it must be referenced in the query, or we ignore it. This
+		 * prevents infinite expansion loop due to new rtable entries
+		 * inserted by expansion of a rule.
 		 */
-		if (! rte->inFromCl && rt_index != parsetree->resultRelation &&
-			! rangeTableEntry_used((Node *) parsetree, rt_index, 0))
+		if (!rte->inFromCl && rt_index != parsetree->resultRelation &&
+			!rangeTableEntry_used((Node *) parsetree, rt_index, 0))
 		{
 			/* Make sure the planner ignores it too... */
 			rte->inJoinSet = false;
@@ -915,7 +931,8 @@ fireRIRrules(Query *parsetree)
 			continue;
 		}
 
-		relWasInJoinSet = rte->inJoinSet; /* save before possibly clearing */
+		relWasInJoinSet = rte->inJoinSet;		/* save before possibly
+												 * clearing */
 
 		/*
 		 * Collect the RIR rules that we must apply
@@ -930,16 +947,18 @@ fireRIRrules(Query *parsetree)
 			if (rule->attrno > 0)
 			{
 				/* per-attr rule; do we need it? */
-				if (! attribute_used((Node *) parsetree,
-									 rt_index,
-									 rule->attrno, 0))
+				if (!attribute_used((Node *) parsetree,
+									rt_index,
+									rule->attrno, 0))
 					continue;
 			}
 			else
 			{
-				/* Rel-wide ON SELECT DO INSTEAD means this is a view.
-				 * Remove the view from the planner's join target set,
-				 * or we'll get no rows out because view itself is empty!
+
+				/*
+				 * Rel-wide ON SELECT DO INSTEAD means this is a view.
+				 * Remove the view from the planner's join target set, or
+				 * we'll get no rows out because view itself is empty!
 				 */
 				if (rule->isInstead)
 					rte->inJoinSet = false;
@@ -1448,7 +1467,7 @@ BasicQueryRewrite(Query *parsetree)
 
 		/*
 		 * If the query was marked having aggregates, check if this is
-		 * still true after rewriting.  Ditto for sublinks.  Note there
+		 * still true after rewriting.	Ditto for sublinks.  Note there
 		 * should be no aggs in the qual at this point.
 		 */
 		if (query->hasAggs)
@@ -1663,6 +1682,7 @@ Except_Intersect_Rewrite(Query *parsetree)
 	 */
 	if (parsetree->commandType == CMD_INSERT)
 	{
+
 		/*
 		 * The result relation ( = the one to insert into) has to be
 		 * attached to the rtable list of the new top node
@@ -1825,7 +1845,8 @@ Except_Intersect_Rewrite(Query *parsetree)
 
 			/*
 			 * Also prepare the list of Opers that must be used for the
-			 * comparisons (they depend on the specific datatypes involved!)
+			 * comparisons (they depend on the specific datatypes
+			 * involved!)
 			 */
 			left_expr = n->lefthand;
 			right_expr = ((Query *) (n->subselect))->targetList;
@@ -1848,8 +1869,8 @@ Except_Intersect_Rewrite(Query *parsetree)
 				if (opform->oprresult != BOOLOID)
 					elog(ERROR, "parser: '%s' must return 'bool' to be used with quantified predicate subquery", op);
 
-				newop = makeOper(oprid(optup),/* opno */
-								 InvalidOid, /* opid */
+				newop = makeOper(oprid(optup),	/* opno */
+								 InvalidOid,	/* opid */
 								 opform->oprresult,
 								 0,
 								 NULL);
diff --git a/src/backend/rewrite/rewriteManip.c b/src/backend/rewrite/rewriteManip.c
index e8224d80b3a507928dc8f4aeeda525ba2a3dc2a6..a4935b78c4886ae9df50d31a2586207bee1c87d4 100644
--- a/src/backend/rewrite/rewriteManip.c
+++ b/src/backend/rewrite/rewriteManip.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.45 2000/03/16 03:23:18 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.46 2000/04/12 17:15:32 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -52,7 +52,8 @@ checkExprHasAggs_walker(Node *node, void *context)
 	if (node == NULL)
 		return false;
 	if (IsA(node, Aggref))
-		return true;			/* abort the tree traversal and return true */
+		return true;			/* abort the tree traversal and return
+								 * true */
 	return expression_tree_walker(node, checkExprHasAggs_walker, context);
 }
 
@@ -73,7 +74,8 @@ checkExprHasSubLink_walker(Node *node, void *context)
 	if (node == NULL)
 		return false;
 	if (IsA(node, SubLink))
-		return true;			/* abort the tree traversal and return true */
+		return true;			/* abort the tree traversal and return
+								 * true */
 	return expression_tree_walker(node, checkExprHasSubLink_walker, context);
 }
 
@@ -86,11 +88,12 @@ checkExprHasSubLink_walker(Node *node, void *context)
  * The varnoold fields are adjusted similarly.
  *
  * NOTE: although this has the form of a walker, we cheat and modify the
- * Var nodes in-place.  The given expression tree should have been copied
+ * Var nodes in-place.	The given expression tree should have been copied
  * earlier to ensure that no unwanted side-effects occur!
  */
 
-typedef struct {
+typedef struct
+{
 	int			offset;
 	int			sublevels_up;
 } OffsetVarNodes_context;
@@ -113,9 +116,10 @@ OffsetVarNodes_walker(Node *node, OffsetVarNodes_context *context)
 	}
 	if (IsA(node, SubLink))
 	{
+
 		/*
-		 * Standard expression_tree_walker will not recurse into subselect,
-		 * but here we must do so.
+		 * Standard expression_tree_walker will not recurse into
+		 * subselect, but here we must do so.
 		 */
 		SubLink    *sub = (SubLink *) node;
 
@@ -162,14 +166,15 @@ OffsetVarNodes(Node *node, int offset, int sublevels_up)
  *
  * Find all Var nodes in the given tree belonging to a specific relation
  * (identified by sublevels_up and rt_index), and change their varno fields
- * to 'new_index'.  The varnoold fields are changed too.
+ * to 'new_index'.	The varnoold fields are changed too.
  *
  * NOTE: although this has the form of a walker, we cheat and modify the
- * Var nodes in-place.  The given expression tree should have been copied
+ * Var nodes in-place.	The given expression tree should have been copied
  * earlier to ensure that no unwanted side-effects occur!
  */
 
-typedef struct {
+typedef struct
+{
 	int			rt_index;
 	int			new_index;
 	int			sublevels_up;
@@ -194,9 +199,10 @@ ChangeVarNodes_walker(Node *node, ChangeVarNodes_context *context)
 	}
 	if (IsA(node, SubLink))
 	{
+
 		/*
-		 * Standard expression_tree_walker will not recurse into subselect,
-		 * but here we must do so.
+		 * Standard expression_tree_walker will not recurse into
+		 * subselect, but here we must do so.
 		 */
 		SubLink    *sub = (SubLink *) node;
 
@@ -253,11 +259,12 @@ ChangeVarNodes(Node *node, int rt_index, int new_index, int sublevels_up)
  * to the expression's original query level or parents thereof.
  *
  * NOTE: although this has the form of a walker, we cheat and modify the
- * Var nodes in-place.  The given expression tree should have been copied
+ * Var nodes in-place.	The given expression tree should have been copied
  * earlier to ensure that no unwanted side-effects occur!
  */
 
-typedef struct {
+typedef struct
+{
 	int			delta_sublevels_up;
 	int			min_sublevels_up;
 } IncrementVarSublevelsUp_context;
@@ -278,9 +285,10 @@ IncrementVarSublevelsUp_walker(Node *node,
 	}
 	if (IsA(node, SubLink))
 	{
+
 		/*
-		 * Standard expression_tree_walker will not recurse into subselect,
-		 * but here we must do so.
+		 * Standard expression_tree_walker will not recurse into
+		 * subselect, but here we must do so.
 		 */
 		SubLink    *sub = (SubLink *) node;
 
@@ -346,7 +354,8 @@ AddQual(Query *parsetree, Node *qual)
 
 	/*
 	 * Make sure query is marked correctly if added qual has sublinks or
-	 * aggregates (not sure it can ever have aggs, but sublinks definitely).
+	 * aggregates (not sure it can ever have aggs, but sublinks
+	 * definitely).
 	 */
 	parsetree->hasAggs |= checkExprHasAggs(copy);
 	parsetree->hasSubLinks |= checkExprHasSubLink(copy);
@@ -376,7 +385,8 @@ AddHavingQual(Query *parsetree, Node *havingQual)
 
 	/*
 	 * Make sure query is marked correctly if added qual has sublinks or
-	 * aggregates (not sure it can ever have aggs, but sublinks definitely).
+	 * aggregates (not sure it can ever have aggs, but sublinks
+	 * definitely).
 	 */
 	parsetree->hasAggs |= checkExprHasAggs(copy);
 	parsetree->hasSubLinks |= checkExprHasSubLink(copy);
@@ -396,6 +406,7 @@ AddNotHavingQual(Query *parsetree, Node *havingQual)
 
 	AddHavingQual(parsetree, notqual);
 }
+
 #endif
 
 void
@@ -435,7 +446,8 @@ AddGroupClause(Query *parsetree, List *group_by, List *tlist)
 		/* copy the groupclause's TLE from the old tlist */
 		tle = (TargetEntry *) copyObject(tle);
 
-		/* The ressortgroupref number in the old tlist might be already
+		/*
+		 * The ressortgroupref number in the old tlist might be already
 		 * taken in the new tlist, so force assignment of a new number.
 		 */
 		tle->resdom->ressortgroupref = 0;
@@ -528,10 +540,11 @@ FindMatchingTLEntry(List *tlist, char *e_attname)
  * entry with matching resno from targetlist, if there is one.
  */
 
-typedef struct {
-	RewriteInfo	   *info;
-	List		   *targetlist;
-	int				sublevels_up;
+typedef struct
+{
+	RewriteInfo *info;
+	List	   *targetlist;
+	int			sublevels_up;
 } ResolveNew_context;
 
 static Node *
@@ -579,14 +592,15 @@ ResolveNew_mutator(Node *node, ResolveNew_context *context)
 		}
 		/* otherwise fall through to copy the var normally */
 	}
+
 	/*
 	 * Since expression_tree_mutator won't touch subselects, we have to
 	 * handle them specially.
 	 */
 	if (IsA(node, SubLink))
 	{
-		SubLink   *sublink = (SubLink *) node;
-		SubLink   *newnode;
+		SubLink    *sublink = (SubLink *) node;
+		SubLink    *newnode;
 
 		FLATCOPY(newnode, sublink, SubLink);
 		MUTATE(newnode->lefthand, sublink->lefthand, List *,
@@ -599,8 +613,8 @@ ResolveNew_mutator(Node *node, ResolveNew_context *context)
 	}
 	if (IsA(node, Query))
 	{
-		Query  *query = (Query *) node;
-		Query  *newnode;
+		Query	   *query = (Query *) node;
+		Query	   *newnode;
 
 		/*
 		 * XXX original code for ResolveNew only recursed into qual field
@@ -624,7 +638,7 @@ static Node *
 ResolveNew(Node *node, RewriteInfo *info, List *targetlist,
 		   int sublevels_up)
 {
-	ResolveNew_context	context;
+	ResolveNew_context context;
 
 	context.info = info;
 	context.targetlist = targetlist;
@@ -637,13 +651,13 @@ void
 FixNew(RewriteInfo *info, Query *parsetree)
 {
 	info->rule_action->targetList = (List *)
-		ResolveNew((Node *) info->rule_action->targetList,
-				   info, parsetree->targetList, 0);
+	ResolveNew((Node *) info->rule_action->targetList,
+			   info, parsetree->targetList, 0);
 	info->rule_action->qual = ResolveNew(info->rule_action->qual,
 										 info, parsetree->targetList, 0);
 	/* XXX original code didn't fix havingQual; presumably an oversight? */
 	info->rule_action->havingQual = ResolveNew(info->rule_action->havingQual,
-											   info, parsetree->targetList, 0);
+										 info, parsetree->targetList, 0);
 }
 
 /*
@@ -656,14 +670,15 @@ FixNew(RewriteInfo *info, Query *parsetree)
  * XXX Why is this not unified with apply_RIR_view()?
  */
 
-typedef struct {
-	List		   *rtable;
-	List		   *targetlist;
-	int				rt_index;
-	int				attr_num;
-	int			   *modified;
-	int			   *badsql;
-	int				sublevels_up;
+typedef struct
+{
+	List	   *rtable;
+	List	   *targetlist;
+	int			rt_index;
+	int			attr_num;
+	int		   *modified;
+	int		   *badsql;
+	int			sublevels_up;
 } HandleRIRAttributeRule_context;
 
 static Node *
@@ -691,7 +706,7 @@ HandleRIRAttributeRule_mutator(Node *node,
 			}
 			else
 			{
-				char   *name_to_look_for;
+				char	   *name_to_look_for;
 
 				name_to_look_for = get_attname(getrelid(this_varno,
 														context->rtable),
@@ -707,7 +722,11 @@ HandleRIRAttributeRule_mutator(Node *node,
 						return make_null(var->vartype);
 					/* Make a copy of the tlist item to return */
 					n = copyObject(n);
-					/* Adjust varlevelsup if tlist item is from higher query */
+
+					/*
+					 * Adjust varlevelsup if tlist item is from higher
+					 * query
+					 */
 					if (this_varlevelsup > 0)
 						IncrementVarSublevelsUp(n, this_varlevelsup, 0);
 					return n;
@@ -716,14 +735,15 @@ HandleRIRAttributeRule_mutator(Node *node,
 		}
 		/* otherwise fall through to copy the var normally */
 	}
+
 	/*
 	 * Since expression_tree_mutator won't touch subselects, we have to
 	 * handle them specially.
 	 */
 	if (IsA(node, SubLink))
 	{
-		SubLink   *sublink = (SubLink *) node;
-		SubLink   *newnode;
+		SubLink    *sublink = (SubLink *) node;
+		SubLink    *newnode;
 
 		FLATCOPY(newnode, sublink, SubLink);
 		MUTATE(newnode->lefthand, sublink->lefthand, List *,
@@ -736,12 +756,12 @@ HandleRIRAttributeRule_mutator(Node *node,
 	}
 	if (IsA(node, Query))
 	{
-		Query  *query = (Query *) node;
-		Query  *newnode;
+		Query	   *query = (Query *) node;
+		Query	   *newnode;
 
 		/*
 		 * XXX original code for HandleRIRAttributeRule only recursed into
-		 * qual field of subquery.  I'm assuming that was an oversight ...
+		 * qual field of subquery.	I'm assuming that was an oversight ...
 		 */
 
 		FLATCOPY(newnode, query, Query);
@@ -766,7 +786,7 @@ HandleRIRAttributeRule(Query *parsetree,
 					   int *modified,
 					   int *badsql)
 {
-	HandleRIRAttributeRule_context	context;
+	HandleRIRAttributeRule_context context;
 
 	context.rtable = rtable;
 	context.targetlist = targetlist;
@@ -776,7 +796,7 @@ HandleRIRAttributeRule(Query *parsetree,
 	context.badsql = badsql;
 	context.sublevels_up = 0;
 
-	parsetree->targetList = (List *) 
+	parsetree->targetList = (List *)
 		HandleRIRAttributeRule_mutator((Node *) parsetree->targetList,
 									   &context);
 	parsetree->qual = HandleRIRAttributeRule_mutator(parsetree->qual,
diff --git a/src/backend/rewrite/rewriteRemove.c b/src/backend/rewrite/rewriteRemove.c
index d3fda73d48e497d3fbdb0f320d8a5a71f6f0c1c8..821f93440e2d9c57196382386053ad31a2d5ab9d 100644
--- a/src/backend/rewrite/rewriteRemove.c
+++ b/src/backend/rewrite/rewriteRemove.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.35 2000/01/26 05:56:50 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.36 2000/04/12 17:15:32 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -125,8 +125,8 @@ RemoveRewriteRule(char *ruleName)
 	/*
 	 * Delete any comments associated with this rule
 	 *
-	 */	 
-	 
+	 */
+
 	DeleteComments(ruleId);
 
 	/*
@@ -168,13 +168,14 @@ RelationRemoveRules(Oid relid)
 	scanDesc = heap_beginscan(RewriteRelation,
 							  0, SnapshotNow, 1, &scanKeyData);
 
-	while (HeapTupleIsValid(tuple = heap_getnext(scanDesc, 0))) {
+	while (HeapTupleIsValid(tuple = heap_getnext(scanDesc, 0)))
+	{
+
+		/*** Delete any comments associated with this relation ***/
 
-	  /*** Delete any comments associated with this relation ***/
+		DeleteComments(tuple->t_data->t_oid);
 
-	  DeleteComments(tuple->t_data->t_oid);
-	   
-	  heap_delete(RewriteRelation, &tuple->t_self, NULL);
+		heap_delete(RewriteRelation, &tuple->t_self, NULL);
 
 	}
 
diff --git a/src/backend/storage/buffer/buf_init.c b/src/backend/storage/buffer/buf_init.c
index 4f1d033bc42f2eb72dcd9f30b8b66453fb243690..ce212968944978dc87f0a38958bd3d59e3acb214 100644
--- a/src/backend/storage/buffer/buf_init.c
+++ b/src/backend/storage/buffer/buf_init.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.33 2000/04/09 04:43:18 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.34 2000/04/12 17:15:33 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -66,8 +66,9 @@ extern IpcSemaphoreId WaitIOSemId;
 
 long	   *PrivateRefCount;	/* also used in freelist.c */
 bits8	   *BufferLocks;		/* flag bits showing locks I have set */
-BufferTag  *BufferTagLastDirtied; /* tag buffer had when last dirtied by me */
-BufferBlindId *BufferBlindLastDirtied; /* and its BlindId too */
+BufferTag  *BufferTagLastDirtied;		/* tag buffer had when last
+										 * dirtied by me */
+BufferBlindId *BufferBlindLastDirtied;	/* and its BlindId too */
 bool	   *BufferDirtiedByMe;	/* T if buf has been dirtied in cur xact */
 
 
@@ -242,7 +243,7 @@ InitBufferPool(IPCKey key)
 			elog(FATAL, "InitBufferPool: IpcSemaphoreCreate(WaitIOSemId) failed");
 		WaitCLSemId = IpcSemaphoreCreate(IPCKeyGetWaitCLSemaphoreKey(key),
 										 1, IPCProtection,
-										 IpcSemaphoreDefaultStartValue, 1);
+									   IpcSemaphoreDefaultStartValue, 1);
 		if (WaitCLSemId < 0)
 			elog(FATAL, "InitBufferPool: IpcSemaphoreCreate(WaitCLSemId) failed");
 	}
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index b5eb53b03a345df99eb74a8453a0e30673207131..b49e10c895bac1f138afc04c350939a09da47dbb 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.79 2000/04/10 23:41:49 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.80 2000/04/12 17:15:34 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -69,7 +69,7 @@ extern long int LocalBufferFlushCount;
  * marking shared buffer as dirty. We set it to false in xact.c
  * after transaction is committed/aborted.
  */
-bool			SharedBufferChanged = false;
+bool		SharedBufferChanged = false;
 
 static void WaitIO(BufferDesc *buf, SPINLOCK spinlock);
 static void StartBufferIO(BufferDesc *buf, bool forInput);
@@ -80,7 +80,7 @@ extern void AbortBufferIO(void);
 
 /*
  * Macro : BUFFER_IS_BROKEN
- *      Note that write error doesn't mean the buffer broken
+ *		Note that write error doesn't mean the buffer broken
 */
 #define BUFFER_IS_BROKEN(buf) ((buf->flags & BM_IO_ERROR) && !(buf->flags & BM_DIRTY))
 
@@ -117,7 +117,7 @@ RelationGetBufferWithBuffer(Relation relation,
 	{
 		if (!BufferIsLocal(buffer))
 		{
-			LockRelId  *lrelId = & relation->rd_lockInfo.lockRelId;
+			LockRelId  *lrelId = &relation->rd_lockInfo.lockRelId;
 
 			bufHdr = &BufferDescriptors[buffer - 1];
 			SpinAcquire(BufMgrLock);
@@ -381,29 +381,29 @@ BufferAlloc(Relation reln,
 		inProgress = (buf->flags & BM_IO_IN_PROGRESS);
 
 		*foundPtr = TRUE;
-		if (inProgress) /* confirm end of IO */
+		if (inProgress)			/* confirm end of IO */
 		{
 			WaitIO(buf, BufMgrLock);
 			inProgress = (buf->flags & BM_IO_IN_PROGRESS);
 		}
 		if (BUFFER_IS_BROKEN(buf))
 		{
-			/* I couldn't understand the following old comment.
-			 * If there's no IO for the buffer and the buffer
-			 * is BROKEN,it should be read again. So start a
-			 * new buffer IO here. 
+
+			/*
+			 * I couldn't understand the following old comment. If there's
+			 * no IO for the buffer and the buffer is BROKEN,it should be
+			 * read again. So start a new buffer IO here.
 			 *
 			 * wierd race condition:
 			 *
-			 * We were waiting for someone else to read the buffer. While
-			 * we were waiting, the reader boof'd in some way, so the
-			 * contents of the buffer are still invalid.  By saying
-			 * that we didn't find it, we can make the caller
-			 * reinitialize the buffer.  If two processes are waiting
-			 * for this block, both will read the block.  The second
-			 * one to finish may overwrite any updates made by the
-			 * first.  (Assume higher level synchronization prevents
-			 * this from happening).
+			 * We were waiting for someone else to read the buffer. While we
+			 * were waiting, the reader boof'd in some way, so the
+			 * contents of the buffer are still invalid.  By saying that
+			 * we didn't find it, we can make the caller reinitialize the
+			 * buffer.	If two processes are waiting for this block, both
+			 * will read the block.  The second one to finish may
+			 * overwrite any updates made by the first.  (Assume higher
+			 * level synchronization prevents this from happening).
 			 *
 			 * This is never going to happen, don't worry about it.
 			 */
@@ -483,7 +483,7 @@ BufferAlloc(Relation reln,
 			if (smok == FALSE)
 			{
 				elog(NOTICE, "BufferAlloc: cannot write block %u for %s/%s",
-					 buf->tag.blockNum, buf->blind.dbname, buf->blind.relname);
+				buf->tag.blockNum, buf->blind.dbname, buf->blind.relname);
 				inProgress = FALSE;
 				buf->flags |= BM_IO_ERROR;
 				buf->flags &= ~BM_IO_IN_PROGRESS;
@@ -628,9 +628,7 @@ BufferAlloc(Relation reln,
 	 * attempted, so the flag isnt set.
 	 */
 	if (!inProgress)
-	{
 		StartBufferIO(buf, true);
-	}
 	else
 		ContinueBufferIO(buf, true);
 
@@ -777,7 +775,7 @@ FlushBuffer(Buffer buffer, bool release)
 	if (BAD_BUFFER_ID(buffer))
 		return STATUS_ERROR;
 
-	Assert(PrivateRefCount[buffer - 1] > 0); /* else caller didn't pin */
+	Assert(PrivateRefCount[buffer - 1] > 0);	/* else caller didn't pin */
 
 	bufHdr = &BufferDescriptors[buffer - 1];
 	bufdb = bufHdr->tag.relId.dbId;
@@ -790,9 +788,9 @@ FlushBuffer(Buffer buffer, bool release)
 
 	/* To check if block content changed while flushing. - vadim 01/17/97 */
 	SpinAcquire(BufMgrLock);
-	WaitIO(bufHdr, BufMgrLock);	/* confirm end of IO */
+	WaitIO(bufHdr, BufMgrLock); /* confirm end of IO */
 	bufHdr->flags &= ~BM_JUST_DIRTIED;
-	StartBufferIO(bufHdr, false);	/* output IO start */
+	StartBufferIO(bufHdr, false);		/* output IO start */
 	SpinRelease(BufMgrLock);
 
 	status = smgrflush(DEFAULT_SMGR, bufrel, bufHdr->tag.blockNum,
@@ -810,12 +808,13 @@ FlushBuffer(Buffer buffer, bool release)
 	BufferFlushCount++;
 
 	SpinAcquire(BufMgrLock);
-	bufHdr->flags &= ~BM_IO_IN_PROGRESS;	/* mark IO finished */
-	TerminateBufferIO(bufHdr);		/* output IO finished */
+	bufHdr->flags &= ~BM_IO_IN_PROGRESS;		/* mark IO finished */
+	TerminateBufferIO(bufHdr);	/* output IO finished */
 
 	/*
 	 * If this buffer was marked by someone as DIRTY while we were
-	 * flushing it out we must not clear shared DIRTY flag - vadim 01/17/97
+	 * flushing it out we must not clear shared DIRTY flag - vadim
+	 * 01/17/97
 	 *
 	 * ... but we can clear BufferDirtiedByMe anyway - tgl 3/31/00
 	 */
@@ -927,7 +926,7 @@ ReleaseAndReadBuffer(Buffer buffer,
 static void
 SetBufferDirtiedByMe(Buffer buffer, BufferDesc *bufHdr)
 {
-	BufferTag  *tagLastDirtied = & BufferTagLastDirtied[buffer - 1];
+	BufferTag  *tagLastDirtied = &BufferTagLastDirtied[buffer - 1];
 	Relation	reln;
 	int			status;
 
@@ -953,8 +952,8 @@ SetBufferDirtiedByMe(Buffer buffer, BufferDesc *bufHdr)
 		if (reln == (Relation) NULL)
 		{
 			status = smgrblindmarkdirty(DEFAULT_SMGR,
-										BufferBlindLastDirtied[buffer - 1].dbname,
-										BufferBlindLastDirtied[buffer - 1].relname,
+							   BufferBlindLastDirtied[buffer - 1].dbname,
+							  BufferBlindLastDirtied[buffer - 1].relname,
 										tagLastDirtied->relId.dbId,
 										tagLastDirtied->relId.relId,
 										tagLastDirtied->blockNum);
@@ -963,7 +962,11 @@ SetBufferDirtiedByMe(Buffer buffer, BufferDesc *bufHdr)
 		{
 			status = smgrmarkdirty(DEFAULT_SMGR, reln,
 								   tagLastDirtied->blockNum);
-			/* drop relcache refcnt incremented by RelationIdCacheGetRelation */
+
+			/*
+			 * drop relcache refcnt incremented by
+			 * RelationIdCacheGetRelation
+			 */
 			RelationDecrementReferenceCount(reln);
 		}
 		if (status == SM_FAIL)
@@ -996,25 +999,23 @@ SetBufferDirtiedByMe(Buffer buffer, BufferDesc *bufHdr)
 static void
 ClearBufferDirtiedByMe(Buffer buffer, BufferDesc *bufHdr)
 {
-	BufferTag  *tagLastDirtied = & BufferTagLastDirtied[buffer - 1];
+	BufferTag  *tagLastDirtied = &BufferTagLastDirtied[buffer - 1];
 
 	/*
 	 * Do *not* clear the flag if it refers to some other buffertag than
-	 * the data we just wrote.  This is unlikely, but possible if some
+	 * the data we just wrote.	This is unlikely, but possible if some
 	 * other backend replaced the buffer contents since we set our flag.
 	 */
 	if (bufHdr->tag.relId.dbId == tagLastDirtied->relId.dbId &&
 		bufHdr->tag.relId.relId == tagLastDirtied->relId.relId &&
 		bufHdr->tag.blockNum == tagLastDirtied->blockNum)
-	{
 		BufferDirtiedByMe[buffer - 1] = false;
-	}
 }
 
 /*
  * BufferSync -- Flush all dirty buffers in the pool.
  *
- *		This is called at transaction commit time.  We find all buffers
+ *		This is called at transaction commit time.	We find all buffers
  *		that have been dirtied by the current xact and flush them to disk.
  *		We do *not* flush dirty buffers that have been dirtied by other xacts.
  *		(This is a substantial change from pre-7.0 behavior.)
@@ -1044,16 +1045,16 @@ BufferSync()
 	for (i = 0, bufHdr = BufferDescriptors; i < NBuffers; i++, bufHdr++)
 	{
 		/* Ignore buffers that were not dirtied by me */
-		if (! BufferDirtiedByMe[i])
+		if (!BufferDirtiedByMe[i])
 			continue;
 
 		SpinAcquire(BufMgrLock);
 
 		/*
 		 * We only need to write if the buffer is still dirty and still
-		 * contains the same disk page that it contained when we dirtied it.
-		 * Otherwise, someone else has already written our changes for us,
-		 * and we need only fsync.
+		 * contains the same disk page that it contained when we dirtied
+		 * it. Otherwise, someone else has already written our changes for
+		 * us, and we need only fsync.
 		 *
 		 * (NOTE: it's still possible to do an unnecessary write, if other
 		 * xacts have written and then re-dirtied the page since our last
@@ -1073,6 +1074,7 @@ BufferSync()
 				bufrel == BufferTagLastDirtied[i].relId.relId &&
 				bufHdr->tag.blockNum == BufferTagLastDirtied[i].blockNum)
 			{
+
 				/*
 				 * Try to find relation for buf.  This could fail, if the
 				 * rel has been flushed from the relcache since we dirtied
@@ -1103,19 +1105,20 @@ BufferSync()
 				}
 				else
 				{
+
 					/*
-					 * To check if block content changed while flushing (see
-					 * below). - vadim 01/17/97
+					 * To check if block content changed while flushing
+					 * (see below). - vadim 01/17/97
 					 */
-					WaitIO(bufHdr, BufMgrLock);	/* confirm end of IO */
+					WaitIO(bufHdr, BufMgrLock); /* confirm end of IO */
 					bufHdr->flags &= ~BM_JUST_DIRTIED;
-					StartBufferIO(bufHdr, false); /* output IO start */
+					StartBufferIO(bufHdr, false);		/* output IO start */
 
 					/*
-					 * If we didn't have the reldesc in our local cache, write
-					 * this page out using the 'blind write' storage manager
-					 * routine.  If we did find it, use the standard
-					 * interface.
+					 * If we didn't have the reldesc in our local cache,
+					 * write this page out using the 'blind write' storage
+					 * manager routine.  If we did find it, use the
+					 * standard interface.
 					 */
 #ifndef OPTIMIZE_SINGLE
 					SpinRelease(BufMgrLock);
@@ -1127,14 +1130,14 @@ BufferSync()
 											  bufHdr->blind.relname,
 											  bufdb, bufrel,
 											  bufHdr->tag.blockNum,
-											  (char *) MAKE_PTR(bufHdr->data),
-											  true); /* must fsync */
+										 (char *) MAKE_PTR(bufHdr->data),
+											  true);	/* must fsync */
 					}
 					else
 					{
 						status = smgrwrite(DEFAULT_SMGR, reln,
 										   bufHdr->tag.blockNum,
-										   (char *) MAKE_PTR(bufHdr->data));
+										(char *) MAKE_PTR(bufHdr->data));
 					}
 #ifndef OPTIMIZE_SINGLE
 					SpinAcquire(BufMgrLock);
@@ -1147,15 +1150,15 @@ BufferSync()
 						elog(ERROR, "BufferSync: cannot write %u for %s",
 							 bufHdr->tag.blockNum, bufHdr->blind.relname);
 					}
-					bufHdr->flags &= ~BM_IO_IN_PROGRESS; /* mark IO finished */
+					bufHdr->flags &= ~BM_IO_IN_PROGRESS;		/* mark IO finished */
 					TerminateBufferIO(bufHdr);	/* Sync IO finished */
 					BufferFlushCount++;
 					didwrite = true;
 
 					/*
-					 * If this buffer was marked by someone as DIRTY while we
-					 * were flushing it out we must not clear DIRTY flag -
-					 * vadim 01/17/97
+					 * If this buffer was marked by someone as DIRTY while
+					 * we were flushing it out we must not clear DIRTY
+					 * flag - vadim 01/17/97
 					 *
 					 * but it is OK to clear BufferDirtiedByMe - tgl 3/31/00
 					 */
@@ -1170,11 +1173,11 @@ BufferSync()
 		}
 
 		/*
-		 * If we did not write the buffer (because someone else did),
-		 * we must still fsync the file containing it, to ensure that the
+		 * If we did not write the buffer (because someone else did), we
+		 * must still fsync the file containing it, to ensure that the
 		 * write is down to disk before we commit.
 		 */
-		if (! didwrite)
+		if (!didwrite)
 		{
 #ifndef OPTIMIZE_SINGLE
 			SpinRelease(BufMgrLock);
@@ -1184,17 +1187,21 @@ BufferSync()
 			if (reln == (Relation) NULL)
 			{
 				status = smgrblindmarkdirty(DEFAULT_SMGR,
-											BufferBlindLastDirtied[i].dbname,
-											BufferBlindLastDirtied[i].relname,
-											BufferTagLastDirtied[i].relId.dbId,
-											BufferTagLastDirtied[i].relId.relId,
-											BufferTagLastDirtied[i].blockNum);
+										BufferBlindLastDirtied[i].dbname,
+									   BufferBlindLastDirtied[i].relname,
+									  BufferTagLastDirtied[i].relId.dbId,
+									 BufferTagLastDirtied[i].relId.relId,
+									   BufferTagLastDirtied[i].blockNum);
 			}
 			else
 			{
 				status = smgrmarkdirty(DEFAULT_SMGR, reln,
 									   BufferTagLastDirtied[i].blockNum);
-				/* drop relcache refcnt incremented by RelationIdCacheGetRelation */
+
+				/*
+				 * drop relcache refcnt incremented by
+				 * RelationIdCacheGetRelation
+				 */
 				RelationDecrementReferenceCount(reln);
 
 			}
@@ -1241,6 +1248,7 @@ BufferSync()
 static void
 WaitIO(BufferDesc *buf, SPINLOCK spinlock)
 {
+
 	/*
 	 * Changed to wait until there's no IO - Inoue 01/13/2000
 	 */
@@ -1369,13 +1377,13 @@ ResetBufferPool(bool isCommit)
 		}
 		PrivateRefCount[i] = 0;
 
-		if (! isCommit)
+		if (!isCommit)
 			BufferDirtiedByMe[i] = false;
 	}
 
 	ResetLocalBufferPool();
 
-	if (! isCommit)
+	if (!isCommit)
 		smgrabort();
 }
 
@@ -1531,7 +1539,7 @@ BufferReplace(BufferDesc *bufHdr)
 							  bufHdr->blind.relname, bufdb, bufrel,
 							  bufHdr->tag.blockNum,
 							  (char *) MAKE_PTR(bufHdr->data),
-							  false); /* no fsync */
+							  false);	/* no fsync */
 	}
 
 #ifndef OPTIMIZE_SINGLE
@@ -1545,9 +1553,10 @@ BufferReplace(BufferDesc *bufHdr)
 	if (status == SM_FAIL)
 		return FALSE;
 
-	/* If we had marked this buffer as needing to be fsync'd, we can forget
-	 * about that, because it's now the storage manager's responsibility
-	 * (but only if we called smgrwrite, not smgrblindwrt).
+	/*
+	 * If we had marked this buffer as needing to be fsync'd, we can
+	 * forget about that, because it's now the storage manager's
+	 * responsibility (but only if we called smgrwrite, not smgrblindwrt).
 	 */
 	if (reln != (Relation) NULL)
 		ClearBufferDirtiedByMe(BufferDescriptorGetBuffer(bufHdr), bufHdr);
@@ -1601,7 +1610,7 @@ ReleaseRelationBuffers(Relation rel)
 		{
 			buf = &LocalBufferDescriptors[i];
 			if (buf->tag.relId.relId == relid)
-				buf->flags &= ~ ( BM_DIRTY | BM_JUST_DIRTIED);
+				buf->flags &= ~(BM_DIRTY | BM_JUST_DIRTIED);
 		}
 		return;
 	}
@@ -1614,10 +1623,11 @@ ReleaseRelationBuffers(Relation rel)
 			SpinAcquire(BufMgrLock);
 			holding = true;
 		}
-	recheck:
+recheck:
 		if (buf->tag.relId.dbId == MyDatabaseId &&
 			buf->tag.relId.relId == relid)
 		{
+
 			/*
 			 * If there is I/O in progress, better wait till it's done;
 			 * don't want to delete the relation out from under someone
@@ -1626,19 +1636,23 @@ ReleaseRelationBuffers(Relation rel)
 			if (buf->flags & BM_IO_IN_PROGRESS)
 			{
 				WaitIO(buf, BufMgrLock);
-				/* By now, the buffer very possibly belongs to some other
+
+				/*
+				 * By now, the buffer very possibly belongs to some other
 				 * rel, so check again before proceeding.
 				 */
 				goto recheck;
 			}
 			/* Now we can do what we came for */
-			buf->flags &= ~ ( BM_DIRTY | BM_JUST_DIRTIED);
+			buf->flags &= ~(BM_DIRTY | BM_JUST_DIRTIED);
 			ClearBufferDirtiedByMe(i, buf);
+
 			/*
 			 * Release any refcount we may have.
 			 *
 			 * This is very probably dead code, and if it isn't then it's
-			 * probably wrong.  I added the Assert to find out --- tgl 11/99.
+			 * probably wrong.	I added the Assert to find out --- tgl
+			 * 11/99.
 			 */
 			if (!(buf->flags & BM_FREE))
 			{
@@ -1663,7 +1677,7 @@ ReleaseRelationBuffers(Relation rel)
  *		This function marks all the buffers in the buffer cache for a
  *		particular database as clean.  This is used when we destroy a
  *		database, to avoid trying to flush data to disk when the directory
- *		tree no longer exists.  Implementation is pretty similar to
+ *		tree no longer exists.	Implementation is pretty similar to
  *		ReleaseRelationBuffers() which is for destroying just one relation.
  * --------------------------------------------------------------------
  */
@@ -1677,9 +1691,10 @@ DropBuffers(Oid dbid)
 	for (i = 1; i <= NBuffers; i++)
 	{
 		buf = &BufferDescriptors[i - 1];
-	recheck:
+recheck:
 		if (buf->tag.relId.dbId == dbid)
 		{
+
 			/*
 			 * If there is I/O in progress, better wait till it's done;
 			 * don't want to delete the database out from under someone
@@ -1688,17 +1703,20 @@ DropBuffers(Oid dbid)
 			if (buf->flags & BM_IO_IN_PROGRESS)
 			{
 				WaitIO(buf, BufMgrLock);
-				/* By now, the buffer very possibly belongs to some other
+
+				/*
+				 * By now, the buffer very possibly belongs to some other
 				 * DB, so check again before proceeding.
 				 */
 				goto recheck;
 			}
 			/* Now we can do what we came for */
-			buf->flags &= ~ ( BM_DIRTY | BM_JUST_DIRTIED);
+			buf->flags &= ~(BM_DIRTY | BM_JUST_DIRTIED);
 			ClearBufferDirtiedByMe(i, buf);
+
 			/*
-			 * The thing should be free, if caller has checked that
-			 * no backends are running in that database.
+			 * The thing should be free, if caller has checked that no
+			 * backends are running in that database.
 			 */
 			Assert(buf->flags & BM_FREE);
 		}
@@ -1796,7 +1814,7 @@ BufferPoolBlowaway()
  *
  *		This function removes from the buffer pool all pages of a relation
  *		that have blocknumber >= specified block.  Pages that are dirty are
- *		written out first.  If expectDirty is false, a notice is emitted
+ *		written out first.	If expectDirty is false, a notice is emitted
  *		warning of dirty buffers, but we proceed anyway.  An error code is
  *		returned if we fail to dump a dirty buffer or if we find one of
  *		the target pages is pinned into the cache.
@@ -1804,7 +1822,7 @@ BufferPoolBlowaway()
  *		This is used by VACUUM before truncating the relation to the given
  *		number of blocks.  For VACUUM, we pass expectDirty = false since it
  *		could mean a bug in VACUUM if any of the unwanted pages were still
- *		dirty.  (TRUNCATE TABLE also uses it in the same way.)
+ *		dirty.	(TRUNCATE TABLE also uses it in the same way.)
  *
  *		This is also used by RENAME TABLE (with block=0 and expectDirty=true)
  *		to clear out the buffer cache before renaming the physical files of
@@ -1817,7 +1835,7 @@ BufferPoolBlowaway()
  *		more blocks of the relation.
  *
  *		Formerly, we considered it an error condition if we found unexpectedly
- *		dirty buffers.  However, since BufferSync no longer forces out all
+ *		dirty buffers.	However, since BufferSync no longer forces out all
  *		dirty buffers at every xact commit, it's possible for dirty buffers
  *		to still be present in the cache due to failure of an earlier
  *		transaction.  So, downgrade the error to a mere notice.  Maybe we
@@ -1845,11 +1863,11 @@ FlushRelationBuffers(Relation rel, BlockNumber block, bool expectDirty)
 			{
 				if (buf->flags & BM_DIRTY)
 				{
-					if (! expectDirty)
+					if (!expectDirty)
 						elog(NOTICE, "FlushRelationBuffers(%s (local), %u): block %u is dirty",
 							 RelationGetRelationName(rel),
 							 block, buf->tag.blockNum);
-					if (FlushBuffer(-i-1, false) != STATUS_OK)
+					if (FlushBuffer(-i - 1, false) != STATUS_OK)
 					{
 						elog(NOTICE, "FlushRelationBuffers(%s (local), %u): block %u is dirty, could not flush it",
 							 RelationGetRelationName(rel),
@@ -1873,7 +1891,7 @@ FlushRelationBuffers(Relation rel, BlockNumber block, bool expectDirty)
 	SpinAcquire(BufMgrLock);
 	for (i = 0; i < NBuffers; i++)
 	{
-	recheck:
+recheck:
 		buf = &BufferDescriptors[i];
 		if (buf->tag.relId.relId == RelationGetRelid(rel) &&
 			(buf->tag.relId.dbId == MyDatabaseId ||
@@ -1884,12 +1902,12 @@ FlushRelationBuffers(Relation rel, BlockNumber block, bool expectDirty)
 			{
 				PinBuffer(buf);
 				SpinRelease(BufMgrLock);
-				if (! expectDirty)
+				if (!expectDirty)
 					elog(NOTICE, "FlushRelationBuffers(%s, %u): block %u is dirty (private %ld, global %d)",
 						 RelationGetRelationName(rel), block,
 						 buf->tag.blockNum,
 						 PrivateRefCount[i], buf->refcount);
-				if (FlushBuffer(i+1, true) != STATUS_OK)
+				if (FlushBuffer(i + 1, true) != STATUS_OK)
 				{
 					elog(NOTICE, "FlushRelationBuffers(%s, %u): block %u is dirty (private %ld, global %d), could not flush it",
 						 RelationGetRelationName(rel), block,
@@ -1898,7 +1916,9 @@ FlushRelationBuffers(Relation rel, BlockNumber block, bool expectDirty)
 					return -1;
 				}
 				SpinAcquire(BufMgrLock);
-				/* Buffer could already be reassigned, so must recheck
+
+				/*
+				 * Buffer could already be reassigned, so must recheck
 				 * whether it still belongs to rel before freeing it!
 				 */
 				goto recheck;
@@ -2244,9 +2264,10 @@ UnlockBuffers()
 		}
 		if (BufferLocks[i] & BL_RI_LOCK)
 		{
-			/* 
-			 * Someone else could remove our RI lock when acquiring
-			 * W lock. This is possible if we came here from elog(ERROR)
+
+			/*
+			 * Someone else could remove our RI lock when acquiring W
+			 * lock. This is possible if we came here from elog(ERROR)
 			 * from IpcSemaphore{Lock|Unlock}(WaitCLSemId). And so we
 			 * don't do Assert(buf->ri_lock) here.
 			 */
@@ -2270,7 +2291,7 @@ void
 LockBuffer(Buffer buffer, int mode)
 {
 	BufferDesc *buf;
-	bits8 *buflock;
+	bits8	   *buflock;
 
 	Assert(BufferIsValid(buffer));
 	if (BufferIsLocal(buffer))
@@ -2335,11 +2356,12 @@ LockBuffer(Buffer buffer, int mode)
 		{
 			if (buf->r_locks > 3 || (*buflock & BL_RI_LOCK))
 			{
+
 				/*
 				 * Our RI lock might be removed by concurrent W lock
-				 * acquiring (see what we do with RI locks below
-				 * when our own W acquiring succeeded) and so
-				 * we set RI lock again if we already did this.
+				 * acquiring (see what we do with RI locks below when our
+				 * own W acquiring succeeded) and so we set RI lock again
+				 * if we already did this.
 				 */
 				*buflock |= BL_RI_LOCK;
 				buf->ri_lock = true;
@@ -2358,9 +2380,10 @@ LockBuffer(Buffer buffer, int mode)
 		*buflock |= BL_W_LOCK;
 		if (*buflock & BL_RI_LOCK)
 		{
+
 			/*
-			 * It's possible to remove RI locks acquired by another
-			 * W lockers here, but they'll take care about it.
+			 * It's possible to remove RI locks acquired by another W
+			 * lockers here, but they'll take care about it.
 			 */
 			buf->ri_lock = false;
 			*buflock &= ~BL_RI_LOCK;
@@ -2384,36 +2407,39 @@ LockBuffer(Buffer buffer, int mode)
  *	i.e at most one io_in_progress spinlock is held
  *	per proc.
 */
-static	BufferDesc *InProgressBuf = (BufferDesc *)NULL;
-static	bool	IsForInput;
+static BufferDesc *InProgressBuf = (BufferDesc *) NULL;
+static bool IsForInput;
 
 /*
  * Function:StartBufferIO
  *	(Assumptions)
  *	My process is executing no IO
  *	BufMgrLock is held
- *	BM_IO_IN_PROGRESS mask is not set for the buffer 
+ *	BM_IO_IN_PROGRESS mask is not set for the buffer
  *	The buffer is Pinned
  *
 */
-static void StartBufferIO(BufferDesc *buf, bool forInput)
+static void
+StartBufferIO(BufferDesc *buf, bool forInput)
 {
 	Assert(!InProgressBuf);
 	Assert(!(buf->flags & BM_IO_IN_PROGRESS));
 	buf->flags |= BM_IO_IN_PROGRESS;
 #ifdef	HAS_TEST_AND_SET
+
 	/*
 	 * There used to be
 	 *
 	 * Assert(S_LOCK_FREE(&(buf->io_in_progress_lock)));
 	 *
 	 * here, but that's wrong because of the way WaitIO works: someone else
-	 * waiting for the I/O to complete will succeed in grabbing the lock for
-	 * a few instructions, and if we context-swap back to here the Assert
-	 * could fail.  Tiny window for failure, but I've seen it happen -- tgl
+	 * waiting for the I/O to complete will succeed in grabbing the lock
+	 * for a few instructions, and if we context-swap back to here the
+	 * Assert could fail.  Tiny window for failure, but I've seen it
+	 * happen -- tgl
 	 */
 	S_LOCK(&(buf->io_in_progress_lock));
-#endif /* HAS_TEST_AND_SET */
+#endif	 /* HAS_TEST_AND_SET */
 	InProgressBuf = buf;
 	IsForInput = forInput;
 }
@@ -2426,7 +2452,8 @@ static void StartBufferIO(BufferDesc *buf, bool forInput)
  *	The buffer is Pinned
  *
 */
-static void TerminateBufferIO(BufferDesc *buf)
+static void
+TerminateBufferIO(BufferDesc *buf)
 {
 	Assert(buf == InProgressBuf);
 #ifdef	HAS_TEST_AND_SET
@@ -2434,8 +2461,8 @@ static void TerminateBufferIO(BufferDesc *buf)
 #else
 	if (buf->refcount > 1)
 		SignalIO(buf);
-#endif /* HAS_TEST_AND_SET */
-	InProgressBuf = (BufferDesc *)0;
+#endif	 /* HAS_TEST_AND_SET */
+	InProgressBuf = (BufferDesc *) 0;
 }
 
 /*
@@ -2446,36 +2473,38 @@ static void TerminateBufferIO(BufferDesc *buf)
  *	The buffer is Pinned
  *
 */
-static void ContinueBufferIO(BufferDesc *buf, bool forInput)
+static void
+ContinueBufferIO(BufferDesc *buf, bool forInput)
 {
 	Assert(buf == InProgressBuf);
 	Assert(buf->flags & BM_IO_IN_PROGRESS);
 	IsForInput = forInput;
 }
 
-void InitBufferIO(void)
+void
+InitBufferIO(void)
 {
-	InProgressBuf = (BufferDesc *)0;
+	InProgressBuf = (BufferDesc *) 0;
 }
 
 /*
  *	This function is called from ProcReleaseSpins().
- *	BufMgrLock isn't held when this function is called. 
+ *	BufMgrLock isn't held when this function is called.
  *	BM_IO_ERROR is always set. If BM_IO_ERROR was already
- *	set in case of output,this routine would kill all 
+ *	set in case of output,this routine would kill all
  *	backends and reset postmaster.
  */
-void AbortBufferIO(void)
+void
+AbortBufferIO(void)
 {
 	BufferDesc *buf = InProgressBuf;
+
 	if (buf)
 	{
 		Assert(buf->flags & BM_IO_IN_PROGRESS);
 		SpinAcquire(BufMgrLock);
 		if (IsForInput)
-		{
 			Assert(!(buf->flags & BM_DIRTY));
-		}
 		else
 		{
 			Assert((buf->flags & BM_DIRTY) != 0);
diff --git a/src/backend/storage/buffer/localbuf.c b/src/backend/storage/buffer/localbuf.c
index 84d24e553b4c52f0a05f0c44ef0799e58e6cf04f..91eff97f26482649de63578b35394ce71cc1b373 100644
--- a/src/backend/storage/buffer/localbuf.c
+++ b/src/backend/storage/buffer/localbuf.c
@@ -16,7 +16,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.29 2000/01/26 05:56:52 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.30 2000/04/12 17:15:34 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -111,7 +111,10 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
 				  (char *) MAKE_PTR(bufHdr->data));
 		LocalBufferFlushCount++;
 
-		/* drop relcache refcount incremented by RelationIdCacheGetRelation */
+		/*
+		 * drop relcache refcount incremented by
+		 * RelationIdCacheGetRelation
+		 */
 		RelationDecrementReferenceCount(bufrel);
 	}
 
diff --git a/src/backend/storage/file/buffile.c b/src/backend/storage/file/buffile.c
index 2af57b56380935543875af40c914e2c1ab185c24..d62ed2670c85d36118d3b1dda6f0229df94e7e6d 100644
--- a/src/backend/storage/file/buffile.c
+++ b/src/backend/storage/file/buffile.c
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/storage/file/buffile.c,v 1.4 2000/01/26 05:56:55 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/storage/file/buffile.c,v 1.5 2000/04/12 17:15:35 momjian Exp $
  *
  * NOTES:
  *
@@ -23,11 +23,11 @@
  * will go away automatically at transaction end.  If the underlying
  * virtual File is made with OpenTemporaryFile, then all resources for
  * the file are certain to be cleaned up even if processing is aborted
- * by elog(ERROR).  To avoid confusion, the caller should take care that
+ * by elog(ERROR).	To avoid confusion, the caller should take care that
  * all calls for a single BufFile are made in the same palloc context.
  *
  * BufFile also supports temporary files that exceed the OS file size limit
- * (by opening multiple fd.c temporary files).  This is an essential feature
+ * (by opening multiple fd.c temporary files).	This is an essential feature
  * for sorts and hashjoins on large amounts of data.
  *-------------------------------------------------------------------------
  */
@@ -56,15 +56,19 @@ struct BufFile
 	/* all files except the last have length exactly MAX_PHYSICAL_FILESIZE */
 	File	   *files;			/* palloc'd array with numFiles entries */
 	long	   *offsets;		/* palloc'd array with numFiles entries */
-	/* offsets[i] is the current seek position of files[i].  We use this
+
+	/*
+	 * offsets[i] is the current seek position of files[i].  We use this
 	 * to avoid making redundant FileSeek calls.
 	 */
 
 	bool		isTemp;			/* can only add files if this is TRUE */
 	bool		dirty;			/* does buffer need to be written? */
+
 	/*
-	 * "current pos" is position of start of buffer within the logical file.
-	 * Position as seen by user of BufFile is (curFile, curOffset + pos).
+	 * "current pos" is position of start of buffer within the logical
+	 * file. Position as seen by user of BufFile is (curFile, curOffset +
+	 * pos).
 	 */
 	int			curFile;		/* file index (0..n) part of current pos */
 	int			curOffset;		/* offset part of current pos */
@@ -87,7 +91,7 @@ static int	BufFileFlush(BufFile *file);
 static BufFile *
 makeBufFile(File firstfile)
 {
-	BufFile	   *file = (BufFile *) palloc(sizeof(BufFile));
+	BufFile    *file = (BufFile *) palloc(sizeof(BufFile));
 
 	file->numFiles = 1;
 	file->files = (File *) palloc(sizeof(File));
@@ -117,9 +121,9 @@ extendBufFile(BufFile *file)
 	Assert(pfile >= 0);
 
 	file->files = (File *) repalloc(file->files,
-									(file->numFiles+1) * sizeof(File));
+									(file->numFiles + 1) * sizeof(File));
 	file->offsets = (long *) repalloc(file->offsets,
-									  (file->numFiles+1) * sizeof(long));
+									(file->numFiles + 1) * sizeof(long));
 	file->files[file->numFiles] = pfile;
 	file->offsets[file->numFiles] = 0L;
 	file->numFiles++;
@@ -130,7 +134,7 @@ extendBufFile(BufFile *file)
  * multiple temporary files if more than MAX_PHYSICAL_FILESIZE bytes are
  * written to it).
  */
-BufFile *
+BufFile    *
 BufFileCreateTemp(void)
 {
 	BufFile    *file;
@@ -152,7 +156,7 @@ BufFileCreateTemp(void)
  * to attach a BufFile to a non-temporary file.  Note that BufFiles created
  * in this way CANNOT be expanded into multiple files.
  */
-BufFile *
+BufFile    *
 BufFileCreate(File file)
 {
 	return makeBufFile(file);
@@ -166,7 +170,7 @@ BufFileCreate(File file)
 void
 BufFileClose(BufFile *file)
 {
-	int		i;
+	int			i;
 
 	/* flush any unwritten data */
 	BufFileFlush(file);
@@ -189,21 +193,22 @@ BufFileClose(BufFile *file)
 static void
 BufFileLoadBuffer(BufFile *file)
 {
-	File	thisfile;
+	File		thisfile;
 
 	/*
 	 * Advance to next component file if necessary and possible.
 	 *
-	 * This path can only be taken if there is more than one component,
-	 * so it won't interfere with reading a non-temp file that is over
+	 * This path can only be taken if there is more than one component, so it
+	 * won't interfere with reading a non-temp file that is over
 	 * MAX_PHYSICAL_FILESIZE.
 	 */
 	if (file->curOffset >= MAX_PHYSICAL_FILESIZE &&
-		file->curFile+1 < file->numFiles)
+		file->curFile + 1 < file->numFiles)
 	{
 		file->curFile++;
 		file->curOffset = 0L;
 	}
+
 	/*
 	 * May need to reposition physical file.
 	 */
@@ -214,6 +219,7 @@ BufFileLoadBuffer(BufFile *file)
 			return;				/* seek failed, read nothing */
 		file->offsets[file->curFile] = file->curOffset;
 	}
+
 	/*
 	 * Read whatever we can get, up to a full bufferload.
 	 */
@@ -239,21 +245,23 @@ BufFileDumpBuffer(BufFile *file)
 	File		thisfile;
 
 	/*
-	 * Unlike BufFileLoadBuffer, we must dump the whole buffer even if
-	 * it crosses a component-file boundary; so we need a loop.
+	 * Unlike BufFileLoadBuffer, we must dump the whole buffer even if it
+	 * crosses a component-file boundary; so we need a loop.
 	 */
 	while (wpos < file->nbytes)
 	{
+
 		/*
 		 * Advance to next component file if necessary and possible.
 		 */
 		if (file->curOffset >= MAX_PHYSICAL_FILESIZE && file->isTemp)
 		{
-			while (file->curFile+1 >= file->numFiles)
+			while (file->curFile + 1 >= file->numFiles)
 				extendBufFile(file);
 			file->curFile++;
 			file->curOffset = 0L;
 		}
+
 		/*
 		 * Enforce per-file size limit only for temp files, else just try
 		 * to write as much as asked...
@@ -261,11 +269,12 @@ BufFileDumpBuffer(BufFile *file)
 		bytestowrite = file->nbytes - wpos;
 		if (file->isTemp)
 		{
-			long	availbytes = MAX_PHYSICAL_FILESIZE - file->curOffset;
+			long		availbytes = MAX_PHYSICAL_FILESIZE - file->curOffset;
 
 			if ((long) bytestowrite > availbytes)
 				bytestowrite = (int) availbytes;
 		}
+
 		/*
 		 * May need to reposition physical file.
 		 */
@@ -284,11 +293,13 @@ BufFileDumpBuffer(BufFile *file)
 		wpos += bytestowrite;
 	}
 	file->dirty = false;
+
 	/*
-	 * At this point, curOffset has been advanced to the end of the buffer,
-	 * ie, its original value + nbytes.  We need to make it point to the
-	 * logical file position, ie, original value + pos, in case that is less
-	 * (as could happen due to a small backwards seek in a dirty buffer!)
+	 * At this point, curOffset has been advanced to the end of the
+	 * buffer, ie, its original value + nbytes.  We need to make it point
+	 * to the logical file position, ie, original value + pos, in case
+	 * that is less (as could happen due to a small backwards seek in a
+	 * dirty buffer!)
 	 */
 	file->curOffset -= (file->nbytes - file->pos);
 	if (file->curOffset < 0)	/* handle possible segment crossing */
@@ -297,7 +308,11 @@ BufFileDumpBuffer(BufFile *file)
 		Assert(file->curFile >= 0);
 		file->curOffset += MAX_PHYSICAL_FILESIZE;
 	}
-	/* Now we can set the buffer empty without changing the logical position */
+
+	/*
+	 * Now we can set the buffer empty without changing the logical
+	 * position
+	 */
 	file->pos = 0;
 	file->nbytes = 0;
 }
@@ -317,7 +332,7 @@ BufFileRead(BufFile *file, void *ptr, size_t size)
 	{
 		if (BufFileFlush(file) != 0)
 			return 0;			/* could not flush... */
-		Assert(! file->dirty);
+		Assert(!file->dirty);
 	}
 
 	while (size > 0)
@@ -430,8 +445,9 @@ BufFileFlush(BufFile *file)
 int
 BufFileSeek(BufFile *file, int fileno, long offset, int whence)
 {
-	int newFile;
-	long newOffset;
+	int			newFile;
+	long		newOffset;
+
 	switch (whence)
 	{
 		case SEEK_SET:
@@ -441,9 +457,11 @@ BufFileSeek(BufFile *file, int fileno, long offset, int whence)
 			newOffset = offset;
 			break;
 		case SEEK_CUR:
+
 			/*
-			 * Relative seek considers only the signed offset, ignoring fileno.
-			 * Note that large offsets (> 1 gig) risk overflow in this add...
+			 * Relative seek considers only the signed offset, ignoring
+			 * fileno. Note that large offsets (> 1 gig) risk overflow in
+			 * this add...
 			 */
 			newFile = file->curFile;
 			newOffset = (file->curOffset + file->pos) + offset;
@@ -467,11 +485,12 @@ BufFileSeek(BufFile *file, int fileno, long offset, int whence)
 		newOffset >= file->curOffset &&
 		newOffset <= file->curOffset + file->nbytes)
 	{
+
 		/*
 		 * Seek is to a point within existing buffer; we can just adjust
-		 * pos-within-buffer, without flushing buffer.  Note this is OK
-		 * whether reading or writing, but buffer remains dirty if we
-		 * were writing.
+		 * pos-within-buffer, without flushing buffer.	Note this is OK
+		 * whether reading or writing, but buffer remains dirty if we were
+		 * writing.
 		 */
 		file->pos = (int) (newOffset - file->curOffset);
 		return 0;
@@ -479,10 +498,11 @@ BufFileSeek(BufFile *file, int fileno, long offset, int whence)
 	/* Otherwise, must reposition buffer, so flush any dirty data */
 	if (BufFileFlush(file) != 0)
 		return EOF;
+
 	/*
-	 * At this point and no sooner, check for seek past last segment.
-	 * The above flush could have created a new segment, so
-	 * checking sooner would not work (at least not with this code).
+	 * At this point and no sooner, check for seek past last segment. The
+	 * above flush could have created a new segment, so checking sooner
+	 * would not work (at least not with this code).
 	 */
 	if (file->isTemp)
 	{
@@ -544,7 +564,7 @@ BufFileSeekBlock(BufFile *file, long blknum)
 long
 BufFileTellBlock(BufFile *file)
 {
-	long	blknum;
+	long		blknum;
 
 	blknum = (file->curOffset + file->pos) / BLCKSZ;
 	blknum += file->curFile * RELSEG_SIZE;
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index 1fb753dbf3a393ff699aded42e0588058849355e..e3e1ff00e4c53cf5aeba781d36841a4e070b9c95 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.55 2000/04/09 04:43:19 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.56 2000/04/12 17:15:35 momjian Exp $
  *
  * NOTES:
  *
@@ -417,11 +417,11 @@ ReleaseDataFile()
 	DO_DB(elog(DEBUG, "ReleaseDataFile. Opened %d", nfile));
 
 	if (nfile <= 0)
-		return(false);
+		return (false);
 	Assert(VfdCache[0].lruMoreRecently != 0);
 	LruDelete(VfdCache[0].lruMoreRecently);
 
-	return(true);
+	return (true);
 }
 
 static File
@@ -442,12 +442,16 @@ AllocateVfd()
 
 		SizeVfdCache = 1;
 
-		/* register proc-exit call to ensure temp files are dropped at exit */
+		/*
+		 * register proc-exit call to ensure temp files are dropped at
+		 * exit
+		 */
 		on_proc_exit(AtEOXact_Files, NULL);
 	}
 
 	if (VfdCache[0].nextFree == 0)
 	{
+
 		/*
 		 * The free list is empty so it is time to increase the size of
 		 * the array.  We choose to double it each time this happens.
@@ -511,7 +515,7 @@ FreeVfd(File file)
  *
  * (Generally, this isn't actually necessary, considering that we
  * should be cd'd into the database directory.  Presently it is only
- * necessary to do it in "bootstrap" mode.  Maybe we should change
+ * necessary to do it in "bootstrap" mode.	Maybe we should change
  * bootstrap mode to do the cd, and save a few cycles/bytes here.)
  */
 static char *
@@ -562,6 +566,7 @@ FileAccess(File file)
 	}
 	else if (VfdCache[0].lruLessRecently != file)
 	{
+
 		/*
 		 * We now know that the file is open and that it is not the last
 		 * one accessed, so we need to move it to the head of the Lru
@@ -917,9 +922,11 @@ FileSync(File file)
 		returnCode = 0;
 		VfdCache[file].fdstate &= ~FD_DIRTY;
 	}
-	else 
+	else
 	{
-		/* We don't use FileAccess() because we don't want to force the
+
+		/*
+		 * We don't use FileAccess() because we don't want to force the
 		 * file to the front of the LRU ring; we aren't expecting to
 		 * access it again soon.
 		 */
@@ -941,7 +948,7 @@ FileSync(File file)
  * FileMarkDirty --- mark a file as needing fsync at transaction commit.
  *
  * Since FileWrite marks the file dirty, this routine is not needed in
- * normal use.  It is called when the buffer manager detects that some other
+ * normal use.	It is called when the buffer manager detects that some other
  * backend has written out a shared buffer that this backend dirtied (but
  * didn't write) in the current xact.  In that scenario, we need to fsync
  * the file before we can commit.  We cannot assume that the other backend
diff --git a/src/backend/storage/ipc/ipc.c b/src/backend/storage/ipc/ipc.c
index 4d217b36f24a1e8dbb7802f29683d7d8bc6997e2..27290f7dcaab0ad9f077d838ac3d1c33e0f8a7b7 100644
--- a/src/backend/storage/ipc/ipc.c
+++ b/src/backend/storage/ipc/ipc.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.45 2000/01/26 05:56:57 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.46 2000/04/12 17:15:36 momjian Exp $
  *
  * NOTES
  *
@@ -49,7 +49,7 @@
  * so that an elog() from an on_proc_exit routine cannot get us out
  * of the exit procedure.  We do NOT want to go back to the idle loop...
  */
-bool	proc_exit_inprogress = false;
+bool		proc_exit_inprogress = false;
 
 static int	UsePrivateMemory = 0;
 
@@ -78,7 +78,7 @@ typedef struct _PrivateMemStruct
 	char	   *memptr;
 } PrivateMem;
 
-static PrivateMem	IpcPrivateMem[16];
+static PrivateMem IpcPrivateMem[16];
 
 
 static int
@@ -117,6 +117,7 @@ PrivateMemoryAttach(IpcMemoryId memid)
 void
 proc_exit(int code)
 {
+
 	/*
 	 * Once we set this flag, we are committed to exit.  Any elog() will
 	 * NOT send control back to the main loop, but right back here.
@@ -140,7 +141,7 @@ proc_exit(int code)
 	 */
 	while (--on_proc_exit_index >= 0)
 		(*on_proc_exit_list[on_proc_exit_index].function) (code,
-														   on_proc_exit_list[on_proc_exit_index].arg);
+							  on_proc_exit_list[on_proc_exit_index].arg);
 
 	TPRINTF(TRACE_VERBOSE, "exit(%d)", code);
 	exit(code);
@@ -166,7 +167,7 @@ shmem_exit(int code)
 	 */
 	while (--on_shmem_exit_index >= 0)
 		(*on_shmem_exit_list[on_shmem_exit_index].function) (code,
-														   on_shmem_exit_list[on_shmem_exit_index].arg);
+							on_shmem_exit_list[on_shmem_exit_index].arg);
 
 	on_shmem_exit_index = 0;
 }
@@ -179,7 +180,7 @@ shmem_exit(int code)
  * ----------------------------------------------------------------
  */
 int
-on_proc_exit(void (*function) (), caddr_t arg)
+			on_proc_exit(void (*function) (), caddr_t arg)
 {
 	if (on_proc_exit_index >= MAX_ON_EXITS)
 		return -1;
@@ -200,7 +201,7 @@ on_proc_exit(void (*function) (), caddr_t arg)
  * ----------------------------------------------------------------
  */
 int
-on_shmem_exit(void (*function) (), caddr_t arg)
+			on_shmem_exit(void (*function) (), caddr_t arg)
 {
 	if (on_shmem_exit_index >= MAX_ON_EXITS)
 		return -1;
@@ -288,7 +289,7 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey,
 
 	/* check arguments	*/
 	if (semNum > IPC_NMAXSEM || semNum <= 0)
-		return(-1);
+		return (-1);
 
 	semId = semget(semKey, 0, 0);
 
@@ -308,7 +309,7 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey,
 					"key=%d, num=%d, permission=%o",
 					strerror(errno), semKey, semNum, permission);
 			IpcConfigTip();
-			return(-1);
+			return (-1);
 		}
 		for (i = 0; i < semNum; i++)
 			array[i] = semStartValue;
@@ -320,7 +321,7 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey,
 					strerror(errno), semId);
 			semctl(semId, 0, IPC_RMID, semun);
 			IpcConfigTip();
-			return(-1);
+			return (-1);
 		}
 
 		if (removeOnExit)
diff --git a/src/backend/storage/ipc/ipci.c b/src/backend/storage/ipc/ipci.c
index 14d7d0302bdc7afc405f6802edef471c4cf15271..12594484ece5d669f2ac16206d5bc1202310037c 100644
--- a/src/backend/storage/ipc/ipci.c
+++ b/src/backend/storage/ipc/ipci.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.32 2000/01/26 05:56:58 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.33 2000/04/12 17:15:37 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -56,14 +56,16 @@ CreateSharedMemoryAndSemaphores(IPCKey key, int maxBackends)
 {
 	int			size;
 	extern int	XLOGShmemSize(void);
-	extern void	XLOGShmemInit(void);
+	extern void XLOGShmemInit(void);
 
 #ifdef HAS_TEST_AND_SET
+
 	/*
 	 * Create shared memory for slocks
 	 */
 	CreateAndInitSLockMemory(IPCKeyGetSLockSharedMemoryKey(key));
 #endif
+
 	/*
 	 * Kill and create the buffer manager buffer pool (and semaphore)
 	 */
diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c
index 1a4d81275534dff3e39cda64a64121134a5b418d..38bf8e7c1a37c68f0d27fc16514e6ad1a1522f10 100644
--- a/src/backend/storage/ipc/shmem.c
+++ b/src/backend/storage/ipc/shmem.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.49 2000/02/26 05:25:55 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.50 2000/04/12 17:15:37 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -340,9 +340,9 @@ ShmemInitHash(char *name,		/* table string name for shmem index */
 	long	   *location;
 
 	/*
-	 * Hash tables allocated in shared memory have a fixed directory;
-	 * it can't grow or other backends wouldn't be able to find it.
-	 * So, make sure we make it big enough to start with.
+	 * Hash tables allocated in shared memory have a fixed directory; it
+	 * can't grow or other backends wouldn't be able to find it. So, make
+	 * sure we make it big enough to start with.
 	 *
 	 * The segbase is for calculating pointer values. The shared memory
 	 * allocator must be specified too.
@@ -354,7 +354,7 @@ ShmemInitHash(char *name,		/* table string name for shmem index */
 
 	/* look it up in the shmem index */
 	location = ShmemInitStruct(name,
-						 sizeof(HHDR) + infoP->dsize * sizeof(SEG_OFFSET),
+						sizeof(HHDR) + infoP->dsize * sizeof(SEG_OFFSET),
 							   &found);
 
 	/*
diff --git a/src/backend/storage/ipc/sinval.c b/src/backend/storage/ipc/sinval.c
index d19fb4a40cc41ee0bb041278261576b89539c98e..62023afa01c0bd6564dbf9062d68e595ea16e03c 100644
--- a/src/backend/storage/ipc/sinval.c
+++ b/src/backend/storage/ipc/sinval.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.20 2000/01/26 05:56:58 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.21 2000/04/12 17:15:37 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -96,8 +96,8 @@ RegisterSharedInvalid(int cacheId,		/* XXX */
 					  Index hashIndex,
 					  ItemPointer pointer)
 {
-	SharedInvalidData	newInvalid;
-	bool				insertOK;
+	SharedInvalidData newInvalid;
+	bool		insertOK;
 
 	/*
 	 * This code has been hacked to accept two types of messages.  This
@@ -121,7 +121,7 @@ RegisterSharedInvalid(int cacheId,		/* XXX */
 	SpinAcquire(SInvalLock);
 	insertOK = SIInsertDataEntry(shmInvalBuffer, &newInvalid);
 	SpinRelease(SInvalLock);
-	if (! insertOK)
+	if (!insertOK)
 		elog(NOTICE, "RegisterSharedInvalid: SI buffer overflow");
 }
 
@@ -130,12 +130,12 @@ RegisterSharedInvalid(int cacheId,		/* XXX */
  *		Process shared-cache-invalidation messages waiting for this backend
  */
 void
-InvalidateSharedInvalid(void (*invalFunction) (),
-						void (*resetFunction) ())
+			InvalidateSharedInvalid(void (*invalFunction) (),
+									void (*resetFunction) ())
 {
-	SharedInvalidData	data;
-	int					getResult;
-	bool				gotMessage = false;
+	SharedInvalidData data;
+	int			getResult;
+	bool		gotMessage = false;
 
 	for (;;)
 	{
@@ -171,13 +171,13 @@ InvalidateSharedInvalid(void (*invalFunction) (),
 
 
 /****************************************************************************/
-/* Functions that need to scan the PROC structures of all running backends.	*/
+/* Functions that need to scan the PROC structures of all running backends. */
 /* It's a bit strange to keep these in sinval.c, since they don't have any	*/
 /* direct relationship to shared-cache invalidation.  But the procState		*/
 /* array in the SI segment is the only place in the system where we have	*/
-/* an array of per-backend data, so it is the most convenient place to keep	*/
+/* an array of per-backend data, so it is the most convenient place to keep */
 /* pointers to the backends' PROC structures.  We used to implement these	*/
-/* functions with a slow, ugly search through the ShmemIndex hash table ---	*/
+/* functions with a slow, ugly search through the ShmemIndex hash table --- */
 /* now they are simple loops over the SI ProcState array.					*/
 /****************************************************************************/
 
@@ -205,7 +205,7 @@ DatabaseHasActiveBackends(Oid databaseId)
 
 	for (index = 0; index < segP->maxBackends; index++)
 	{
-		SHMEM_OFFSET	pOffset = stateP[index].procStruct;
+		SHMEM_OFFSET pOffset = stateP[index].procStruct;
 
 		if (pOffset != INVALID_OFFSET)
 		{
@@ -239,7 +239,7 @@ TransactionIdIsInProgress(TransactionId xid)
 
 	for (index = 0; index < segP->maxBackends; index++)
 	{
-		SHMEM_OFFSET	pOffset = stateP[index].procStruct;
+		SHMEM_OFFSET pOffset = stateP[index].procStruct;
 
 		if (pOffset != INVALID_OFFSET)
 		{
@@ -277,14 +277,15 @@ GetXmaxRecent(TransactionId *XmaxRecent)
 
 	for (index = 0; index < segP->maxBackends; index++)
 	{
-		SHMEM_OFFSET	pOffset = stateP[index].procStruct;
+		SHMEM_OFFSET pOffset = stateP[index].procStruct;
 
 		if (pOffset != INVALID_OFFSET)
 		{
 			PROC	   *proc = (PROC *) MAKE_PTR(pOffset);
 			TransactionId xmin;
 
-			xmin = proc->xmin;	/* we don't use spin-locking in AbortTransaction() ! */
+			xmin = proc->xmin;	/* we don't use spin-locking in
+								 * AbortTransaction() ! */
 			if (proc == MyProc || xmin < FirstTransactionId)
 				continue;
 			if (xmin < *XmaxRecent)
@@ -307,8 +308,9 @@ GetSnapshotData(bool serializable)
 	int			index;
 	int			count = 0;
 
-	/* There can be no more than maxBackends active transactions,
-	 * so this is enough space:
+	/*
+	 * There can be no more than maxBackends active transactions, so this
+	 * is enough space:
 	 */
 	snapshot->xip = (TransactionId *)
 		malloc(segP->maxBackends * sizeof(TransactionId));
@@ -317,8 +319,8 @@ GetSnapshotData(bool serializable)
 	SpinAcquire(SInvalLock);
 
 	/*
-	 * Unfortunately, we have to call ReadNewTransactionId()
-	 * after acquiring SInvalLock above. It's not good because
+	 * Unfortunately, we have to call ReadNewTransactionId() after
+	 * acquiring SInvalLock above. It's not good because
 	 * ReadNewTransactionId() does SpinAcquire(OidGenLockId) but
 	 * _necessary_.
 	 */
@@ -326,26 +328,27 @@ GetSnapshotData(bool serializable)
 
 	for (index = 0; index < segP->maxBackends; index++)
 	{
-		SHMEM_OFFSET	pOffset = stateP[index].procStruct;
+		SHMEM_OFFSET pOffset = stateP[index].procStruct;
 
 		if (pOffset != INVALID_OFFSET)
 		{
 			PROC	   *proc = (PROC *) MAKE_PTR(pOffset);
 			TransactionId xid;
 
-			/* 
-			 * We don't use spin-locking when changing proc->xid 
-			 * in GetNewTransactionId() and in AbortTransaction() !..
+			/*
+			 * We don't use spin-locking when changing proc->xid in
+			 * GetNewTransactionId() and in AbortTransaction() !..
 			 */
 			xid = proc->xid;
-			if (proc == MyProc || 
+			if (proc == MyProc ||
 				xid < FirstTransactionId || xid >= snapshot->xmax)
 			{
+
 				/*
-				 * Seems that there is no sense to store xid >= snapshot->xmax
-				 * (what we got from ReadNewTransactionId above) in
-				 * snapshot->xip - we just assume that all xacts with such
-				 * xid-s are running and may be ignored.
+				 * Seems that there is no sense to store xid >=
+				 * snapshot->xmax (what we got from ReadNewTransactionId
+				 * above) in snapshot->xip - we just assume that all xacts
+				 * with such xid-s are running and may be ignored.
 				 */
 				continue;
 			}
diff --git a/src/backend/storage/ipc/sinvaladt.c b/src/backend/storage/ipc/sinvaladt.c
index 5075323728f41cf728acf61290da586cb3295eb0..937a9ca0938d7d89d678acd352c73c66922d6efb 100644
--- a/src/backend/storage/ipc/sinvaladt.c
+++ b/src/backend/storage/ipc/sinvaladt.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.29 2000/03/17 02:36:21 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.30 2000/04/12 17:15:37 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -53,8 +53,9 @@ SISegmentInit(bool createNewSegment, IPCKey key, int maxBackends)
 		/* Kill existing segment, if any */
 		IpcMemoryKill(key);
 
-		/* Figure space needed.
-		 * Note sizeof(SISeg) includes the first ProcState entry.
+		/*
+		 * Figure space needed. Note sizeof(SISeg) includes the first
+		 * ProcState entry.
 		 */
 		segSize = sizeof(SISeg) + sizeof(ProcState) * (maxBackends - 1);
 
@@ -125,7 +126,7 @@ SISegInit(SISeg *segP, int maxBackends)
 	/* Mark all backends inactive */
 	for (i = 0; i < maxBackends; i++)
 	{
-		segP->procState[i].nextMsgNum = -1;	/* inactive */
+		segP->procState[i].nextMsgNum = -1;		/* inactive */
 		segP->procState[i].resetState = false;
 		segP->procState[i].tag = InvalidBackendTag;
 		segP->procState[i].procStruct = INVALID_OFFSET;
@@ -143,8 +144,8 @@ SISegInit(SISeg *segP, int maxBackends)
 int
 SIBackendInit(SISeg *segP)
 {
-	int		index;
-	ProcState      *stateP = NULL;
+	int			index;
+	ProcState  *stateP = NULL;
 
 	Assert(MyBackendTag > 0);
 
@@ -165,7 +166,8 @@ SIBackendInit(SISeg *segP)
 		}
 	}
 
-	/* elog() with spinlock held is probably not too cool, but this
+	/*
+	 * elog() with spinlock held is probably not too cool, but this
 	 * condition should never happen anyway.
 	 */
 	if (stateP == NULL)
@@ -230,11 +232,12 @@ CleanupInvalidationState(int status,
 bool
 SIInsertDataEntry(SISeg *segP, SharedInvalidData *data)
 {
-	int		numMsgs = segP->maxMsgNum - segP->minMsgNum;
+	int			numMsgs = segP->maxMsgNum - segP->minMsgNum;
 
 	/* Is the buffer full? */
 	if (numMsgs >= MAXNUMMESSAGES)
 	{
+
 		/*
 		 * Don't panic just yet: slowest backend might have consumed some
 		 * messages but not yet have done SIDelExpiredDataEntries() to
@@ -254,8 +257,9 @@ SIInsertDataEntry(SISeg *segP, SharedInvalidData *data)
 	 * Try to prevent table overflow.  When the table is 70% full send a
 	 * SIGUSR2 (ordinarily a NOTIFY signal) to the postmaster, which will
 	 * send it back to all the backends.  This will force idle backends to
-	 * execute a transaction to look through pg_listener for NOTIFY messages,
-	 * and as a byproduct of the transaction start they will read SI entries.
+	 * execute a transaction to look through pg_listener for NOTIFY
+	 * messages, and as a byproduct of the transaction start they will
+	 * read SI entries.
 	 *
 	 * This should never happen if all the backends are actively executing
 	 * queries, but if a backend is sitting idle then it won't be starting
@@ -267,7 +271,7 @@ SIInsertDataEntry(SISeg *segP, SharedInvalidData *data)
 		IsUnderPostmaster)
 	{
 		TPRINTF(TRACE_VERBOSE,
-				"SIInsertDataEntry: table is 70%% full, signaling postmaster");
+		  "SIInsertDataEntry: table is 70%% full, signaling postmaster");
 		kill(getppid(), SIGUSR2);
 	}
 
@@ -296,7 +300,7 @@ SISetProcStateInvalid(SISeg *segP)
 
 	for (i = 0; i < segP->maxBackends; i++)
 	{
-		if (segP->procState[i].nextMsgNum >= 0)	/* active backend? */
+		if (segP->procState[i].nextMsgNum >= 0) /* active backend? */
 		{
 			segP->procState[i].resetState = true;
 			segP->procState[i].nextMsgNum = 0;
@@ -318,13 +322,15 @@ int
 SIGetDataEntry(SISeg *segP, int backendId,
 			   SharedInvalidData *data)
 {
-	ProcState  *stateP = & segP->procState[backendId - 1];
+	ProcState  *stateP = &segP->procState[backendId - 1];
 
 	Assert(stateP->tag == MyBackendTag);
 
 	if (stateP->resetState)
 	{
-		/* Force reset.  We can say we have dealt with any messages added
+
+		/*
+		 * Force reset.  We can say we have dealt with any messages added
 		 * since the reset, as well...
 		 */
 		stateP->resetState = false;
@@ -341,9 +347,10 @@ SIGetDataEntry(SISeg *segP, int backendId,
 	*data = segP->buffer[stateP->nextMsgNum % MAXNUMMESSAGES];
 	stateP->nextMsgNum++;
 
-	/* There may be other backends that haven't read the message,
-	 * so we cannot delete it here.
-	 * SIDelExpiredDataEntries() should be called to remove dead messages.
+	/*
+	 * There may be other backends that haven't read the message, so we
+	 * cannot delete it here. SIDelExpiredDataEntries() should be called
+	 * to remove dead messages.
 	 */
 	return 1;					/* got a message */
 }
@@ -376,8 +383,9 @@ SIDelExpiredDataEntries(SISeg *segP)
 	}
 	segP->minMsgNum = min;
 
-	/* When minMsgNum gets really large, decrement all message counters
-	 * so as to forestall overflow of the counters.
+	/*
+	 * When minMsgNum gets really large, decrement all message counters so
+	 * as to forestall overflow of the counters.
 	 */
 	if (min >= MSGNUMWRAPAROUND)
 	{
diff --git a/src/backend/storage/ipc/spin.c b/src/backend/storage/ipc/spin.c
index 2892ca13a497652a8cd97317aa142645a06f23e3..bab3d27b9ca701fa60b49dc4318c679afbf8e9dd 100644
--- a/src/backend/storage/ipc/spin.c
+++ b/src/backend/storage/ipc/spin.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/spin.c,v 1.23 2000/04/12 04:58:09 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/spin.c,v 1.24 2000/04/12 17:15:37 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -59,7 +59,8 @@ InitSpinLocks(void)
 	extern SPINLOCK SInvalLock;
 	extern SPINLOCK OidGenLockId;
 	extern SPINLOCK XidGenLockId;
-	extern SPINLOCK	ControlFileLockId;
+	extern SPINLOCK ControlFileLockId;
+
 #ifdef STABLE_MEMORY_STORAGE
 	extern SPINLOCK MMCacheLock;
 
@@ -233,7 +234,7 @@ CreateSpinlocks(IPCKey key)
 {
 
 	SpinLockId = IpcSemaphoreCreate(key, MAX_SPINS, IPCProtection,
-							   IpcSemaphoreDefaultStartValue, 1);
+									IpcSemaphoreDefaultStartValue, 1);
 
 	if (SpinLockId <= 0)
 		elog(STOP, "CreateSpinlocks: cannot create spin locks");
@@ -264,7 +265,7 @@ InitSpinLocks(void)
 	extern SPINLOCK SInvalLock;
 	extern SPINLOCK OidGenLockId;
 	extern SPINLOCK XidGenLockId;
-	extern SPINLOCK	ControlFileLockId;
+	extern SPINLOCK ControlFileLockId;
 
 #ifdef STABLE_MEMORY_STORAGE
 	extern SPINLOCK MMCacheLock;
diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c
index e5c1f56dac8f76b766d9ee68c337065b2666b724..38961ff34c19032174c9196f5a02c00223f79f86 100644
--- a/src/backend/storage/large_object/inv_api.c
+++ b/src/backend/storage/large_object/inv_api.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.66 2000/04/08 04:37:07 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.67 2000/04/12 17:15:37 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -289,7 +289,8 @@ inv_drop(Oid lobjId)
 		return -1;
 	}
 
-	/* Since heap_drop_with_catalog will destroy the relcache entry,
+	/*
+	 * Since heap_drop_with_catalog will destroy the relcache entry,
 	 * there's no need to drop the refcount in this path.
 	 */
 	heap_drop_with_catalog(RelationGetRelationName(r));
diff --git a/src/backend/storage/lmgr/lmgr.c b/src/backend/storage/lmgr/lmgr.c
index 7152db297ea10d122f93f39f01d99fb15f2d8973..44a74e8591fdae22ae4ca62648bf814e76485baa 100644
--- a/src/backend/storage/lmgr/lmgr.c
+++ b/src/backend/storage/lmgr/lmgr.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.38 2000/01/26 05:57:00 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.39 2000/04/12 17:15:38 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -145,14 +145,14 @@ LockRelation(Relation relation, LOCKMODE lockmode)
 	tag.dbId = relation->rd_lockInfo.lockRelId.dbId;
 	tag.objId.blkno = InvalidBlockNumber;
 
-	if (! LockAcquire(LockTableId, &tag, lockmode))
+	if (!LockAcquire(LockTableId, &tag, lockmode))
 		elog(ERROR, "LockRelation: LockAcquire failed");
 
 	/*
-	 * Check to see if the relcache entry has been invalidated
-	 * while we were waiting to lock it.  If so, rebuild it,
-	 * or elog() trying.  Increment the refcount to ensure that
-	 * RelationFlushRelation will rebuild it and not just delete it.
+	 * Check to see if the relcache entry has been invalidated while we
+	 * were waiting to lock it.  If so, rebuild it, or elog() trying.
+	 * Increment the refcount to ensure that RelationFlushRelation will
+	 * rebuild it and not just delete it.
 	 */
 	RelationIncrementReferenceCount(relation);
 	DiscardInvalid();
@@ -194,7 +194,7 @@ LockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode)
 	tag.dbId = relation->rd_lockInfo.lockRelId.dbId;
 	tag.objId.blkno = blkno;
 
-	if (! LockAcquire(LockTableId, &tag, lockmode))
+	if (!LockAcquire(LockTableId, &tag, lockmode))
 		elog(ERROR, "LockPage: LockAcquire failed");
 }
 
@@ -230,7 +230,7 @@ XactLockTableInsert(TransactionId xid)
 	tag.dbId = InvalidOid;
 	tag.objId.xid = xid;
 
-	if (! LockAcquire(LockTableId, &tag, ExclusiveLock))
+	if (!LockAcquire(LockTableId, &tag, ExclusiveLock))
 		elog(ERROR, "XactLockTableInsert: LockAcquire failed");
 }
 
@@ -263,7 +263,7 @@ XactLockTableWait(TransactionId xid)
 	tag.dbId = InvalidOid;
 	tag.objId.xid = xid;
 
-	if (! LockAcquire(LockTableId, &tag, ShareLock))
+	if (!LockAcquire(LockTableId, &tag, ShareLock))
 		elog(ERROR, "XactLockTableWait: LockAcquire failed");
 
 	LockRelease(LockTableId, &tag, ShareLock);
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
index 82b40a333ce80e0c5f11d2084f31b77719561bc7..de161517239f68ce0ace6d873da2072b435fd8bc 100644
--- a/src/backend/storage/lmgr/proc.c
+++ b/src/backend/storage/lmgr/proc.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.71 2000/04/10 00:45:42 inoue Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.72 2000/04/12 17:15:38 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -47,7 +47,7 @@
  *		This is so that we can support more backends. (system-wide semaphore
  *		sets run out pretty fast.)				  -ay 4/95
  *
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.71 2000/04/10 00:45:42 inoue Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.72 2000/04/12 17:15:38 momjian Exp $
  */
 #include <sys/time.h>
 #include <unistd.h>
@@ -72,7 +72,7 @@
 #include "storage/proc.h"
 #include "utils/trace.h"
 
-void HandleDeadLock(SIGNAL_ARGS);
+void		HandleDeadLock(SIGNAL_ARGS);
 static void ProcFreeAllSemaphores(void);
 static bool GetOffWaitqueue(PROC *);
 
@@ -320,11 +320,13 @@ InitProcess(IPCKey key)
 static bool
 GetOffWaitqueue(PROC *proc)
 {
-	bool	getoffed = false;
+	bool		getoffed = false;
+
 	LockLockTable();
 	if (proc->links.next != INVALID_OFFSET)
 	{
-		int	lockmode = proc->token;
+		int			lockmode = proc->token;
+
 		Assert(proc->waitLock->waitProcs.size > 0);
 		SHMQueueDelete(&(proc->links));
 		--proc->waitLock->waitProcs.size;
@@ -343,6 +345,7 @@ GetOffWaitqueue(PROC *proc)
 
 	return getoffed;
 }
+
 /*
  * ProcReleaseLocks() -- release all locks associated with this process
  *
@@ -485,8 +488,9 @@ ProcQueueInit(PROC_QUEUE *queue)
  *	Handling cancel request while waiting for lock
  *
  */
-static bool	lockWaiting = false;
-void	SetWaitingForLock(bool waiting)
+static bool lockWaiting = false;
+void
+SetWaitingForLock(bool waiting)
 {
 	if (waiting == lockWaiting)
 		return;
@@ -499,7 +503,7 @@ void	SetWaitingForLock(bool waiting)
 			lockWaiting = false;
 			return;
 		}
-		if (QueryCancel) /* cancel request pending */
+		if (QueryCancel)		/* cancel request pending */
 		{
 			if (GetOffWaitqueue(MyProc))
 			{
@@ -509,11 +513,14 @@ void	SetWaitingForLock(bool waiting)
 		}
 	}
 }
-void	LockWaitCancel(void)
+void
+LockWaitCancel(void)
 {
-	struct itimerval timeval, dummy;
+	struct itimerval timeval,
+				dummy;
 
-	if (!lockWaiting)	return;
+	if (!lockWaiting)
+		return;
 	lockWaiting = false;
 	/* Deadlock timer off */
 	MemSet(&timeval, 0, sizeof(struct itimerval));
diff --git a/src/backend/storage/page/bufpage.c b/src/backend/storage/page/bufpage.c
index c5f03f9e9ff386c892b16e253d2b79904a6a86c4..f25faf180c39421a7f77d5040523db7956f535a4 100644
--- a/src/backend/storage/page/bufpage.c
+++ b/src/backend/storage/page/bufpage.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.28 2000/01/26 05:57:04 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.29 2000/04/12 17:15:40 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -40,7 +40,7 @@ PageInit(Page page, Size pageSize, Size specialSize)
 
 	Assert(pageSize == BLCKSZ);
 	Assert(pageSize >
-			 specialSize + sizeof(PageHeaderData) - sizeof(ItemIdData));
+		   specialSize + sizeof(PageHeaderData) - sizeof(ItemIdData));
 
 	specialSize = MAXALIGN(specialSize);
 
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
index b30b0386af8fc482fd00ff8490eea6d46449c7f9..e4fee43220520fcc1583042eea976425886bc8ba 100644
--- a/src/backend/storage/smgr/md.c
+++ b/src/backend/storage/smgr/md.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.66 2000/04/10 23:41:51 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.67 2000/04/12 17:15:41 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -21,7 +21,8 @@
 #include "catalog/catalog.h"
 #include "miscadmin.h"
 #include "storage/smgr.h"
-#include "utils/inval.h"	/* ImmediateSharedRelationCacheInvalidate() */
+#include "utils/inval.h"		/* ImmediateSharedRelationCacheInvalidate()
+								 * */
 
 #undef DIAGNOSTIC
 
@@ -62,17 +63,18 @@ typedef struct _MdfdVec
 
 static int	Nfds = 100;			/* initial/current size of Md_fdvec array */
 static MdfdVec *Md_fdvec = (MdfdVec *) NULL;
-static int	Md_Free = -1;		/* head of freelist of unused fdvec entries */
+static int	Md_Free = -1;		/* head of freelist of unused fdvec
+								 * entries */
 static int	CurFd = 0;			/* first never-used fdvec index */
 static MemoryContext MdCxt;		/* context for all my allocations */
 
 /* routines declared here */
 static void mdclose_fd(int fd);
-static int _mdfd_getrelnfd(Relation reln);
+static int	_mdfd_getrelnfd(Relation reln);
 static MdfdVec *_mdfd_openseg(Relation reln, int segno, int oflags);
 static MdfdVec *_mdfd_getseg(Relation reln, int blkno);
 static int _mdfd_blind_getseg(char *dbname, char *relname,
-							  Oid dbid, Oid relid, int blkno);
+				   Oid dbid, Oid relid, int blkno);
 static int	_fdvec_alloc(void);
 static void _fdvec_free(int);
 static BlockNumber _mdnblocks(File file, Size blcksz);
@@ -140,11 +142,10 @@ mdcreate(Relation reln)
 	 * are processed.
 	 *
 	 * For cataloged relations,pg_class is guaranteed to have an unique
-	 * record with the same relname by the unique index.
-	 * So we are able to reuse existent files for new catloged relations.
-	 * Currently we reuse them in the following cases.
-	 * 1. they are empty.
-	 * 2. they are used for Index relations and their size == BLCKSZ * 2.
+	 * record with the same relname by the unique index. So we are able to
+	 * reuse existent files for new catloged relations. Currently we reuse
+	 * them in the following cases. 1. they are empty. 2. they are used
+	 * for Index relations and their size == BLCKSZ * 2.
 	 */
 
 	if (fd < 0)
@@ -162,13 +163,13 @@ mdcreate(Relation reln)
 			return -1;
 		if (!IsBootstrapProcessingMode())
 		{
-			bool	reuse = false;	
-			int	len = FileSeek(fd, 0L, SEEK_END);
+			bool		reuse = false;
+			int			len = FileSeek(fd, 0L, SEEK_END);
 
 			if (len == 0)
 				reuse = true;
 			else if (reln->rd_rel->relkind == RELKIND_INDEX &&
-				 len == BLCKSZ * 2)
+					 len == BLCKSZ * 2)
 				reuse = true;
 			if (!reuse)
 			{
@@ -206,14 +207,15 @@ mdunlink(Relation reln)
 	MdfdVec    *v;
 	MemoryContext oldcxt;
 
-	/* If the relation is already unlinked,we have nothing to do
-	 * any more.
+	/*
+	 * If the relation is already unlinked,we have nothing to do any more.
 	 */
 	if (reln->rd_unlinked && reln->rd_fd < 0)
 		return SM_SUCCESS;
+
 	/*
-	 * Force all segments of the relation to be opened, so that we
-	 * won't miss deleting any of them.
+	 * Force all segments of the relation to be opened, so that we won't
+	 * miss deleting any of them.
 	 */
 	nblocks = mdnblocks(reln);
 
@@ -222,9 +224,10 @@ mdunlink(Relation reln)
 	 *
 	 * NOTE: We truncate the file(s) before deleting 'em, because if other
 	 * backends are holding the files open, the unlink will fail on some
-	 * platforms (think Microsoft).  Better a zero-size file gets left around
-	 * than a big file.  Those other backends will be forced to close the
-	 * relation by cache invalidation, but that probably hasn't happened yet.
+	 * platforms (think Microsoft).  Better a zero-size file gets left
+	 * around than a big file.	Those other backends will be forced to
+	 * close the relation by cache invalidation, but that probably hasn't
+	 * happened yet.
 	 */
 	fd = RelationGetFile(reln);
 	if (fd < 0)					/* should not happen */
@@ -237,6 +240,7 @@ mdunlink(Relation reln)
 	for (v = &Md_fdvec[fd]; v != (MdfdVec *) NULL;)
 	{
 		MdfdVec    *ov = v;
+
 		FileTruncate(v->mdfd_vfd, 0);
 		FileUnlink(v->mdfd_vfd);
 		v = v->mdfd_chain;
@@ -269,7 +273,8 @@ mdunlink(Relation reln)
 int
 mdextend(Relation reln, char *buffer)
 {
-	long		pos, nbytes;
+	long		pos,
+				nbytes;
 	int			nblocks;
 	MdfdVec    *v;
 
@@ -279,7 +284,7 @@ mdextend(Relation reln, char *buffer)
 	if ((pos = FileSeek(v->mdfd_vfd, 0L, SEEK_END)) < 0)
 		return SM_FAIL;
 
-	if (pos % BLCKSZ != 0) /* the last block is incomplete */
+	if (pos % BLCKSZ != 0)		/* the last block is incomplete */
 	{
 		pos -= pos % BLCKSZ;
 		if (FileSeek(v->mdfd_vfd, pos, SEEK_SET) < 0)
@@ -414,6 +419,7 @@ mdclose_fd(int fd)
 		/* if not closed already */
 		if (v->mdfd_vfd >= 0)
 		{
+
 			/*
 			 * We sync the file descriptor so that we don't need to reopen
 			 * it at transaction commit to force changes to disk.  (This
@@ -436,6 +442,7 @@ mdclose_fd(int fd)
 	{
 		if (v->mdfd_vfd >= 0)
 		{
+
 			/*
 			 * We sync the file descriptor so that we don't need to reopen
 			 * it at transaction commit to force changes to disk.  (This
@@ -689,9 +696,11 @@ mdnblocks(Relation reln)
 {
 	int			fd;
 	MdfdVec    *v;
+
 #ifndef LET_OS_MANAGE_FILESIZE
 	int			nblocks;
 	int			segno;
+
 #endif
 
 	fd = _mdfd_getrelnfd(reln);
@@ -738,13 +747,16 @@ mdtruncate(Relation reln, int nblocks)
 	int			curnblk;
 	int			fd;
 	MdfdVec    *v;
+
 #ifndef LET_OS_MANAGE_FILESIZE
 	MemoryContext oldcxt;
 	int			priorblocks;
+
 #endif
 
-	/* NOTE: mdnblocks makes sure we have opened all existing segments,
-	 * so that truncate/delete loop will get them all!
+	/*
+	 * NOTE: mdnblocks makes sure we have opened all existing segments, so
+	 * that truncate/delete loop will get them all!
 	 */
 	curnblk = mdnblocks(reln);
 	if (nblocks < 0 || nblocks > curnblk)
@@ -764,29 +776,34 @@ mdtruncate(Relation reln, int nblocks)
 
 		if (priorblocks > nblocks)
 		{
-			/* This segment is no longer wanted at all (and has already been
-			 * unlinked from the mdfd_chain).
-			 * We truncate the file before deleting it because if other
-			 * backends are holding the file open, the unlink will fail on
-			 * some platforms.  Better a zero-size file gets left around than
-			 * a big file...
+
+			/*
+			 * This segment is no longer wanted at all (and has already
+			 * been unlinked from the mdfd_chain). We truncate the file
+			 * before deleting it because if other backends are holding
+			 * the file open, the unlink will fail on some platforms.
+			 * Better a zero-size file gets left around than a big file...
 			 */
 			FileTruncate(v->mdfd_vfd, 0);
 			FileUnlink(v->mdfd_vfd);
 			v = v->mdfd_chain;
-			Assert(ov != &Md_fdvec[fd]); /* we never drop the 1st segment */
+			Assert(ov != &Md_fdvec[fd]);		/* we never drop the 1st
+												 * segment */
 			pfree(ov);
 		}
 		else if (priorblocks + RELSEG_SIZE > nblocks)
 		{
-			/* This is the last segment we want to keep.
-			 * Truncate the file to the right length, and clear chain link
-			 * that points to any remaining segments (which we shall zap).
-			 * NOTE: if nblocks is exactly a multiple K of RELSEG_SIZE,
-			 * we will truncate the K+1st segment to 0 length but keep it.
-			 * This is mainly so that the right thing happens if nblocks=0.
+
+			/*
+			 * This is the last segment we want to keep. Truncate the file
+			 * to the right length, and clear chain link that points to
+			 * any remaining segments (which we shall zap). NOTE: if
+			 * nblocks is exactly a multiple K of RELSEG_SIZE, we will
+			 * truncate the K+1st segment to 0 length but keep it. This is
+			 * mainly so that the right thing happens if nblocks=0.
 			 */
-			int lastsegblocks = nblocks - priorblocks;
+			int			lastsegblocks = nblocks - priorblocks;
+
 			if (FileTruncate(v->mdfd_vfd, lastsegblocks * BLCKSZ) < 0)
 				return -1;
 			v->mdfd_lstbcnt = lastsegblocks;
@@ -795,7 +812,9 @@ mdtruncate(Relation reln, int nblocks)
 		}
 		else
 		{
-			/* We still need this segment and 0 or more blocks beyond it,
+
+			/*
+			 * We still need this segment and 0 or more blocks beyond it,
 			 * so nothing to do here.
 			 */
 			v = v->mdfd_chain;
@@ -842,7 +861,7 @@ mdcommit()
 			continue;
 		/* Sync the file entry */
 #ifndef LET_OS_MANAGE_FILESIZE
-		for ( ; v != (MdfdVec *) NULL; v = v->mdfd_chain)
+		for (; v != (MdfdVec *) NULL; v = v->mdfd_chain)
 #else
 		if (v != (MdfdVec *) NULL)
 #endif
@@ -853,7 +872,7 @@ mdcommit()
 	}
 
 	return SM_SUCCESS;
-#endif	/* XLOG */
+#endif	 /* XLOG */
 }
 
 /*
@@ -865,7 +884,9 @@ mdcommit()
 int
 mdabort()
 {
-	/* We don't actually have to do anything here.  fd.c will discard
+
+	/*
+	 * We don't actually have to do anything here.  fd.c will discard
 	 * fsync-needed bits in its AtEOXact_Files() routine.
 	 */
 	return SM_SUCCESS;
@@ -1073,8 +1094,10 @@ _mdfd_blind_getseg(char *dbname, char *relname, Oid dbid, Oid relid,
 {
 	char	   *path;
 	int			fd;
+
 #ifndef LET_OS_MANAGE_FILESIZE
 	int			segno;
+
 #endif
 
 	/* construct the path to the relation */
@@ -1085,7 +1108,7 @@ _mdfd_blind_getseg(char *dbname, char *relname, Oid dbid, Oid relid,
 	segno = blkno / RELSEG_SIZE;
 	if (segno > 0)
 	{
-		char   *segpath = (char *) palloc(strlen(path) + 12);
+		char	   *segpath = (char *) palloc(strlen(path) + 12);
 
 		sprintf(segpath, "%s.%d", path, segno);
 		pfree(path);
@@ -1110,6 +1133,7 @@ _mdnblocks(File file, Size blcksz)
 	long		len;
 
 	len = FileSeek(file, 0L, SEEK_END);
-	if (len < 0) return 0;	/* on failure, assume file is empty */
+	if (len < 0)
+		return 0;				/* on failure, assume file is empty */
 	return (BlockNumber) (len / blcksz);
 }
diff --git a/src/backend/storage/smgr/smgr.c b/src/backend/storage/smgr/smgr.c
index 27cad952aeb57149eea765e86b49bbb38efe7634..3b857cd3196e61c839ba9c148ba73cf69f95bf0d 100644
--- a/src/backend/storage/smgr/smgr.c
+++ b/src/backend/storage/smgr/smgr.c
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.34 2000/04/10 23:41:52 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.35 2000/04/12 17:15:42 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -23,31 +23,31 @@ static void smgrshutdown(int dummy);
 
 typedef struct f_smgr
 {
-	int			(*smgr_init) (void); /* may be NULL */
-	int			(*smgr_shutdown) (void); /* may be NULL */
+	int			(*smgr_init) (void);	/* may be NULL */
+	int			(*smgr_shutdown) (void);		/* may be NULL */
 	int			(*smgr_create) (Relation reln);
 	int			(*smgr_unlink) (Relation reln);
 	int			(*smgr_extend) (Relation reln, char *buffer);
 	int			(*smgr_open) (Relation reln);
 	int			(*smgr_close) (Relation reln);
 	int			(*smgr_read) (Relation reln, BlockNumber blocknum,
-							  char *buffer);
+										  char *buffer);
 	int			(*smgr_write) (Relation reln, BlockNumber blocknum,
-							   char *buffer);
+										   char *buffer);
 	int			(*smgr_flush) (Relation reln, BlockNumber blocknum,
-							   char *buffer);
+										   char *buffer);
 	int			(*smgr_blindwrt) (char *dbname, char *relname,
-								  Oid dbid, Oid relid,
-								  BlockNumber blkno, char *buffer,
-								  bool dofsync);
+											  Oid dbid, Oid relid,
+										 BlockNumber blkno, char *buffer,
+											  bool dofsync);
 	int			(*smgr_markdirty) (Relation reln, BlockNumber blkno);
 	int			(*smgr_blindmarkdirty) (char *dbname, char *relname,
-										Oid dbid, Oid relid,
-										BlockNumber blkno);
+													Oid dbid, Oid relid,
+													BlockNumber blkno);
 	int			(*smgr_nblocks) (Relation reln);
 	int			(*smgr_truncate) (Relation reln, int nblocks);
-	int			(*smgr_commit) (void); /* may be NULL */
-	int			(*smgr_abort) (void); /* may be NULL */
+	int			(*smgr_commit) (void);	/* may be NULL */
+	int			(*smgr_abort) (void);	/* may be NULL */
 } f_smgr;
 
 /*
@@ -59,14 +59,14 @@ static f_smgr smgrsw[] = {
 
 	/* magnetic disk */
 	{mdinit, NULL, mdcreate, mdunlink, mdextend, mdopen, mdclose,
-	 mdread, mdwrite, mdflush, mdblindwrt, mdmarkdirty, mdblindmarkdirty,
-	 mdnblocks, mdtruncate, mdcommit, mdabort},
+		mdread, mdwrite, mdflush, mdblindwrt, mdmarkdirty, mdblindmarkdirty,
+	mdnblocks, mdtruncate, mdcommit, mdabort},
 
 #ifdef STABLE_MEMORY_STORAGE
 	/* main memory */
 	{mminit, mmshutdown, mmcreate, mmunlink, mmextend, mmopen, mmclose,
-	 mmread, mmwrite, mmflush, mmblindwrt, mmmarkdirty, mmblindmarkdirty,
-	 mmnblocks, NULL, mmcommit, mmabort},
+		mmread, mmwrite, mmflush, mmblindwrt, mmmarkdirty, mmblindmarkdirty,
+	mmnblocks, NULL, mmcommit, mmabort},
 
 #endif
 };
@@ -178,7 +178,7 @@ smgrextend(int16 which, Relation reln, char *buffer)
 
 	if (status == SM_FAIL)
 		elog(ERROR, "%s: cannot extend.  Check free disk space.",
-				RelationGetRelationName(reln));
+			 RelationGetRelationName(reln));
 
 	return status;
 }
@@ -209,7 +209,7 @@ smgropen(int16 which, Relation reln)
  *		This is currently called only from RelationFlushRelation() when
  *		the relation cache entry is about to be dropped; could be doing
  *		simple relation cache clear, or finishing up DROP TABLE.
- *		
+ *
  *		Returns SM_SUCCESS on success, aborts on failure.
  */
 int
@@ -294,7 +294,7 @@ smgrflush(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
  *		this case, the buffer manager will call smgrblindwrt() with
  *		the name and OID of the database and the relation to which the
  *		buffer belongs.  Every storage manager must be able to force
- *		this page down to stable storage in this circumstance.  The
+ *		this page down to stable storage in this circumstance.	The
  *		write should be synchronous if dofsync is true.
  */
 int
@@ -403,7 +403,7 @@ smgrnblocks(int16 which, Relation reln)
 
 	if ((nblocks = (*(smgrsw[which].smgr_nblocks)) (reln)) < 0)
 		elog(ERROR, "cannot count blocks for %s",
-				RelationGetRelationName(reln));
+			 RelationGetRelationName(reln));
 
 	return nblocks;
 }
diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c
index 213e54af68415703dab57a4b5c62b639997818c4..1b38fe7ed08e4098bf99e10abf944c6461f7cc64 100644
--- a/src/backend/tcop/fastpath.c
+++ b/src/backend/tcop/fastpath.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.37 2000/01/26 05:57:07 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.38 2000/04/12 17:15:43 momjian Exp $
  *
  * NOTES
  *	  This cruft is the server side of PQfn.
@@ -302,10 +302,10 @@ HandleFunctionRequest()
 		update_fp_info(fid, fip);
 
 	/*
-	 * XXX FIXME: elog() here means we lose sync with the frontend,
-	 * since we have not swallowed all of its input message.  What
-	 * should happen is we absorb all of the input message per protocol
-	 * syntax, and *then* do error checking and elog if appropriate.
+	 * XXX FIXME: elog() here means we lose sync with the frontend, since
+	 * we have not swallowed all of its input message.	What should happen
+	 * is we absorb all of the input message per protocol syntax, and
+	 * *then* do error checking and elog if appropriate.
 	 */
 
 	if (fip->nargs != nargs)
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 402725efb51eee6c15e941521e576050b5d34564..c9bfcad00d8c9e345558a776d5214eba2c16b3db 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.150 2000/04/04 23:52:50 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.151 2000/04/12 17:15:43 momjian Exp $
  *
  * NOTES
  *	  this is the "main" module of the postgres backend and
@@ -101,14 +101,14 @@ CommandDest whereToSendOutput = Debug;
 PS_DEFINE_BUFFER;
 #endif
 
-extern void		BaseInit(void);
-extern void		StartupXLOG(void);
-extern void		ShutdownXLOG(void);
+extern void BaseInit(void);
+extern void StartupXLOG(void);
+extern void ShutdownXLOG(void);
 
-extern void		HandleDeadLock(SIGNAL_ARGS);
+extern void HandleDeadLock(SIGNAL_ARGS);
 
-extern char		XLogDir[];
-extern char		ControlFilePath[];
+extern char XLogDir[];
+extern char ControlFilePath[];
 
 extern int	lockingOff;
 extern int	NBuffers;
@@ -126,7 +126,7 @@ bool		ExitAfterAbort = false;
 
 extern int	NBuffers;
 
-static bool	EchoQuery = false;		/* default don't echo */
+static bool EchoQuery = false;	/* default don't echo */
 time_t		tim;
 char		pg_pathname[MAXPGPATH];
 FILE	   *StatFp;
@@ -154,9 +154,9 @@ int			XfuncMode = 0;
  *		decls for routines only used in this file
  * ----------------------------------------------------------------
  */
-static int InteractiveBackend(StringInfo inBuf);
-static int SocketBackend(StringInfo inBuf);
-static int ReadCommand(StringInfo inBuf);
+static int	InteractiveBackend(StringInfo inBuf);
+static int	SocketBackend(StringInfo inBuf);
+static int	ReadCommand(StringInfo inBuf);
 static void pg_exec_query(char *query_string);
 
 
@@ -169,7 +169,7 @@ static void pg_exec_query(char *query_string);
  *	InteractiveBackend() is called for user interactive connections
  *	the string entered by the user is placed in its parameter inBuf.
  *
- *  EOF is returned if end-of-file input is seen; time to shut down.
+ *	EOF is returned if end-of-file input is seen; time to shut down.
  * ----------------
  */
 
@@ -277,7 +277,7 @@ InteractiveBackend(StringInfo inBuf)
  *	the function call is processed in HandleFunctionRequest()
  *	(now called from PostgresMain()).
  *
- *  EOF is returned if the connection is lost.
+ *	EOF is returned if the connection is lost.
  * ----------------
  */
 
@@ -349,11 +349,12 @@ SocketBackend(StringInfo inBuf)
 static int
 ReadCommand(StringInfo inBuf)
 {
-	MemoryContext	oldcontext;
-	int				result;
+	MemoryContext oldcontext;
+	int			result;
 
-	/* Make sure any expansion of inBuf happens in permanent memory context,
-	 * so that we can keep using it for future command cycles.
+	/*
+	 * Make sure any expansion of inBuf happens in permanent memory
+	 * context, so that we can keep using it for future command cycles.
 	 */
 	oldcontext = MemoryContextSwitchTo(TopMemoryContext);
 	if (IsUnderPostmaster)
@@ -372,9 +373,9 @@ ReadCommand(StringInfo inBuf)
  * multiple queries and/or the rewriter might expand one query to several.
  */
 List *
-pg_parse_and_rewrite(char *query_string,	/* string to execute */
-					 Oid *typev,			/* argument types */
-					 int nargs,				/* number of arguments */
+pg_parse_and_rewrite(char *query_string,		/* string to execute */
+					 Oid *typev,/* argument types */
+					 int nargs, /* number of arguments */
 					 bool aclOverride)
 {
 	List	   *querytree_list;
@@ -383,9 +384,7 @@ pg_parse_and_rewrite(char *query_string,	/* string to execute */
 	List	   *new_list;
 
 	if (DebugPrintQuery)
-	{
 		TPRINTF(TRACE_QUERY, "query: %s", query_string);
-	}
 
 	/* ----------------
 	 *	(1) parse the request string into a list of parse trees
@@ -436,7 +435,8 @@ pg_parse_and_rewrite(char *query_string,	/* string to execute */
 		else
 		{
 			/* rewrite regular queries */
-			List *rewritten = QueryRewrite(querytree);
+			List	   *rewritten = QueryRewrite(querytree);
+
 			new_list = nconc(new_list, rewritten);
 		}
 	}
@@ -586,11 +586,10 @@ pg_exec_query_dest(char *query_string,	/* string to execute */
 	 * list pointer has been advanced before the query is executed. We
 	 * need to do that because VACUUM has a nasty little habit of doing
 	 * CommitTransactionCommand at startup, and that will release the
-	 * memory holding our parse list :-(.  This needs a better
-	 * solution --- currently, the code will crash if someone submits
-	 * "vacuum; something-else" in a single query string.  But memory
-	 * allocation needs redesigned anyway, so this will have to do for
-	 * now.
+	 * memory holding our parse list :-(.  This needs a better solution
+	 * --- currently, the code will crash if someone submits "vacuum;
+	 * something-else" in a single query string.  But memory allocation
+	 * needs redesigned anyway, so this will have to do for now.
 	 */
 	while (querytree_list)
 	{
@@ -637,7 +636,8 @@ pg_exec_query_dest(char *query_string,	/* string to execute */
 
 				EndCommand(tag, dest);
 
-				/* We continue in the loop, on the off chance that there
+				/*
+				 * We continue in the loop, on the off chance that there
 				 * is a COMMIT or ROLLBACK utility command later in the
 				 * query string.
 				 */
@@ -735,6 +735,7 @@ void
 die(SIGNAL_ARGS)
 {
 	PG_SETMASK(&BlockSig);
+
 	/*
 	 * If ERROR/FATAL is in progress...
 	 */
@@ -840,7 +841,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
 
 	extern int	optind;
 	extern char *optarg;
-	extern int  DebugLvl;
+	extern int	DebugLvl;
 
 	/*
 	 * Set default values for command-line options.
@@ -1210,16 +1211,15 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
 		fprintf(stderr, "%s does not know where to find the database system "
 				"data.  You must specify the directory that contains the "
 				"database system either by specifying the -D invocation "
-				"option or by setting the PGDATA environment variable.\n\n",
+			 "option or by setting the PGDATA environment variable.\n\n",
 				argv[0]);
 		proc_exit(1);
 	}
 
 	/*
-	 * 1. Set BlockSig and UnBlockSig masks. 
-	 * 2. Set up signal handlers.
-	 * 3. Allow only SIGUSR1 signal (we never block it) 
-	 *    during initialization.
+	 * 1. Set BlockSig and UnBlockSig masks. 2. Set up signal handlers. 3.
+	 * Allow only SIGUSR1 signal (we never block it) during
+	 * initialization.
 	 *
 	 * Note that postmaster already blocked ALL signals to make us happy.
 	 */
@@ -1235,22 +1235,23 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
 	BlockSig &= ~(sigmask(SIGUSR1));
 #endif
 
-	pqsignal(SIGHUP, read_pg_options);		/* update pg_options from file */
-	pqsignal(SIGINT, QueryCancelHandler);	/* cancel current query */
-	pqsignal(SIGQUIT, handle_warn);			/* handle error */
+	pqsignal(SIGHUP, read_pg_options);	/* update pg_options from file */
+	pqsignal(SIGINT, QueryCancelHandler);		/* cancel current query */
+	pqsignal(SIGQUIT, handle_warn);		/* handle error */
 	pqsignal(SIGTERM, die);
 	pqsignal(SIGALRM, HandleDeadLock);
-	/* 
-	 * Ignore failure to write to frontend. Note: if frontend closes 
-	 * connection, we will notice it and exit cleanly when control next 
-	 * returns to outer loop.  This seems safer than forcing exit in the 
+
+	/*
+	 * Ignore failure to write to frontend. Note: if frontend closes
+	 * connection, we will notice it and exit cleanly when control next
+	 * returns to outer loop.  This seems safer than forcing exit in the
 	 * midst of output during who-knows-what operation...
 	 */
 	pqsignal(SIGPIPE, SIG_IGN);
 	pqsignal(SIGUSR1, quickdie);
-	pqsignal(SIGUSR2, Async_NotifyHandler);	/* flush also sinval cache */
+	pqsignal(SIGUSR2, Async_NotifyHandler);		/* flush also sinval cache */
 	pqsignal(SIGFPE, FloatExceptionHandler);
-	pqsignal(SIGCHLD, SIG_IGN);				/* ignored, sent by LockOwners */
+	pqsignal(SIGCHLD, SIG_IGN); /* ignored, sent by LockOwners */
 	pqsignal(SIGTTIN, SIG_DFL);
 	pqsignal(SIGTTOU, SIG_DFL);
 	pqsignal(SIGCONT, SIG_DFL);
@@ -1298,9 +1299,9 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
 		 * Try to create pid file.
 		 */
 		SetPidFname(DataDir);
-		if (SetPidFile(-getpid())) {
+		if (SetPidFile(-getpid()))
 			proc_exit(0);
-		}
+
 		/*
 		 * Register clean up proc.
 		 */
@@ -1365,6 +1366,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
 				remote_info = remote_host = "unknown";
 				break;
 		}
+
 		/*
 		 * Set process params for ps
 		 */
@@ -1425,13 +1427,14 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
 	on_shmem_exit(remove_all_temp_relations, NULL);
 
 	{
-		MemoryContext	oldcontext = MemoryContextSwitchTo(TopMemoryContext);
-		parser_input = makeStringInfo(); /* initialize input buffer */
+		MemoryContext oldcontext = MemoryContextSwitchTo(TopMemoryContext);
+
+		parser_input = makeStringInfo();		/* initialize input buffer */
 		MemoryContextSwitchTo(oldcontext);
 	}
 
-	/* 
-	 * Send this backend's cancellation info to the frontend. 
+	/*
+	 * Send this backend's cancellation info to the frontend.
 	 */
 	if (whereToSendOutput == Remote &&
 		PG_PROTOCOL_MAJOR(FrontendProtocol) >= 2)
@@ -1449,7 +1452,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
 	if (!IsUnderPostmaster)
 	{
 		puts("\nPOSTGRES backend interactive interface ");
-		puts("$Revision: 1.150 $ $Date: 2000/04/04 23:52:50 $\n");
+		puts("$Revision: 1.151 $ $Date: 2000/04/12 17:15:43 $\n");
 	}
 
 	/*
@@ -1463,8 +1466,8 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
 	/*
 	 * POSTGRES main processing loop begins here
 	 *
-	 * If an exception is encountered, processing resumes here
-	 * so we abort the current transaction and start a new one.
+	 * If an exception is encountered, processing resumes here so we abort
+	 * the current transaction and start a new one.
 	 */
 
 	if (sigsetjmp(Warn_restart, 1) != 0)
@@ -1478,7 +1481,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
 		InError = false;
 		if (ExitAfterAbort)
 		{
-			ProcReleaseLocks();		/* Just to be sure... */
+			ProcReleaseLocks(); /* Just to be sure... */
 			proc_exit(0);
 		}
 	}
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index d3ba5b319dd7a8072726d61ba698eb1bb02b20bd..2cc10fe1cd9781b64d3ccfae2b98b3d78169f6f2 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.85 2000/04/04 21:44:40 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.86 2000/04/12 17:15:43 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -164,7 +164,7 @@ ProcessUtility(Node *parsetree,
 
 		case T_DropStmt:
 			{
-				DropStmt *stmt = (DropStmt *) parsetree;
+				DropStmt   *stmt = (DropStmt *) parsetree;
 				List	   *args = stmt->relNames;
 				List	   *arg;
 
@@ -213,17 +213,17 @@ ProcessUtility(Node *parsetree,
 				PS_SET_STATUS(commandTag = "TRUNCATE");
 				CHECK_IF_ABORTED();
 
-				relname = ((TruncateStmt *) parsetree)->relName;			
+				relname = ((TruncateStmt *) parsetree)->relName;
 				if (!allowSystemTableMods && IsSystemRelationName(relname))
 					elog(ERROR, "TRUNCATE cannot be used on system tables. '%s' is a system table",
 						 relname);
 
 				/* Grab exclusive lock in preparation for truncate... */
 				rel = heap_openr(relname, AccessExclusiveLock);
-			    if (rel->rd_rel->relkind == RELKIND_SEQUENCE)
+				if (rel->rd_rel->relkind == RELKIND_SEQUENCE)
 					elog(ERROR, "TRUNCATE cannot be used on sequences. '%s' is a sequence",
 						 relname);
-			    heap_close(rel, NoLock);
+				heap_close(rel, NoLock);
 
 #ifndef NO_SECURITY
 				if (!pg_ownercheck(userName, relname, RELNAME))
@@ -233,21 +233,21 @@ ProcessUtility(Node *parsetree,
 			}
 			break;
 
-	case T_CommentStmt:
-	  {
-	    
-	    CommentStmt *statement;
-	    
-	    statement = ((CommentStmt *) parsetree);
-	    
-	    PS_SET_STATUS(commandTag = "COMMENT");
-	    CHECK_IF_ABORTED();
-	    CommentObject(statement->objtype, statement->objname,
-			  statement->objproperty, statement->objlist,
-			  statement->comment);
-	  }
-	  break;
-	    
+		case T_CommentStmt:
+			{
+
+				CommentStmt *statement;
+
+				statement = ((CommentStmt *) parsetree);
+
+				PS_SET_STATUS(commandTag = "COMMENT");
+				CHECK_IF_ABORTED();
+				CommentObject(statement->objtype, statement->objname,
+							  statement->objproperty, statement->objlist,
+							  statement->comment);
+			}
+			break;
+
 
 
 		case T_CopyStmt:
@@ -272,7 +272,7 @@ ProcessUtility(Node *parsetree,
 				 */
 					   stmt->filename,
 					   stmt->delimiter,
-                       stmt->null_print);
+					   stmt->null_print);
 			}
 			break;
 
@@ -333,42 +333,42 @@ ProcessUtility(Node *parsetree,
 			}
 			break;
 
-            /* various Alter Table forms */
+			/* various Alter Table forms */
 
 		case T_AlterTableStmt:
-        {
-            AlterTableStmt *stmt = (AlterTableStmt *) parsetree;
-
-            PS_SET_STATUS(commandTag = "ALTER");
-            CHECK_IF_ABORTED();
-
-            /*
-             * Some or all of these functions are recursive to cover inherited things,
-             * so permission checks are done there.
-             */
-            switch(stmt->subtype)
-            {
-                case 'A': /* ADD COLUMN */
-                    AlterTableAddColumn(stmt->relname, stmt->inh, (ColumnDef *) stmt->def);
-                    break;
-                case 'T': /* ALTER COLUMN */
-                    AlterTableAlterColumn(stmt->relname, stmt->inh, stmt->name, stmt->def);
-                    break;
-                case 'D': /* ALTER DROP */
-                    AlterTableDropColumn(stmt->relname, stmt->inh, stmt->name, stmt->behavior);
-                    break;
-                case 'C': /* ADD CONSTRAINT */
-                    AlterTableAddConstraint(stmt->relname, stmt->inh, stmt->def);
-                    break;
-                case 'X': /* DROP CONSTRAINT */
-                    AlterTableDropConstraint(stmt->relname, stmt->inh, stmt->name, stmt->behavior);
-                    break;
-                default: /* oops */
-                    elog(ERROR, "T_AlterTableStmt: unknown subtype");
-                    break;
-            }
-        }
-        break;
+			{
+				AlterTableStmt *stmt = (AlterTableStmt *) parsetree;
+
+				PS_SET_STATUS(commandTag = "ALTER");
+				CHECK_IF_ABORTED();
+
+				/*
+				 * Some or all of these functions are recursive to cover
+				 * inherited things, so permission checks are done there.
+				 */
+				switch (stmt->subtype)
+				{
+					case 'A':	/* ADD COLUMN */
+						AlterTableAddColumn(stmt->relname, stmt->inh, (ColumnDef *) stmt->def);
+						break;
+					case 'T':	/* ALTER COLUMN */
+						AlterTableAlterColumn(stmt->relname, stmt->inh, stmt->name, stmt->def);
+						break;
+					case 'D':	/* ALTER DROP */
+						AlterTableDropColumn(stmt->relname, stmt->inh, stmt->name, stmt->behavior);
+						break;
+					case 'C':	/* ADD CONSTRAINT */
+						AlterTableAddConstraint(stmt->relname, stmt->inh, stmt->def);
+						break;
+					case 'X':	/* DROP CONSTRAINT */
+						AlterTableDropConstraint(stmt->relname, stmt->inh, stmt->name, stmt->behavior);
+						break;
+					default:	/* oops */
+						elog(ERROR, "T_AlterTableStmt: unknown subtype");
+						break;
+				}
+			}
+			break;
 
 
 		case T_ChangeACLStmt:
@@ -385,7 +385,7 @@ ProcessUtility(Node *parsetree,
 
 				modechg = stmt->modechg;
 				foreach(i, stmt->relNames)
-                {
+				{
 					Relation	rel;
 
 					relname = strVal(lfirst(i));
@@ -830,26 +830,26 @@ ProcessUtility(Node *parsetree,
 			DeferredTriggerSetState((ConstraintsSetStmt *) parsetree);
 			break;
 
-        case T_CreateGroupStmt:
-            PS_SET_STATUS(commandTag = "CREATE GROUP");
+		case T_CreateGroupStmt:
+			PS_SET_STATUS(commandTag = "CREATE GROUP");
 			CHECK_IF_ABORTED();
 
-            CreateGroup((CreateGroupStmt *) parsetree);
-            break;
+			CreateGroup((CreateGroupStmt *) parsetree);
+			break;
 
-        case T_AlterGroupStmt:
-            PS_SET_STATUS(commandTag = "ALTER GROUP");
+		case T_AlterGroupStmt:
+			PS_SET_STATUS(commandTag = "ALTER GROUP");
 			CHECK_IF_ABORTED();
 
-            AlterGroup((AlterGroupStmt *) parsetree, "ALTER GROUP");
-            break;
+			AlterGroup((AlterGroupStmt *) parsetree, "ALTER GROUP");
+			break;
 
-        case T_DropGroupStmt:
-            PS_SET_STATUS(commandTag = "DROP GROUP");
+		case T_DropGroupStmt:
+			PS_SET_STATUS(commandTag = "DROP GROUP");
 			CHECK_IF_ABORTED();
 
-            DropGroup((DropGroupStmt *) parsetree);
-            break;
+			DropGroup((DropGroupStmt *) parsetree);
+			break;
 
 		case T_ReindexStmt:
 			{
@@ -861,15 +861,15 @@ ProcessUtility(Node *parsetree,
 				switch (stmt->reindexType)
 				{
 					case INDEX:
-						relname = (char*) stmt->name;
+						relname = (char *) stmt->name;
 						if (IsSystemRelationName(relname))
 						{
 							if (!allowSystemTableMods && IsSystemRelationName(relname))
-							elog(ERROR, "class \"%s\" is a system catalog index",
-								 relname);
+								elog(ERROR, "class \"%s\" is a system catalog index",
+									 relname);
 							if (!IsIgnoringSystemIndexes())
 								elog(ERROR, "class \"%s\" is a system catalog index",
-								 relname);
+									 relname);
 						}
 #ifndef NO_SECURITY
 						if (!pg_ownercheck(userName, relname, RELNAME))
@@ -878,15 +878,15 @@ ProcessUtility(Node *parsetree,
 						ReindexIndex(relname, stmt->force);
 						break;
 					case TABLE:
-						relname = (char*) stmt->name;
+						relname = (char *) stmt->name;
 						if (IsSystemRelationName(relname))
 						{
 							if (!allowSystemTableMods && IsSystemRelationName(relname))
-							elog(ERROR, "class \"%s\" is a system catalog index",
-								 relname);
+								elog(ERROR, "class \"%s\" is a system catalog index",
+									 relname);
 							if (!IsIgnoringSystemIndexes())
 								elog(ERROR, "class \"%s\" is a system catalog index",
-								 relname);
+									 relname);
 						}
 #ifndef NO_SECURITY
 						if (!pg_ownercheck(userName, relname, RELNAME))
@@ -895,7 +895,7 @@ ProcessUtility(Node *parsetree,
 						ReindexTable(relname, stmt->force);
 						break;
 					case DATABASE:
-						relname = (char*) stmt->name;
+						relname = (char *) stmt->name;
 						if (!allowSystemTableMods)
 							elog(ERROR, "-O option is needed");
 						if (!IsIgnoringSystemIndexes())
@@ -906,6 +906,7 @@ ProcessUtility(Node *parsetree,
 				break;
 			}
 			break;
+
 			/*
 			 * ******************************** default ********************************
 			 *
diff --git a/src/backend/tioga/tgRecipe.h b/src/backend/tioga/tgRecipe.h
index a64bb1d0580b4e1a7c3f9200893f0670811b27cc..94bd57d86c40a6bace26b33eaae968d3cc71bac6 100644
--- a/src/backend/tioga/tgRecipe.h
+++ b/src/backend/tioga/tgRecipe.h
@@ -12,7 +12,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: tgRecipe.h,v 1.13 2000/01/26 05:57:10 momjian Exp $
+ * $Id: tgRecipe.h,v 1.14 2000/04/12 17:15:45 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -38,6 +38,8 @@ typedef struct
 								 *
 								 *
 								 *
+								 *
+								 *
 								 * geo-decls.h */
 
 #endif	 /* TIOGA_FRONTEND */
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c
index 1533b5f18dfebaa0058279358bd6a172af073c9e..6c27fbe03fa6793652cafa27e0650081eb9ce6be 100644
--- a/src/backend/utils/adt/acl.c
+++ b/src/backend/utils/adt/acl.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.44 2000/01/26 05:57:12 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.45 2000/04/12 17:15:47 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -681,8 +681,8 @@ ChangeACLStmt *
 makeAclStmt(char *privileges, List *rel_list, char *grantee,
 			char grant_or_revoke)
 {
-	ChangeACLStmt  *n = makeNode(ChangeACLStmt);
-	StringInfoData	str;
+	ChangeACLStmt *n = makeNode(ChangeACLStmt);
+	StringInfoData str;
 
 	initStringInfo(&str);
 
diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c
index a255e2a3d0e2434b0a41eb4e2706ad2ba8ee2f65..d19749ab014a78950fadc0e3073f1d8f6deabd07 100644
--- a/src/backend/utils/adt/cash.c
+++ b/src/backend/utils/adt/cash.c
@@ -9,7 +9,7 @@
  * workings can be found in the book "Software Solutions in C" by
  * Dale Schumacher, Academic Press, ISBN: 0-12-632360-7.
  *
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.34 2000/03/19 22:10:52 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.35 2000/04/12 17:15:48 momjian Exp $
  */
 
 #include <limits.h>
@@ -32,6 +32,7 @@ static const char *num_word(Cash value);
 
 #ifdef USE_LOCALE
 static struct lconv *lconvert = NULL;
+
 #endif
 
 /* cash_in()
diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c
index 378289373b837c252d7b1f2727cd9cd83b5c7439..e0d361152fa2c65190901600c738c271702cccdb 100644
--- a/src/backend/utils/adt/date.c
+++ b/src/backend/utils/adt/date.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.43 2000/03/14 23:06:35 thomas Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.44 2000/04/12 17:15:48 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -22,7 +22,7 @@
 #include "utils/builtins.h"
 
 static int
-date2tm(DateADT dateVal, int *tzp, struct tm * tm, double *fsec, char **tzn);
+			date2tm(DateADT dateVal, int *tzp, struct tm * tm, double *fsec, char **tzn);
 
 
 /*****************************************************************************
@@ -188,10 +188,10 @@ date_mii(DateADT dateVal, int4 days)
 /* date_timestamp()
  * Convert date to timestamp data type.
  */
-Timestamp   *
+Timestamp  *
 date_timestamp(DateADT dateVal)
 {
-	Timestamp   *result;
+	Timestamp  *result;
 	struct tm	tt,
 			   *tm = &tt;
 	int			tz;
@@ -392,7 +392,7 @@ time_in(char *str)
 		elog(ERROR, "Bad (null) time external representation");
 
 	if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
-		|| (DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, NULL) != 0))
+	 || (DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, NULL) != 0))
 		elog(ERROR, "Bad time external representation '%s'", str);
 
 	time = palloc(sizeof(*time));
@@ -492,16 +492,16 @@ time_cmp(TimeADT *time1, TimeADT *time2)
 	return (*time1 < *time2) ? -1 : (((*time1 > *time2) ? 1 : 0));
 }	/* time_cmp() */
 
-TimeADT *
+TimeADT    *
 time_larger(TimeADT *time1, TimeADT *time2)
 {
-	return time_gt(time1, time2)? time1: time2;
+	return time_gt(time1, time2) ? time1 : time2;
 }	/* time_larger() */
 
-TimeADT *
+TimeADT    *
 time_smaller(TimeADT *time1, TimeADT *time2)
 {
-	return time_lt(time1, time2)? time1: time2;
+	return time_lt(time1, time2) ? time1 : time2;
 }	/* time_smaller() */
 
 /* overlaps_time()
@@ -514,19 +514,21 @@ overlaps_time(TimeADT *ts1, TimeADT *te1, TimeADT *ts2, TimeADT *te2)
 	/* Make sure we have ordered pairs... */
 	if (time_gt(ts1, te1))
 	{
-		TimeADT *tt = ts1;
+		TimeADT    *tt = ts1;
+
 		ts1 = te1;
 		te1 = tt;
 	}
 	if (time_gt(ts2, te2))
 	{
-		TimeADT *tt = ts2;
+		TimeADT    *tt = ts2;
+
 		ts2 = te2;
 		te2 = tt;
 	}
 
 	return ((time_gt(ts1, ts2) && (time_lt(ts1, te2) || time_lt(te1, te2)))
-			|| (time_gt(ts2, ts1) && (time_lt(ts2, te1) || time_lt(te2, te1)))
+	   || (time_gt(ts2, ts1) && (time_lt(ts2, te1) || time_lt(te2, te1)))
 			|| time_eq(ts1, ts2));
 }
 
@@ -550,13 +552,9 @@ timestamp_time(Timestamp *timestamp)
 		elog(ERROR, "Unable to convert timestamp to date");
 
 	if (TIMESTAMP_IS_EPOCH(*timestamp))
-	{
 		timestamp2tm(SetTimestamp(*timestamp), NULL, tm, &fsec, NULL);
-	}
 	else if (TIMESTAMP_IS_CURRENT(*timestamp))
-	{
 		timestamp2tm(SetTimestamp(*timestamp), &tz, tm, &fsec, &tzn);
-	}
 	else
 	{
 		if (timestamp2tm(*timestamp, &tz, tm, &fsec, &tzn) != 0)
@@ -574,10 +572,10 @@ timestamp_time(Timestamp *timestamp)
 /* datetime_timestamp()
  * Convert date and time to timestamp data type.
  */
-Timestamp   *
+Timestamp  *
 datetime_timestamp(DateADT date, TimeADT *time)
 {
-	Timestamp   *result;
+	Timestamp  *result;
 
 	if (!PointerIsValid(time))
 	{
@@ -618,7 +616,7 @@ time_interval(TimeADT *time)
  *****************************************************************************/
 
 
-TimeTzADT    *
+TimeTzADT  *
 timetz_in(char *str)
 {
 	TimeTzADT  *time;
@@ -638,7 +636,7 @@ timetz_in(char *str)
 		elog(ERROR, "Bad (null) time external representation");
 
 	if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
-		|| (DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
+	  || (DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
 		elog(ERROR, "Bad time external representation '%s'", str);
 
 	time = palloc(sizeof(*time));
@@ -738,19 +736,19 @@ timetz_ge(TimeTzADT *time1, TimeTzADT *time2)
 int
 timetz_cmp(TimeTzADT *time1, TimeTzADT *time2)
 {
-	return (timetz_lt(time1, time2) ? -1 : (timetz_gt(time1, time2)? 1: 0));
+	return (timetz_lt(time1, time2) ? -1 : (timetz_gt(time1, time2) ? 1 : 0));
 }	/* timetz_cmp() */
 
-TimeTzADT *
+TimeTzADT  *
 timetz_larger(TimeTzADT *time1, TimeTzADT *time2)
 {
-	return timetz_gt(time1, time2)? time1: time2;
+	return timetz_gt(time1, time2) ? time1 : time2;
 }	/* timetz_larger() */
 
-TimeTzADT *
+TimeTzADT  *
 timetz_smaller(TimeTzADT *time1, TimeTzADT *time2)
 {
-	return timetz_lt(time1, time2)? time1: time2;
+	return timetz_lt(time1, time2) ? time1 : time2;
 }	/* timetz_smaller() */
 
 /* overlaps_timetz()
@@ -763,13 +761,15 @@ overlaps_timetz(TimeTzADT *ts1, TimeTzADT *te1, TimeTzADT *ts2, TimeTzADT *te2)
 	/* Make sure we have ordered pairs... */
 	if (timetz_gt(ts1, te1))
 	{
-		TimeTzADT *tt = ts1;
+		TimeTzADT  *tt = ts1;
+
 		ts1 = te1;
 		te1 = tt;
 	}
 	if (timetz_gt(ts2, te2))
 	{
-		TimeTzADT *tt = ts2;
+		TimeTzADT  *tt = ts2;
+
 		ts2 = te2;
 		te2 = tt;
 	}
@@ -782,10 +782,10 @@ overlaps_timetz(TimeTzADT *ts1, TimeTzADT *te1, TimeTzADT *ts2, TimeTzADT *te2)
 /* timestamp_timetz()
  * Convert timestamp to timetz data type.
  */
-TimeTzADT    *
+TimeTzADT  *
 timestamp_timetz(Timestamp *timestamp)
 {
-	TimeTzADT    *result;
+	TimeTzADT  *result;
 	struct tm	tt,
 			   *tm = &tt;
 	int			tz;
@@ -804,9 +804,7 @@ timestamp_timetz(Timestamp *timestamp)
 		tz = 0;
 	}
 	else if (TIMESTAMP_IS_CURRENT(*timestamp))
-	{
 		timestamp2tm(SetTimestamp(*timestamp), &tz, tm, &fsec, &tzn);
-	}
 	else
 	{
 		if (timestamp2tm(*timestamp, &tz, tm, &fsec, &tzn) != 0)
@@ -828,7 +826,7 @@ timestamp_timetz(Timestamp *timestamp)
  * stored with the timetz to the result.
  * - thomas 2000-03-10
  */
-Timestamp   *
+Timestamp  *
 datetimetz_timestamp(DateADT date, TimeTzADT *time)
 {
 	Timestamp  *result;
@@ -841,9 +839,7 @@ datetimetz_timestamp(DateADT date, TimeTzADT *time)
 	result = palloc(sizeof(*result));
 
 	if (!PointerIsValid(date) || !PointerIsValid(time))
-	{
 		TIMESTAMP_INVALID(*result);
-	}
 	else
 	{
 		if (date2tm(date, &tz, tm, &fsec, &tzn) != 0)
@@ -857,5 +853,3 @@ datetimetz_timestamp(DateADT date, TimeTzADT *time)
 
 	return result;
 }	/* datetimetz_timestamp() */
-
-
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c
index 6d52d2f2817676ca0f9204afda1520579a212c1f..2f899d21e931e3388b80c6c0423006979dad3cf2 100644
--- a/src/backend/utils/adt/datetime.c
+++ b/src/backend/utils/adt/datetime.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.45 2000/03/29 03:57:18 thomas Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.46 2000/04/12 17:15:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -35,7 +35,7 @@
 #define USE_DATE_CACHE 1
 #define ROUND_ALL 0
 
-static int DecodePosixTimezone(char *str, int *val);
+static int	DecodePosixTimezone(char *str, int *val);
 
 int			day_tab[2][13] = {
 	{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0},
@@ -457,23 +457,24 @@ ParseDateTime(char *timestr, char *lowstr,
 			while (isalpha(*cp))
 				*lp++ = tolower(*cp++);
 
-			/* Full date string with leading text month?
-			 * Could also be a POSIX time zone...
+			/*
+			 * Full date string with leading text month? Could also be a
+			 * POSIX time zone...
 			 */
 			if ((*cp == '-') || (*cp == '/') || (*cp == '.'))
 			{
 #if 0
+
 				/*
-				 * special case of Posix timezone "GMT-0800"
-				 * Note that other sign (e.g. "GMT+0800"
-				 * is recognized as two separate fields and handled later.
-				 * XXX There is no room for a delimiter between
-				 * the "GMT" and the "-0800", so we are going to just swallow the "GMT".
-				 * But this leads to other troubles with the definition of signs,
-				 * so we have to flip
-				 * - thomas 2000-02-06
+				 * special case of Posix timezone "GMT-0800" Note that
+				 * other sign (e.g. "GMT+0800" is recognized as two
+				 * separate fields and handled later. XXX There is no room
+				 * for a delimiter between the "GMT" and the "-0800", so
+				 * we are going to just swallow the "GMT". But this leads
+				 * to other troubles with the definition of signs, so we
+				 * have to flip - thomas 2000-02-06
 				 */
-				if ((*cp == '-') && isdigit(*(cp+1))
+				if ((*cp == '-') && isdigit(*(cp + 1))
 					&& (strncmp(field[nf], "gmt", 3) == 0))
 				{
 					*cp = '+';
@@ -586,7 +587,8 @@ DecodeDateTime(char **field, int *ftype, int nf,
 	tm->tm_min = 0;
 	tm->tm_sec = 0;
 	*fsec = 0;
-	tm->tm_isdst = -1;	/* don't know daylight savings time status apriori */
+	tm->tm_isdst = -1;			/* don't know daylight savings time status
+								 * apriori */
 	if (tzp != NULL)
 		*tzp = 0;
 
@@ -595,10 +597,11 @@ DecodeDateTime(char **field, int *ftype, int nf,
 		switch (ftype[i])
 		{
 			case DTK_DATE:
-				/* Already have a date?
-				 * Then this might be a POSIX time zone
-				 *  with an embedded dash (e.g. "PST-3" == "EST")
-				 * - thomas 2000-03-15
+
+				/*
+				 * Already have a date? Then this might be a POSIX time
+				 * zone with an embedded dash (e.g. "PST-3" == "EST") -
+				 * thomas 2000-03-15
 				 */
 				if ((fmask & DTK_DATE_M) == DTK_DATE_M)
 				{
@@ -630,17 +633,18 @@ DecodeDateTime(char **field, int *ftype, int nf,
 					return -1;
 
 				{
-					int tz;
+					int			tz;
 
 					if (DecodeTimezone(field[i], &tz) != 0)
 						return -1;
 
-					/* Already have a time zone?
-					 * Then maybe this is the second field of a POSIX time:
-					 *  EST+3 (equivalent to PST)
+					/*
+					 * Already have a time zone? Then maybe this is the
+					 * second field of a POSIX time: EST+3 (equivalent to
+					 * PST)
 					 */
 					if ((i > 0) && ((fmask & DTK_M(TZ)) != 0)
-						&& (ftype[i-1] == DTK_TZ) && (isalpha(*field[i-1])))
+						&& (ftype[i - 1] == DTK_TZ) && (isalpha(*field[i - 1])))
 					{
 						*tzp -= tz;
 						tmask = 0;
@@ -742,6 +746,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
 						break;
 
 					case MONTH:
+
 						/*
 						 * already have a (numeric) month? then see if we
 						 * can substitute...
@@ -881,7 +886,8 @@ DecodeDateTime(char **field, int *ftype, int nf,
 				tm->tm_mon += 1;
 
 #if defined(HAVE_TM_ZONE)
-				*tzp = -(tm->tm_gmtoff);	/* tm_gmtoff is Sun/DEC-ism */
+				*tzp = -(tm->tm_gmtoff);		/* tm_gmtoff is
+												 * Sun/DEC-ism */
 #elif defined(HAVE_INT_TIMEZONE)
 #ifdef __CYGWIN__
 				*tzp = ((tm->tm_isdst > 0) ? (_timezone - 3600) : _timezone);
@@ -937,7 +943,8 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
 	tm->tm_min = 0;
 	tm->tm_sec = 0;
 	*fsec = 0;
-	tm->tm_isdst = -1;	/* don't know daylight savings time status apriori */
+	tm->tm_isdst = -1;			/* don't know daylight savings time status
+								 * apriori */
 	if (tzp != NULL)
 		*tzp = 0;
 
@@ -948,9 +955,10 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
 		switch (ftype[i])
 		{
 			case DTK_DATE:
-				/* This might be a POSIX time zone
-				 *  with an embedded dash (e.g. "PST-3" == "EST")
-				 * - thomas 2000-03-15
+
+				/*
+				 * This might be a POSIX time zone with an embedded dash
+				 * (e.g. "PST-3" == "EST") - thomas 2000-03-15
 				 */
 				if ((tzp == NULL)
 					|| (DecodePosixTimezone(field[i], tzp) != 0))
@@ -970,17 +978,18 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
 					return -1;
 
 				{
-					int tz;
+					int			tz;
 
 					if (DecodeTimezone(field[i], &tz) != 0)
 						return -1;
 
-					/* Already have a time zone?
-					 * Then maybe this is the second field of a POSIX time:
-					 *  EST+3 (equivalent to PST)
+					/*
+					 * Already have a time zone? Then maybe this is the
+					 * second field of a POSIX time: EST+3 (equivalent to
+					 * PST)
 					 */
 					if ((i > 0) && ((fmask & DTK_M(TZ)) != 0)
-						&& (ftype[i-1] == DTK_TZ) && (isalpha(*field[i-1])))
+						&& (ftype[i - 1] == DTK_TZ) && (isalpha(*field[i - 1])))
 					{
 						*tzp -= tz;
 						tmask = 0;
@@ -1107,11 +1116,12 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
 	/* timezone not specified? then find local timezone if possible */
 	if ((tzp != NULL) && (!(fmask & DTK_M(TZ))))
 	{
-		struct tm tt, *tmp = &tt;
+		struct tm	tt,
+				   *tmp = &tt;
 
 		/*
-		 * daylight savings time modifier but no standard timezone?
-		 * then error
+		 * daylight savings time modifier but no standard timezone? then
+		 * error
 		 */
 		if (fmask & DTK_M(DTZMOD))
 			return -1;
@@ -1127,7 +1137,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
 		tm->tm_isdst = tmp->tm_isdst;
 
 #if defined(HAVE_TM_ZONE)
-		*tzp = -(tmp->tm_gmtoff);	/* tm_gmtoff is Sun/DEC-ism */
+		*tzp = -(tmp->tm_gmtoff);		/* tm_gmtoff is Sun/DEC-ism */
 #elif defined(HAVE_INT_TIMEZONE)
 #ifdef __CYGWIN__
 		*tzp = ((tmp->tm_isdst > 0) ? (_timezone - 3600) : _timezone);
@@ -1366,10 +1376,8 @@ DecodeNumber(int flen, char *str, int fmask,
 	 * Enough digits to be unequivocal year? Used to test for 4 digits or
 	 * more, but we now test first for a three-digit doy so anything
 	 * bigger than two digits had better be an explicit year. - thomas
-	 * 1999-01-09
-	 * Back to requiring a 4 digit year.
-	 * We accept a two digit year farther down.
-	 * - thomas 2000-03-28
+	 * 1999-01-09 Back to requiring a 4 digit year. We accept a two digit
+	 * year farther down. - thomas 2000-03-28
 	 */
 	else if (flen >= 4)
 	{
@@ -1414,8 +1422,10 @@ DecodeNumber(int flen, char *str, int fmask,
 		*tmask = DTK_M(DAY);
 		tm->tm_mday = val;
 	}
-	/* Check for 2 or 4 or more digits, but currently we reach here
-	 * only if two digits. - thomas 2000-03-28
+
+	/*
+	 * Check for 2 or 4 or more digits, but currently we reach here only
+	 * if two digits. - thomas 2000-03-28
 	 */
 	else if (!(fmask & DTK_M(YEAR))
 			 && ((flen >= 4) || (flen == 2)))
@@ -1550,14 +1560,15 @@ DecodeTimezone(char *str, int *tzp)
 
 /* DecodePosixTimezone()
  * Interpret string as a POSIX-compatible timezone:
- *  PST-hh:mm
- *  PST+h
+ *	PST-hh:mm
+ *	PST+h
  * - thomas 2000-03-15
  */
 static int
 DecodePosixTimezone(char *str, int *tzp)
 {
-	int			val, tz;
+	int			val,
+				tz;
 	int			type;
 	char	   *cp;
 	char		delim;
@@ -1571,10 +1582,10 @@ DecodePosixTimezone(char *str, int *tzp)
 
 	delim = *cp;
 	*cp = '\0';
-	type = DecodeSpecial(MAXDATEFIELDS-1, str, &val);
+	type = DecodeSpecial(MAXDATEFIELDS - 1, str, &val);
 	*cp = delim;
 
-	switch(type)
+	switch (type)
 	{
 		case DTZ:
 		case TZ:
@@ -1898,7 +1909,7 @@ DecodeUnits(int field, char *lowtoken, int *val)
  * Binary search -- from Knuth (6.2.1) Algorithm B.  Special case like this
  * is WAY faster than the generic bsearch().
  */
-datetkn *
+datetkn    *
 datebsearch(char *key, datetkn *base, unsigned int nel)
 {
 	datetkn    *last = base + nel - 1,
@@ -2002,7 +2013,8 @@ EncodeTimeOnly(struct tm * tm, double fsec, int *tzp, int style, char *str)
 
 	if (tzp != NULL)
 	{
-		int hour, min;
+		int			hour,
+					min;
 
 		hour = -(*tzp / 3600);
 		min = ((abs(*tzp) / 60) % 60);
diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c
index 82c7e191d53b72c513b95278d0d7470bac3d11c2..354ee0110b73588aea39747c03c05fb20f142fa4 100644
--- a/src/backend/utils/adt/float.c
+++ b/src/backend/utils/adt/float.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.56 2000/04/07 13:39:40 thomas Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.57 2000/04/12 17:15:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1159,8 +1159,9 @@ dpow(float64 arg1, float64 arg2)
 	tmp1 = *arg1;
 	tmp2 = *arg2;
 
-	/* We must check both for errno getting set and for a NaN result,
-	 * in order to deal with the vagaries of different platforms...
+	/*
+	 * We must check both for errno getting set and for a NaN result, in
+	 * order to deal with the vagaries of different platforms...
 	 */
 	errno = 0;
 	*result = (float64data) pow(tmp1, tmp2);
@@ -1192,9 +1193,10 @@ dexp(float64 arg1)
 
 	tmp = *arg1;
 
-	/* We must check both for errno getting set and for a NaN result,
-	 * in order to deal with the vagaries of different platforms.
-	 * Also, a zero result implies unreported underflow.
+	/*
+	 * We must check both for errno getting set and for a NaN result, in
+	 * order to deal with the vagaries of different platforms. Also, a
+	 * zero result implies unreported underflow.
 	 */
 	errno = 0;
 	*result = (float64data) exp(tmp);
@@ -1234,7 +1236,7 @@ dlog1(float64 arg1)
 
 	CheckFloat8Val(*result);
 	return result;
-} /* dlog1() */
+}	/* dlog1() */
 
 
 /*
@@ -1260,7 +1262,7 @@ dlog10(float64 arg1)
 
 	CheckFloat8Val(*result);
 	return result;
-} /* dlog10() */
+}	/* dlog10() */
 
 
 /*
@@ -1289,7 +1291,7 @@ dacos(float64 arg1)
 
 	CheckFloat8Val(*result);
 	return result;
-} /* dacos() */
+}	/* dacos() */
 
 
 /*
@@ -1318,7 +1320,7 @@ dasin(float64 arg1)
 
 	CheckFloat8Val(*result);
 	return result;
-} /* dasin() */
+}	/* dasin() */
 
 
 /*
@@ -1347,7 +1349,7 @@ datan(float64 arg1)
 
 	CheckFloat8Val(*result);
 	return result;
-} /* datan() */
+}	/* datan() */
 
 
 /*
@@ -1374,7 +1376,7 @@ datan2(float64 arg1, float64 arg2)
 
 	CheckFloat8Val(*result);
 	return result;
-} /* datan2() */
+}	/* datan2() */
 
 
 /*
@@ -1403,7 +1405,7 @@ dcos(float64 arg1)
 
 	CheckFloat8Val(*result);
 	return result;
-} /* dcos() */
+}	/* dcos() */
 
 
 /*
@@ -1430,10 +1432,10 @@ dcot(float64 arg1)
 		)
 		elog(ERROR, "dcot(%f) input is out of range", *arg1);
 
-	*result = 1.0/(*result);
+	*result = 1.0 / (*result);
 	CheckFloat8Val(*result);
 	return result;
-} /* dcot() */
+}	/* dcot() */
 
 
 /*
@@ -1462,7 +1464,7 @@ dsin(float64 arg1)
 
 	CheckFloat8Val(*result);
 	return result;
-} /* dsin() */
+}	/* dsin() */
 
 
 /*
@@ -1491,7 +1493,7 @@ dtan(float64 arg1)
 
 	CheckFloat8Val(*result);
 	return result;
-} /* dtan() */
+}	/* dtan() */
 
 
 #ifndef M_PI
@@ -1517,7 +1519,7 @@ degrees(float64 arg1)
 
 	CheckFloat8Val(*result);
 	return result;
-} /* degrees() */
+}	/* degrees() */
 
 
 /*
@@ -1533,7 +1535,7 @@ dpi(void)
 	*result = (M_PI);
 
 	return result;
-} /* dpi() */
+}	/* dpi() */
 
 
 /*
@@ -1553,11 +1555,11 @@ radians(float64 arg1)
 
 	CheckFloat8Val(*result);
 	return result;
-} /* radians() */
+}	/* radians() */
 
 
 /*
- *		drandom   	- returns a random number
+ *		drandom		- returns a random number
  */
 float64
 drandom(void)
@@ -1571,7 +1573,7 @@ drandom(void)
 
 	CheckFloat8Val(*result);
 	return result;
-} /* drandom() */
+}	/* drandom() */
 
 
 /*
@@ -1580,12 +1582,12 @@ drandom(void)
 int32
 setseed(float64 seed)
 {
-	int iseed = ((*seed) * RAND_MAX);
+	int			iseed = ((*seed) * RAND_MAX);
 
 	srandom((unsigned int) ((*seed) * RAND_MAX));
 
 	return iseed;
-} /* setseed() */
+}	/* setseed() */
 
 
 /*
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index bc60ca654712621f8e3b6d9b4e3c0691ec125789..8d204a159575e099c563b36be2969029f4d3883f 100644
--- a/src/backend/utils/adt/formatting.c
+++ b/src/backend/utils/adt/formatting.c
@@ -1,58 +1,58 @@
 /* -----------------------------------------------------------------------
  * formatting.c
  *
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.7 2000/04/07 19:17:31 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.8 2000/04/12 17:15:49 momjian Exp $
  *
  *
- *   Portions Copyright (c) 1999-2000, PostgreSQL, Inc
+ *	 Portions Copyright (c) 1999-2000, PostgreSQL, Inc
  *
  *
- *   TO_CHAR(); TO_TIMESTAMP(); TO_DATE(); TO_NUMBER();  
+ *	 TO_CHAR(); TO_TIMESTAMP(); TO_DATE(); TO_NUMBER();
  *
- *   The PostgreSQL routines for a timestamp/int/float/numeric formatting, 
- *   inspire with Oracle TO_CHAR() / TO_DATE() / TO_NUMBER() routines.  
+ *	 The PostgreSQL routines for a timestamp/int/float/numeric formatting,
+ *	 inspire with Oracle TO_CHAR() / TO_DATE() / TO_NUMBER() routines.
  *
  *
- *   Cache & Memory:
- *	Routines use (itself) internal cache for format pictures. 
- *	
+ *	 Cache & Memory:
+ *	Routines use (itself) internal cache for format pictures.
+ *
  *	The cache uses a static buffers and is persistent across transactions.
- *	If format-picture is bigger than cache buffer, parser is called always. 
+ *	If format-picture is bigger than cache buffer, parser is called always.
  *
- *   NOTE for Number version:
+ *	 NOTE for Number version:
  *	All in this version is implemented as keywords ( => not used
- * 	suffixes), because a format picture is for *one* item (number) 
- *	only. It not is as a timestamp version, where each keyword (can) 
- *	has suffix.  
+ *	suffixes), because a format picture is for *one* item (number)
+ *	only. It not is as a timestamp version, where each keyword (can)
+ *	has suffix.
  *
- *   NOTE for Timestamp routines:
+ *	 NOTE for Timestamp routines:
  *	In this module the POSIX 'struct tm' type is *not* used, but rather
  *	PgSQL type, which has tm_mon based on one (*non* zero) and
- *	year *not* based on 1900, but is used full year number.  
+ *	year *not* based on 1900, but is used full year number.
  *	Module supports AD / BC / AM / PM.
  *
- *  Supported types for to_char():
- *		
+ *	Supported types for to_char():
+ *
  *		Timestamp, Numeric, int4, int8, float4, float8
  *
- *  Supported types for reverse conversion:
+ *	Supported types for reverse conversion:
  *
  *		Timestamp	- to_timestamp()
  *		Date		- to_date()
- *		Numeric		- to_number()		
- *  
- * 
- *	Karel Zak - Zakkr	
+ *		Numeric		- to_number()
+ *
+ *
+ *	Karel Zak - Zakkr
  *
  * -----------------------------------------------------------------------
  */
- 
+
 /* ----------
  * UnComment me for DEBUG
  * ----------
  */
 /***
-#define DEBUG_TO_FROM_CHAR	
+#define DEBUG_TO_FROM_CHAR
 #define DEBUG_elog_output	NOTICE
 ***/
 
@@ -74,8 +74,8 @@
  * Routines type
  * ----------
  */
-#define DCH_TYPE		1	/* DATE-TIME version 	*/		
-#define NUM_TYPE		2	/* NUMBER version	*/
+#define DCH_TYPE		1		/* DATE-TIME version	*/
+#define NUM_TYPE		2		/* NUMBER version	*/
 
 /* ----------
  * KeyWord Index (ascii from position 32 (' ') to 126 (~))
@@ -85,54 +85,57 @@
 #define KeyWord_INDEX_FILTER(_c)	((_c) <= ' ' || (_c) >= '~' ? 0 : 1)
 
 /* ----------
- * Maximal length of one node 
+ * Maximal length of one node
  * ----------
  */
-#define DCH_MAX_ITEM_SIZ		9	/* max julian day 		*/
-#define NUM_MAX_ITEM_SIZ		8	/* roman number (RN has 15 chars) 	*/
+#define DCH_MAX_ITEM_SIZ		9		/* max julian day		*/
+#define NUM_MAX_ITEM_SIZ		8		/* roman number (RN has 15 chars)	*/
 
 /* ----------
  * More is in float.c
  * ----------
  */
-#define MAXFLOATWIDTH   64
-#define MAXDOUBLEWIDTH  128
+#define MAXFLOATWIDTH	64
+#define MAXDOUBLEWIDTH	128
 
 /* ----------
- * External (defined in PgSQL dt.c (timestamp utils)) 
+ * External (defined in PgSQL dt.c (timestamp utils))
  * ----------
  */
-extern  char		*months[],	/* month abbreviation   */
-			*days[];	/* full days		*/
+extern char *months[],			/* month abbreviation	*/
+		   *days[];				/* full days		*/
 
 /* ----------
- * Format parser structs             
+ * Format parser structs
  * ----------
  */
-typedef struct {
-	char		*name;		/* suffix string		*/
-	int		len,		/* suffix length		*/
-			id,		/* used in node->suffix	*/
-			type;		/* prefix / postfix 		*/
+typedef struct
+{
+	char	   *name;			/* suffix string		*/
+	int			len,			/* suffix length		*/
+				id,				/* used in node->suffix */
+				type;			/* prefix / postfix			*/
 } KeySuffix;
 
-typedef struct {
-	char		*name;		/* keyword			*/
-					/* action for keyword		*/
-	int		len,		/* keyword length		*/	
-			(*action)(),	
-			id;		/* keyword id			*/			
+typedef struct
+{
+	char	   *name;			/* keyword			*/
+	/* action for keyword		*/
+	int			len,			/* keyword length		*/
+				(*action) (),
+				id;				/* keyword id			*/
 } KeyWord;
 
-typedef struct {
-	int		type;		/* node type 			*/
-	KeyWord		*key;		/* if node type is KEYWORD 	*/
-	int		character,	/* if node type is CHAR 	*/
-			suffix;		/* keyword suffix 		*/		
+typedef struct
+{
+	int			type;			/* node type			*/
+	KeyWord    *key;			/* if node type is KEYWORD	*/
+	int			character,		/* if node type is CHAR		*/
+				suffix;			/* keyword suffix		*/
 } FormatNode;
 
 #define NODE_TYPE_END		1
-#define	NODE_TYPE_ACTION	2
+#define NODE_TYPE_ACTION	2
 #define NODE_TYPE_CHAR		3
 
 #define SUFFTYPE_PREFIX		1
@@ -143,9 +146,9 @@ typedef struct {
  * Full months
  * ----------
  */
-static char *months_full[]	= {
-	"January", "February", "March", "April", "May", "June", "July", 
-	"August", "September", "October", "November", "December", NULL        
+static char *months_full[] = {
+	"January", "February", "March", "April", "May", "June", "July",
+	"August", "September", "October", "November", "December", NULL
 };
 
 /* ----------
@@ -153,7 +156,7 @@ static char *months_full[]	= {
  * ----------
  */
 #define YEAR_ABS(_y)	(_y < 0 ? -(_y -1) : _y)
-#define BC_STR_ORIG	" BC"
+#define BC_STR_ORIG " BC"
 
 #define A_D_STR		"A.D."
 #define a_d_STR		"a.d."
@@ -181,47 +184,47 @@ static char *months_full[]	= {
 #define pm_STR		"pm"
 
 
-/* ---------- 
- * Months in roman-numeral 
- * (Must be conversely for seq_search (in FROM_CHAR), because 
- *  'VIII' must be over 'V')   
+/* ----------
+ * Months in roman-numeral
+ * (Must be conversely for seq_search (in FROM_CHAR), because
+ *	'VIII' must be over 'V')
  * ----------
  */
-static char *rm_months_upper[] = 
-{ "XII", "XI", "X", "IX", "VIII", "VII", "VI", "V", "IV", "III", "II", "I", NULL };
+static char *rm_months_upper[] =
+{"XII", "XI", "X", "IX", "VIII", "VII", "VI", "V", "IV", "III", "II", "I", NULL};
 
-static char *rm_months_lower[] = 
-{ "xii", "xi", "x", "ix", "viii", "vii", "vi", "v", "iv", "iii", "ii", "i", NULL };
+static char *rm_months_lower[] =
+{"xii", "xi", "x", "ix", "viii", "vii", "vi", "v", "iv", "iii", "ii", "i", NULL};
 
 /* ----------
  * Roman numbers
  * ----------
  */
-static char *rm1[]   = { "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", NULL };
-static char *rm10[]  = { "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC", NULL };
-static char *rm100[] = { "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM", NULL };
+static char *rm1[] = {"I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", NULL};
+static char *rm10[] = {"X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC", NULL};
+static char *rm100[] = {"C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM", NULL};
 
-/* ---------- 
- * Ordinal postfixes 
+/* ----------
+ * Ordinal postfixes
  * ----------
  */
-static char *numTH[] = { "ST", "ND", "RD", "TH", NULL };
-static char *numth[] = { "st", "nd", "rd", "th", NULL };
+static char *numTH[] = {"ST", "ND", "RD", "TH", NULL};
+static char *numth[] = {"st", "nd", "rd", "th", NULL};
 
-/* ---------- 
- * Flags & Options: 
+/* ----------
+ * Flags & Options:
  * ----------
  */
 #define TO_CHAR		1
-#define FROM_CHAR 	2
+#define FROM_CHAR	2
 
-#define ONE_UPPER	1		/* Name	*/
-#define ALL_UPPER	2		/* NAME */
-#define ALL_LOWER	3		/* name */
+#define ONE_UPPER	1			/* Name */
+#define ALL_UPPER	2			/* NAME */
+#define ALL_LOWER	3			/* name */
 
 #define FULL_SIZ	0
 
-#define MAX_MON_LEN	3
+#define MAX_MON_LEN 3
 #define MAX_DY_LEN	3
 
 #define TH_UPPER	1
@@ -229,21 +232,21 @@ static char *numth[] = { "st", "nd", "rd", "th", NULL };
 
 
 #ifdef DEBUG_TO_FROM_CHAR
-	#define NOTICE_TM {\
+#define NOTICE_TM {\
 		elog(DEBUG_elog_output, "TM:\nsec %d\nyear %d\nmin %d\nwday %d\nhour %d\nyday %d\nmday %d\nnisdst %d\nmon %d\n",\
 			tm->tm_sec, tm->tm_year,\
 			tm->tm_min, tm->tm_wday, tm->tm_hour, tm->tm_yday,\
 			tm->tm_mday, tm->tm_isdst,tm->tm_mon);\
-	}		
+	}
 #endif
 
 /* ----------
  * Flags for DCH version
  * ----------
  */
-static int DCH_global_flag	= 0; 
- 
-#define DCH_F_FX	0x01 
+static int	DCH_global_flag = 0;
+
+#define DCH_F_FX	0x01
 
 #define IS_FX		(DCH_global_flag & DCH_F_FX)
 
@@ -252,33 +255,34 @@ static int DCH_global_flag	= 0;
  * Number description struct
  * ----------
  */
-typedef struct {
-	int	pre,			/* (count) numbers before decimal */
-		post,			/* (count) numbers after decimal  */
-		lsign,			/* want locales sign		  */
-		flag,			/* number parametrs		  */
-		pre_lsign_num,		/* tmp value for lsign		  */	
-		multi,			/* multiplier for 'V'		  */
-		zero_start,		/* position of first zero	  */
-		zero_end,		/* position of last zero	  */
-		need_locale;		/* needs it locale		  */ 
+typedef struct
+{
+	int			pre,			/* (count) numbers before decimal */
+				post,			/* (count) numbers after decimal  */
+				lsign,			/* want locales sign		  */
+				flag,			/* number parametrs		  */
+				pre_lsign_num,	/* tmp value for lsign		  */
+				multi,			/* multiplier for 'V'		  */
+				zero_start,		/* position of first zero	  */
+				zero_end,		/* position of last zero	  */
+				need_locale;	/* needs it locale		  */
 } NUMDesc;
 
 /* ----------
- * Flags for NUMBER version 
+ * Flags for NUMBER version
  * ----------
  */
-#define	NUM_F_DECIMAL	0x01
-#define NUM_F_LDECIMAL 	0x02
+#define NUM_F_DECIMAL	0x01
+#define NUM_F_LDECIMAL	0x02
 #define NUM_F_ZERO	0x04
-#define NUM_F_BLANK	0x08
+#define NUM_F_BLANK 0x08
 #define NUM_F_FILLMODE	0x10
-#define NUM_F_LSIGN	0x20
+#define NUM_F_LSIGN 0x20
 #define NUM_F_BRACKET	0x40
-#define NUM_F_MINUS	0x80
+#define NUM_F_MINUS 0x80
 #define NUM_F_PLUS	0x100
-#define NUM_F_ROMAN	0x200
-#define NUM_F_MULTI	0x400
+#define NUM_F_ROMAN 0x200
+#define NUM_F_MULTI 0x400
 
 #define NUM_LSIGN_PRE	-1
 #define NUM_LSIGN_POST	1
@@ -288,59 +292,64 @@ typedef struct {
  * Tests
  * ----------
  */
-#define	IS_DECIMAL(_f)	((_f)->flag & NUM_F_DECIMAL)
-#define	IS_LDECIMAL(_f)	((_f)->flag & NUM_F_LDECIMAL)
-#define	IS_ZERO(_f)	((_f)->flag & NUM_F_ZERO)
-#define	IS_BLANK(_f)	((_f)->flag & NUM_F_BLANK)
-#define	IS_FILLMODE(_f)	((_f)->flag & NUM_F_FILLMODE)
-#define	IS_BRACKET(_f)	((_f)->flag & NUM_F_BRACKET)
+#define IS_DECIMAL(_f)	((_f)->flag & NUM_F_DECIMAL)
+#define IS_LDECIMAL(_f) ((_f)->flag & NUM_F_LDECIMAL)
+#define IS_ZERO(_f) ((_f)->flag & NUM_F_ZERO)
+#define IS_BLANK(_f)	((_f)->flag & NUM_F_BLANK)
+#define IS_FILLMODE(_f) ((_f)->flag & NUM_F_FILLMODE)
+#define IS_BRACKET(_f)	((_f)->flag & NUM_F_BRACKET)
 #define IS_MINUS(_f)	((_f)->flag & NUM_F_MINUS)
 #define IS_LSIGN(_f)	((_f)->flag & NUM_F_LSIGN)
-#define IS_PLUS(_f)	((_f)->flag & NUM_F_PLUS)
+#define IS_PLUS(_f) ((_f)->flag & NUM_F_PLUS)
 #define IS_ROMAN(_f)	((_f)->flag & NUM_F_ROMAN)
 #define IS_MULTI(_f)	((_f)->flag & NUM_F_MULTI)
 
 /* ----------
- * Format picture cache 
- *  	(cache size: 
- *		Number part 	= NUM_CACHE_SIZE * NUM_CACHE_FIELDS
+ * Format picture cache
+ *		(cache size:
+ *		Number part		= NUM_CACHE_SIZE * NUM_CACHE_FIELDS
  *		Date-time part	= DCH_CACHE_SIZE * DCH_CACHE_FIELDS
  *	)
  * ----------
  */
-#define NUM_CACHE_SIZE		64 
+#define NUM_CACHE_SIZE		64
 #define NUM_CACHE_FIELDS	16
 #define DCH_CACHE_SIZE		128
 #define DCH_CACHE_FIELDS	16
 
-typedef struct {
-	FormatNode	format	[ DCH_CACHE_SIZE +1];
-	char		str	[ DCH_CACHE_SIZE +1];
-	int		age;
+typedef struct
+{
+	FormatNode	format[DCH_CACHE_SIZE + 1];
+	char		str[DCH_CACHE_SIZE + 1];
+	int			age;
 } DCHCacheEntry;
 
-typedef struct {
-	FormatNode	format	[ NUM_CACHE_SIZE +1];
-	char		str	[ NUM_CACHE_SIZE +1];
-	int		age;
-	NUMDesc		Num;	
+typedef struct
+{
+	FormatNode	format[NUM_CACHE_SIZE + 1];
+	char		str[NUM_CACHE_SIZE + 1];
+	int			age;
+	NUMDesc		Num;
 } NUMCacheEntry;
 
-static DCHCacheEntry	DCHCache	[ DCH_CACHE_FIELDS +1];	/* global cache for date/time part */
-static int		n_DCHCache = 0;				/* number of entries */	
-static int		DCHCounter = 0;
+static DCHCacheEntry DCHCache[DCH_CACHE_FIELDS + 1];	/* global cache for
+														 * date/time part */
+static int	n_DCHCache = 0;		/* number of entries */
+static int	DCHCounter = 0;
 
-static NUMCacheEntry	NUMCache	[ NUM_CACHE_FIELDS +1];	/* global cache for number part */
-static int		n_NUMCache = 0;				/* number of entries */	
-static int		NUMCounter = 0;
+static NUMCacheEntry NUMCache[NUM_CACHE_FIELDS + 1];	/* global cache for
+														 * number part */
+static int	n_NUMCache = 0;		/* number of entries */
+static int	NUMCounter = 0;
 
 #define MAX_INT32	(2147483640)
 
 /* ----------
- * Private global-modul definitions 
+ * Private global-modul definitions
  * ----------
  */
-static	struct tm 	_tm,	*tm  = &_tm;
+static struct tm _tm,
+		   *tm = &_tm;
 
 /* ----------
  * Utils
@@ -354,24 +363,24 @@ static	struct tm 	_tm,	*tm  = &_tm;
 #endif
 
 /*****************************************************************************
- *			KeyWords definition & action 
+ *			KeyWords definition & action
  *****************************************************************************/
 
-static int dch_global(int arg, char *inout, int suf, int flag, FormatNode *node); 
-static int dch_time(int arg, char *inout, int suf, int flag, FormatNode *node);
-static int dch_date(int arg, char *inout, int suf, int flag, FormatNode *node);
+static int	dch_global(int arg, char *inout, int suf, int flag, FormatNode *node);
+static int	dch_time(int arg, char *inout, int suf, int flag, FormatNode *node);
+static int	dch_date(int arg, char *inout, int suf, int flag, FormatNode *node);
 
-/* ---------- 
- * Suffixes: 
+/* ----------
+ * Suffixes:
  * ----------
  */
-#define	DCH_S_FM	0x01
-#define	DCH_S_TH	0x02
-#define	DCH_S_th	0x04
-#define	DCH_S_SP	0x08
+#define DCH_S_FM	0x01
+#define DCH_S_TH	0x02
+#define DCH_S_th	0x04
+#define DCH_S_SP	0x08
 
-/* ---------- 
- * Suffix tests 
+/* ----------
+ * Suffix tests
  * ----------
  */
 #define S_THth(_s)	(((_s & DCH_S_TH) || (_s & DCH_S_th)) ? 1 : 0)
@@ -387,47 +396,48 @@ static int dch_date(int arg, char *inout, int suf, int flag, FormatNode *node);
  * ----------
  */
 static KeySuffix DCH_suff[] = {
-	{	"FM",		2, DCH_S_FM,	SUFFTYPE_PREFIX	 },
-	{	"fm",		2, DCH_S_FM,	SUFFTYPE_PREFIX	 },	
-	{	"TH",		2, DCH_S_TH,	SUFFTYPE_POSTFIX },		
-	{	"th",		2, DCH_S_th,	SUFFTYPE_POSTFIX },		
-	{	"SP",		2, DCH_S_SP,	SUFFTYPE_POSTFIX },
+	{"FM", 2, DCH_S_FM, SUFFTYPE_PREFIX},
+	{"fm", 2, DCH_S_FM, SUFFTYPE_PREFIX},
+	{"TH", 2, DCH_S_TH, SUFFTYPE_POSTFIX},
+	{"th", 2, DCH_S_th, SUFFTYPE_POSTFIX},
+	{"SP", 2, DCH_S_SP, SUFFTYPE_POSTFIX},
 	/* last */
-	{	NULL,		0, 0,		0		 }	
+	{NULL, 0, 0, 0}
 };
 
 /* ----------
  * Format-pictures (KeyWord).
- * 
+ *
  * The KeyWord field; alphabetic sorted, *BUT* strings alike is sorted
- *		  complicated -to-> easy: 
+ *		  complicated -to-> easy:
  *
- *	(example: "DDD","DD","Day","D" )	
+ *	(example: "DDD","DD","Day","D" )
  *
  * (this specific sort needs the algorithm for sequential search for strings,
- * which not has exact end; -> How keyword is in "HH12blabla" ? - "HH" 
- * or "HH12"? You must first try "HH12", because "HH" is in string, but 
- * it is not good.   
+ * which not has exact end; -> How keyword is in "HH12blabla" ? - "HH"
+ * or "HH12"? You must first try "HH12", because "HH" is in string, but
+ * it is not good.
  *
- * (!) 
- *    Position for the keyword is simular as position in the enum DCH/NUM_poz 
+ * (!)
+ *	  Position for the keyword is simular as position in the enum DCH/NUM_poz
  * (!)
  *
- * For fast search is used the 'int index[]', index is ascii table from position 
- * 32 (' ') to 126 (~), in this index is DCH_ / NUM_ enums for each ASCII 
- * position or -1 if char is not used in the KeyWord. Search example for 
+ * For fast search is used the 'int index[]', index is ascii table from position
+ * 32 (' ') to 126 (~), in this index is DCH_ / NUM_ enums for each ASCII
+ * position or -1 if char is not used in the KeyWord. Search example for
  * string "MM":
- * 	1)	see in index to index['M' - 32], 
+ *	1)	see in index to index['M' - 32],
  *	2)	take keywords position (enum DCH_MM) from index
- *	3)	run sequential search in keywords[] from this position   
+ *	3)	run sequential search in keywords[] from this position
  *
  * ----------
  */
 
-typedef enum { 
+typedef enum
+{
 	DCH_A_D,
 	DCH_A_M,
-	DCH_AD,	
+	DCH_AD,
 	DCH_AM,
 	DCH_B_C,
 	DCH_BC,
@@ -439,7 +449,7 @@ typedef enum {
 	DCH_Day,
 	DCH_Dy,
 	DCH_D,
-	DCH_FX,		/* global suffix */
+	DCH_FX,						/* global suffix */
 	DCH_HH24,
 	DCH_HH12,
 	DCH_HH,
@@ -463,14 +473,14 @@ typedef enum {
 	DCH_YYY,
 	DCH_YY,
 	DCH_Y,
-	DCH_a_d,	
+	DCH_a_d,
 	DCH_a_m,
 	DCH_ad,
-	DCH_am,	
+	DCH_am,
 	DCH_b_c,
 	DCH_bc,
 	DCH_cc,
-	DCH_day,	
+	DCH_day,
 	DCH_ddd,
 	DCH_dd,
 	DCH_dy,
@@ -478,7 +488,7 @@ typedef enum {
 	DCH_fx,
 	DCH_hh24,
 	DCH_hh12,
-	DCH_hh,	
+	DCH_hh,
 	DCH_j,
 	DCH_mi,
 	DCH_mm,
@@ -496,13 +506,14 @@ typedef enum {
 	DCH_yyyy,
 	DCH_yyy,
 	DCH_yy,
-	DCH_y,    
+	DCH_y,
 
 	/* last */
 	_DCH_last_
 } DCH_poz;
 
-typedef enum {
+typedef enum
+{
 	NUM_COMMA,
 	NUM_DEC,
 	NUM_0,
@@ -538,8 +549,8 @@ typedef enum {
 	NUM_sp,
 	NUM_s,
 	NUM_th,
-	NUM_v,   
-	
+	NUM_v,
+
 	/* last */
 	_NUM_last_
 } NUM_poz;
@@ -548,174 +559,174 @@ typedef enum {
  * KeyWords for DATE-TIME version
  * ----------
  */
-static KeyWord DCH_keywords[] = {	
-/*	keyword,	len, func.	type                 is in Index */
-{	"A.D.",		4, dch_date,	DCH_A_D		},	/*A*/
-{	"A.M.",		4, dch_time,	DCH_A_M		},	
-{	"AD",		2, dch_date,	DCH_AD		},	
-{	"AM",		2, dch_time,	DCH_AM		},	
-{	"B.C.",		4, dch_date,	DCH_B_C		},	/*B*/
-{	"BC",		2, dch_date,	DCH_BC		},
-{	"CC",		2, dch_date,	DCH_CC		},	/*C*/
-{ 	"DAY",          3, dch_date,	DCH_DAY		},	/*D*/
-{ 	"DDD",          3, dch_date,	DCH_DDD		},
-{ 	"DD",           2, dch_date,	DCH_DD		},
-{ 	"DY",           2, dch_date,	DCH_DY		},
-{ 	"Day",		3, dch_date,	DCH_Day		},
-{ 	"Dy",           2, dch_date,	DCH_Dy		},
-{ 	"D",            1, dch_date,	DCH_D		},	
-{ 	"FX",		2, dch_global,	DCH_FX		},	/*F*/
-{ 	"HH24",		4, dch_time,	DCH_HH24	},	/*H*/
-{ 	"HH12",		4, dch_time,	DCH_HH12	},
-{ 	"HH",		2, dch_time,	DCH_HH		},
-{ 	"J",            1, dch_date,	DCH_J	 	},	/*J*/	
-{ 	"MI",		2, dch_time,	DCH_MI		},
-{ 	"MM",          	2, dch_date,	DCH_MM		},
-{ 	"MONTH",        5, dch_date,	DCH_MONTH	},
-{ 	"MON",          3, dch_date,	DCH_MON		},
-{ 	"Month",        5, dch_date,	DCH_Month	},
-{ 	"Mon",          3, dch_date,	DCH_Mon		},
-{	"P.M.",		4, dch_time,	DCH_P_M		},	/*P*/
-{	"PM",		2, dch_time,	DCH_PM		},
-{ 	"Q",            1, dch_date,	DCH_Q		},	/*Q*/	
-{ 	"RM",           2, dch_date,	DCH_RM	 	},	/*R*/
-{ 	"SSSS",		4, dch_time,	DCH_SSSS	},	/*S*/
-{ 	"SS",		2, dch_time,	DCH_SS		},
-{ 	"WW",           2, dch_date,	DCH_WW		},	/*W*/
-{ 	"W",            1, dch_date,	DCH_W	 	},
-{ 	"Y,YYY",        5, dch_date,	DCH_Y_YYY	},	/*Y*/
-{ 	"YYYY",         4, dch_date,	DCH_YYYY	},
-{ 	"YYY",          3, dch_date,	DCH_YYY		},
-{ 	"YY",           2, dch_date,	DCH_YY		},
-{ 	"Y",            1, dch_date,	DCH_Y	 	},
-{	"a.d.",		4, dch_date,	DCH_a_d		},	/*a*/
-{	"a.m.",		4, dch_time,	DCH_a_m		},
-{	"ad",		2, dch_date,	DCH_ad		},	
-{	"am",		2, dch_time,	DCH_am		},
-{ 	"b.c.",		4, dch_date,	DCH_b_c		},	/*b*/
-{ 	"bc",		2, dch_date,	DCH_bc		},
-{ 	"cc",		2, dch_date,	DCH_CC		},	/*c*/
-{ 	"day",		3, dch_date,	DCH_day		},	/*d*/
-{ 	"ddd",		3, dch_date,	DCH_DDD		},		
-{ 	"dd",		2, dch_date,	DCH_DD		},	
-{  	"dy",           2, dch_date,	DCH_dy		},
-{	"d",		1, dch_date,	DCH_D		},	
-{	"fx",		2, dch_global,  DCH_FX		},	/*f*/
-{  	"hh24",		4, dch_time,	DCH_HH24	},	/*h*/
-{  	"hh12",		4, dch_time,	DCH_HH12	},	
-{  	"hh",		2, dch_time,	DCH_HH		},	
-{  	"j",		1, dch_time,	DCH_J		},	/*j*/
-{  	"mi",		2, dch_time,	DCH_MI		},	/*m*/
-{  	"mm",		2, dch_date,	DCH_MM		},	
-{  	"month",        5, dch_date,	DCH_month	},	
-{  	"mon",          3, dch_date,	DCH_mon		},
-{	"p.m.",		4, dch_time,	DCH_p_m		},	/*p*/
-{	"pm",		2, dch_time,	DCH_pm		},
-{  	"q",		1, dch_date,	DCH_Q		},	/*q*/
-{  	"rm",		2, dch_date,	DCH_rm		},	/*r*/
-{  	"ssss",		4, dch_time,	DCH_SSSS	},	/*s*/
-{  	"ss",		2, dch_time,	DCH_SS		},	
-{  	"ww",		2, dch_date,	DCH_WW		},	/*w*/
-{  	"w",		1, dch_date,	DCH_W		},	
-{  	"y,yyy",	5, dch_date,	DCH_Y_YYY	},	/*y*/
-{  	"yyyy",		4, dch_date,	DCH_YYYY	},	
-{  	"yyy",		3, dch_date,	DCH_YYY		},	
-{  	"yy",		2, dch_date,	DCH_YY		},	
-{  	"y",		1, dch_date,	DCH_Y		},	
+static KeyWord DCH_keywords[] = {
+/*	keyword,	len, func.	type				 is in Index */
+	{"A.D.", 4, dch_date, DCH_A_D},		/* A */
+	{"A.M.", 4, dch_time, DCH_A_M},
+	{"AD", 2, dch_date, DCH_AD},
+	{"AM", 2, dch_time, DCH_AM},
+	{"B.C.", 4, dch_date, DCH_B_C},		/* B */
+	{"BC", 2, dch_date, DCH_BC},
+	{"CC", 2, dch_date, DCH_CC},/* C */
+	{"DAY", 3, dch_date, DCH_DAY},		/* D */
+	{"DDD", 3, dch_date, DCH_DDD},
+	{"DD", 2, dch_date, DCH_DD},
+	{"DY", 2, dch_date, DCH_DY},
+	{"Day", 3, dch_date, DCH_Day},
+	{"Dy", 2, dch_date, DCH_Dy},
+	{"D", 1, dch_date, DCH_D},
+	{"FX", 2, dch_global, DCH_FX},		/* F */
+	{"HH24", 4, dch_time, DCH_HH24},	/* H */
+	{"HH12", 4, dch_time, DCH_HH12},
+	{"HH", 2, dch_time, DCH_HH},
+	{"J", 1, dch_date, DCH_J},	/* J */
+	{"MI", 2, dch_time, DCH_MI},
+	{"MM", 2, dch_date, DCH_MM},
+	{"MONTH", 5, dch_date, DCH_MONTH},
+	{"MON", 3, dch_date, DCH_MON},
+	{"Month", 5, dch_date, DCH_Month},
+	{"Mon", 3, dch_date, DCH_Mon},
+	{"P.M.", 4, dch_time, DCH_P_M},		/* P */
+	{"PM", 2, dch_time, DCH_PM},
+	{"Q", 1, dch_date, DCH_Q},	/* Q */
+	{"RM", 2, dch_date, DCH_RM},/* R */
+	{"SSSS", 4, dch_time, DCH_SSSS},	/* S */
+	{"SS", 2, dch_time, DCH_SS},
+	{"WW", 2, dch_date, DCH_WW},/* W */
+	{"W", 1, dch_date, DCH_W},
+	{"Y,YYY", 5, dch_date, DCH_Y_YYY},	/* Y */
+	{"YYYY", 4, dch_date, DCH_YYYY},
+	{"YYY", 3, dch_date, DCH_YYY},
+	{"YY", 2, dch_date, DCH_YY},
+	{"Y", 1, dch_date, DCH_Y},
+	{"a.d.", 4, dch_date, DCH_a_d},		/* a */
+	{"a.m.", 4, dch_time, DCH_a_m},
+	{"ad", 2, dch_date, DCH_ad},
+	{"am", 2, dch_time, DCH_am},
+	{"b.c.", 4, dch_date, DCH_b_c},		/* b */
+	{"bc", 2, dch_date, DCH_bc},
+	{"cc", 2, dch_date, DCH_CC},/* c */
+	{"day", 3, dch_date, DCH_day},		/* d */
+	{"ddd", 3, dch_date, DCH_DDD},
+	{"dd", 2, dch_date, DCH_DD},
+	{"dy", 2, dch_date, DCH_dy},
+	{"d", 1, dch_date, DCH_D},
+	{"fx", 2, dch_global, DCH_FX},		/* f */
+	{"hh24", 4, dch_time, DCH_HH24},	/* h */
+	{"hh12", 4, dch_time, DCH_HH12},
+	{"hh", 2, dch_time, DCH_HH},
+	{"j", 1, dch_time, DCH_J},	/* j */
+	{"mi", 2, dch_time, DCH_MI},/* m */
+	{"mm", 2, dch_date, DCH_MM},
+	{"month", 5, dch_date, DCH_month},
+	{"mon", 3, dch_date, DCH_mon},
+	{"p.m.", 4, dch_time, DCH_p_m},		/* p */
+	{"pm", 2, dch_time, DCH_pm},
+	{"q", 1, dch_date, DCH_Q},	/* q */
+	{"rm", 2, dch_date, DCH_rm},/* r */
+	{"ssss", 4, dch_time, DCH_SSSS},	/* s */
+	{"ss", 2, dch_time, DCH_SS},
+	{"ww", 2, dch_date, DCH_WW},/* w */
+	{"w", 1, dch_date, DCH_W},
+	{"y,yyy", 5, dch_date, DCH_Y_YYY},	/* y */
+	{"yyyy", 4, dch_date, DCH_YYYY},
+	{"yyy", 3, dch_date, DCH_YYY},
+	{"yy", 2, dch_date, DCH_YY},
+	{"y", 1, dch_date, DCH_Y},
 /* last */
-{    NULL,		0, NULL,	0 		}};
+{NULL, 0, NULL, 0}};
 
 /* ----------
  * KeyWords for NUMBER version
  * ----------
  */
-static KeyWord NUM_keywords[] = {	
-/*	keyword,	len, func.	type   	     	   is in Index */
-{ 	",",	        1, NULL,	NUM_COMMA	},  /*,*/
-{ 	".",	        1, NULL,	NUM_DEC		},  /*.*/
-{ 	"0",	        1, NULL,	NUM_0		},  /*0*/
-{ 	"9",	        1, NULL,	NUM_9		},  /*9*/	
-{ 	"B",	        1, NULL,	NUM_B		},  /*B*/	
-{ 	"C",	        1, NULL,	NUM_C		},  /*C*/
-{ 	"D",	        1, NULL,	NUM_D		},  /*D*/
-{ 	"E",	        1, NULL,	NUM_E		},  /*E*/	
-{ 	"FM",	        2, NULL,	NUM_FM		},  /*F*/	
-{ 	"G",	        1, NULL,	NUM_G		},  /*G*/	
-{ 	"L",	        1, NULL,	NUM_L		},  /*L*/	
-{ 	"MI",	        2, NULL,	NUM_MI		},  /*M*/	
-{ 	"PL",        	2, NULL,	NUM_PL		},  /*P*/	
-{ 	"PR",	        2, NULL,	NUM_PR		},  	
-{ 	"RN",	        2, NULL,	NUM_RN		},  /*R*/
-{ 	"SG",	        2, NULL,	NUM_SG		},  /*S*/
-{ 	"SP",	        2, NULL,	NUM_SP   	},
-{ 	"S",	        1, NULL,	NUM_S		},  
-{ 	"TH",		2, NULL,	NUM_TH		},  /*T*/
-{ 	"V",	        1, NULL,	NUM_V   	},  /*V*/			
-{ 	"b",		1, NULL,	NUM_B		},  /*b*/
-{ 	"c",		1, NULL,	NUM_C		},  /*c*/
-{ 	"d",		1, NULL,	NUM_D		},  /*d*/
-{ 	"e",		1, NULL,	NUM_E		},  /*e*/
-{ 	"fm",		2, NULL,	NUM_FM		},  /*f*/
-{ 	"g",		1, NULL,	NUM_G		},  /*g*/
-{ 	"l",		1, NULL,	NUM_L		},  /*l*/
-{ 	"mi",		2, NULL,	NUM_MI		},  /*m*/
-{ 	"pl",		2, NULL,	NUM_PL		},  /*p*/
-{ 	"pr",		2, NULL,	NUM_PR		},
-{ 	"rn",	        2, NULL,	NUM_rn	 	},  /*r*/
-{ 	"sg",		2, NULL,	NUM_SG		},  /*s*/
-{ 	"sp",		2, NULL,	NUM_SP		},	
-{ 	"s",		1, NULL,	NUM_S		},	
-{ 	"th",	        2, NULL,	NUM_th	 	},  /*t*/	
-{ 	"v",		1, NULL,	NUM_V		},  /*v*/	
-
-/* last */	
-{	NULL,		0, NULL,	0 		}};
+static KeyWord NUM_keywords[] = {
+/*	keyword,	len, func.	type			   is in Index */
+	{",", 1, NULL, NUM_COMMA},	/* , */
+	{".", 1, NULL, NUM_DEC},	/* . */
+	{"0", 1, NULL, NUM_0},		/* 0 */
+	{"9", 1, NULL, NUM_9},		/* 9 */
+	{"B", 1, NULL, NUM_B},		/* B */
+	{"C", 1, NULL, NUM_C},		/* C */
+	{"D", 1, NULL, NUM_D},		/* D */
+	{"E", 1, NULL, NUM_E},		/* E */
+	{"FM", 2, NULL, NUM_FM},	/* F */
+	{"G", 1, NULL, NUM_G},		/* G */
+	{"L", 1, NULL, NUM_L},		/* L */
+	{"MI", 2, NULL, NUM_MI},	/* M */
+	{"PL", 2, NULL, NUM_PL},	/* P */
+	{"PR", 2, NULL, NUM_PR},
+	{"RN", 2, NULL, NUM_RN},	/* R */
+	{"SG", 2, NULL, NUM_SG},	/* S */
+	{"SP", 2, NULL, NUM_SP},
+	{"S", 1, NULL, NUM_S},
+	{"TH", 2, NULL, NUM_TH},	/* T */
+	{"V", 1, NULL, NUM_V},		/* V */
+	{"b", 1, NULL, NUM_B},		/* b */
+	{"c", 1, NULL, NUM_C},		/* c */
+	{"d", 1, NULL, NUM_D},		/* d */
+	{"e", 1, NULL, NUM_E},		/* e */
+	{"fm", 2, NULL, NUM_FM},	/* f */
+	{"g", 1, NULL, NUM_G},		/* g */
+	{"l", 1, NULL, NUM_L},		/* l */
+	{"mi", 2, NULL, NUM_MI},	/* m */
+	{"pl", 2, NULL, NUM_PL},	/* p */
+	{"pr", 2, NULL, NUM_PR},
+	{"rn", 2, NULL, NUM_rn},	/* r */
+	{"sg", 2, NULL, NUM_SG},	/* s */
+	{"sp", 2, NULL, NUM_SP},
+	{"s", 1, NULL, NUM_S},
+	{"th", 2, NULL, NUM_th},	/* t */
+	{"v", 1, NULL, NUM_V},		/* v */
+
+/* last */
+{NULL, 0, NULL, 0}};
 
 
 /* ----------
  * KeyWords index for DATE-TIME version
  * ----------
  */
-static int DCH_index[ KeyWord_INDEX_SIZE ] = {
+static int	DCH_index[KeyWord_INDEX_SIZE] = {
 /*
 0	1	2	3	4	5	6	7	8	9
 */
 	/*---- first 0..31 chars are skiped ----*/
 
-		-1,	-1,	-1,	-1,	-1,	-1,	-1,	-1,
--1,	-1,	-1,	-1,	-1,	-1,	-1,	-1,	-1,	-1,
--1,	-1,	-1,	-1,	-1,	-1,	-1,	-1,	-1,	-1,
--1,	-1,	-1,	-1,	-1,	DCH_A_D,DCH_B_C,DCH_CC,	DCH_DAY,-1,	
-DCH_FX,	-1,	DCH_HH24,-1,	DCH_J,	-1,	-1,	DCH_MI,	-1,	-1,
-DCH_P_M, DCH_Q,	DCH_RM,	DCH_SSSS,-1,	-1,	-1,	DCH_WW,	-1,	DCH_Y_YYY,
--1,	-1,	-1,	-1,	-1,	-1,	-1,	DCH_a_d,DCH_b_c,DCH_cc,
-DCH_day,-1,	DCH_fx,	-1,	DCH_hh24,-1,	DCH_j,	-1,	-1,	DCH_mi,	
--1,	-1,	DCH_p_m, DCH_q,	DCH_rm,	DCH_ssss,-1,	-1,	-1,	DCH_ww,
--1,	DCH_y_yyy,-1,	-1,	-1,	-1
+	-1, -1, -1, -1, -1, -1, -1, -1,
+	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+	-1, -1, -1, -1, -1, DCH_A_D, DCH_B_C, DCH_CC, DCH_DAY, -1,
+	DCH_FX, -1, DCH_HH24, -1, DCH_J, -1, -1, DCH_MI, -1, -1,
+	DCH_P_M, DCH_Q, DCH_RM, DCH_SSSS, -1, -1, -1, DCH_WW, -1, DCH_Y_YYY,
+	-1, -1, -1, -1, -1, -1, -1, DCH_a_d, DCH_b_c, DCH_cc,
+	DCH_day, -1, DCH_fx, -1, DCH_hh24, -1, DCH_j, -1, -1, DCH_mi,
+	-1, -1, DCH_p_m, DCH_q, DCH_rm, DCH_ssss, -1, -1, -1, DCH_ww,
+	-1, DCH_y_yyy, -1, -1, -1, -1
 
 	/*---- chars over 126 are skiped ----*/
-};	
+};
 
 /* ----------
  * KeyWords index for NUMBER version
  * ----------
  */
-static int NUM_index[ KeyWord_INDEX_SIZE ] = {
+static int	NUM_index[KeyWord_INDEX_SIZE] = {
 /*
 0	1	2	3	4	5	6	7	8	9
 */
 	/*---- first 0..31 chars are skiped ----*/
 
-		-1,	-1,	-1,	-1,	-1,	-1,	-1,	-1,
--1,	-1,	-1,	-1,	NUM_COMMA,-1,	NUM_DEC,-1,	NUM_0,	-1,
--1,	-1,	-1,	-1,	-1,	-1,	-1,	NUM_9,	-1,	-1,
--1,	-1,	-1,	-1,	-1,	-1,	NUM_B,	NUM_C,	NUM_D,	NUM_E,	
-NUM_FM,	NUM_G,	-1,	-1,	-1,	-1,	NUM_L,	NUM_MI,	-1,	-1,
-NUM_PL,-1,	NUM_RN,	NUM_SG,	NUM_TH,	-1,	NUM_V,	-1,	-1,	-1,
--1,	-1,	-1,	-1,	-1,	-1,	-1,	-1,	NUM_b,	NUM_c,
-NUM_d,	NUM_e,	NUM_fm,	NUM_g,	-1,	-1,	-1,	-1,	NUM_l,	NUM_mi,	
--1,	-1,	NUM_pl,	-1,	NUM_rn,	NUM_sg,	NUM_th,	-1,	NUM_v,	-1,
--1,	-1,	-1,	-1,	-1,	-1
+	-1, -1, -1, -1, -1, -1, -1, -1,
+	-1, -1, -1, -1, NUM_COMMA, -1, NUM_DEC, -1, NUM_0, -1,
+	-1, -1, -1, -1, -1, -1, -1, NUM_9, -1, -1,
+	-1, -1, -1, -1, -1, -1, NUM_B, NUM_C, NUM_D, NUM_E,
+	NUM_FM, NUM_G, -1, -1, -1, -1, NUM_L, NUM_MI, -1, -1,
+	NUM_PL, -1, NUM_RN, NUM_SG, NUM_TH, -1, NUM_V, -1, -1, -1,
+	-1, -1, -1, -1, -1, -1, -1, -1, NUM_b, NUM_c,
+	NUM_d, NUM_e, NUM_fm, NUM_g, -1, -1, -1, -1, NUM_l, NUM_mi,
+	-1, -1, NUM_pl, -1, NUM_rn, NUM_sg, NUM_th, -1, NUM_v, -1,
+	-1, -1, -1, -1, -1, -1
 
 	/*---- chars over 126 are skiped ----*/
 };
@@ -726,32 +737,33 @@ NUM_d,	NUM_e,	NUM_fm,	NUM_g,	-1,	-1,	-1,	-1,	NUM_l,	NUM_mi,
  */
 typedef struct NUMProc
 {
-	int	type;		/* FROM_CHAR (TO_NUMBER) or TO_CHAR */
-
-	NUMDesc	*Num;		/* number description		*/	
-	
-	int	sign,		/* '-' or '+'			*/
-		sign_wrote,	/* was sign write		*/
-		sign_pos,	/* pre number sign position	*/
-		num_count,	/* number of write digits 	*/
-		num_in,		/* is inside number		*/
-		num_curr,	/* current position in number 	*/
-		num_pre,	/* space before first number	*/
-	
-		read_dec,	/* to_number - was read dec. point  */
-		read_post;	/* to_number - number of dec. digit */
-		
-	char	*number,	/* string with number	*/
-		*number_p,	/* pointer to current number pozition */
-		*inout,		/* in / out buffer	*/
-		*inout_p,	/* pointer to current inout pozition */
-		*last_relevant,	/* last relevant number after decimal point */
-		
-		*L_negative_sign,	/* Locale */
-		*L_positive_sign,
-		*decimal,	
-		*L_thousands_sep,
-		*L_currency_symbol;
+	int			type;			/* FROM_CHAR (TO_NUMBER) or TO_CHAR */
+
+	NUMDesc    *Num;			/* number description		*/
+
+	int			sign,			/* '-' or '+'			*/
+				sign_wrote,		/* was sign write		*/
+				sign_pos,		/* pre number sign position */
+				num_count,		/* number of write digits	*/
+				num_in,			/* is inside number		*/
+				num_curr,		/* current position in number	*/
+				num_pre,		/* space before first number	*/
+
+				read_dec,		/* to_number - was read dec. point	*/
+				read_post;		/* to_number - number of dec. digit */
+
+	char	   *number,			/* string with number	*/
+			   *number_p,		/* pointer to current number pozition */
+			   *inout,			/* in / out buffer	*/
+			   *inout_p,		/* pointer to current inout pozition */
+			   *last_relevant,	/* last relevant number after decimal
+								 * point */
+
+			   *L_negative_sign,/* Locale */
+			   *L_positive_sign,
+			   *decimal,
+			   *L_thousands_sep,
+			   *L_currency_symbol;
 } NUMProc;
 
 
@@ -762,38 +774,40 @@ typedef struct NUMProc
 static KeyWord *index_seq_search(char *str, KeyWord *kw, int *index);
 static KeySuffix *suff_search(char *str, KeySuffix *suf, int type);
 static void NUMDesc_prepare(NUMDesc *num, FormatNode *n);
-static void parse_format(FormatNode *node, char *str, KeyWord *kw, 
-		KeySuffix *suf, int *index, int ver, NUMDesc *Num);
+static void parse_format(FormatNode *node, char *str, KeyWord *kw,
+			 KeySuffix *suf, int *index, int ver, NUMDesc *Num);
 static char *DCH_processor(FormatNode *node, char *inout, int flag);
 
 #ifdef DEBUG_TO_FROM_CHAR
-	static void dump_index(KeyWord *k, int *index);
-	static void dump_node(FormatNode *node, int max);
+static void dump_index(KeyWord *k, int *index);
+static void dump_node(FormatNode *node, int max);
+
 #endif
 
 static char *get_th(char *num, int type);
 static char *str_numth(char *dest, char *num, int type);
-static int int4len(int4 num);
+static int	int4len(int4 num);
 static char *str_toupper(char *buff);
 static char *str_tolower(char *buff);
+
 /* static int is_acdc(char *str, int *len); */
-static int seq_search(char *name, char **array, int type, int max, int *len);
-static int dch_global(int arg, char *inout, int suf, int flag, FormatNode *node); 
-static int dch_time(int arg, char *inout, int suf, int flag, FormatNode *node);
-static int dch_date(int arg, char *inout, int suf, int flag, FormatNode *node);
+static int	seq_search(char *name, char **array, int type, int max, int *len);
+static int	dch_global(int arg, char *inout, int suf, int flag, FormatNode *node);
+static int	dch_time(int arg, char *inout, int suf, int flag, FormatNode *node);
+static int	dch_date(int arg, char *inout, int suf, int flag, FormatNode *node);
 static char *fill_str(char *str, int c, int max);
-static FormatNode *NUM_cache( int len, NUMDesc *Num, char *pars_str, int *flag);
+static FormatNode *NUM_cache(int len, NUMDesc *Num, char *pars_str, int *flag);
 static char *int_to_roman(int number);
 static void NUM_prepare_locale(NUMProc *Np);
 static char *get_last_relevant_decnum(char *num);
-static void NUM_numpart_from_char(NUMProc *Np, int id, int plen); 
-static void NUM_numpart_to_char(NUMProc *Np, int id); 
-static char *NUM_processor (FormatNode *node, NUMDesc *Num, char *inout, char *number, 
-					int plen, int sign, int type);
-static DCHCacheEntry *DCH_cache_search( char *str );
-static DCHCacheEntry *DCH_cache_getnew( char *str );
-static NUMCacheEntry *NUM_cache_search( char *str );
-static NUMCacheEntry *NUM_cache_getnew( char *str );
+static void NUM_numpart_from_char(NUMProc *Np, int id, int plen);
+static void NUM_numpart_to_char(NUMProc *Np, int id);
+static char *NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
+			  int plen, int sign, int type);
+static DCHCacheEntry *DCH_cache_search(char *str);
+static DCHCacheEntry *DCH_cache_getnew(char *str);
+static NUMCacheEntry *NUM_cache_search(char *str);
+static NUMCacheEntry *NUM_cache_getnew(char *str);
 
 
 /* ----------
@@ -803,24 +817,26 @@ static NUMCacheEntry *NUM_cache_getnew( char *str );
  * ----------
  */
 static KeyWord *
-index_seq_search(char *str, KeyWord *kw, int *index) 
+index_seq_search(char *str, KeyWord *kw, int *index)
 {
-	int	poz;
+	int			poz;
 
-	if (! KeyWord_INDEX_FILTER(*str))
+	if (!KeyWord_INDEX_FILTER(*str))
 		return (KeyWord *) NULL;
 
-	if ( (poz =  *(index + (*str - ' '))) > -1) {
-	
-		KeyWord		*k = kw+poz;
-	
-		do {
-			if (! strncmp(str, k->name, k->len))
+	if ((poz = *(index + (*str - ' '))) > -1)
+	{
+
+		KeyWord    *k = kw + poz;
+
+		do
+		{
+			if (!strncmp(str, k->name, k->len))
 				return k;
 			k++;
 			if (!k->name)
-				return (KeyWord *) NULL;		  
-		} while(*str == *k->name);
+				return (KeyWord *) NULL;
+		} while (*str == *k->name);
 	}
 	return (KeyWord *) NULL;
 }
@@ -828,12 +844,13 @@ index_seq_search(char *str, KeyWord *kw, int *index)
 static KeySuffix *
 suff_search(char *str, KeySuffix *suf, int type)
 {
-	KeySuffix	*s;
-	
-	for(s=suf; s->name != NULL; s++) {
+	KeySuffix  *s;
+
+	for (s = suf; s->name != NULL; s++)
+	{
 		if (s->type != type)
 			continue;
-		
+
 		if (!strncmp(str, s->name, s->len))
 			return s;
 	}
@@ -844,152 +861,158 @@ suff_search(char *str, KeySuffix *suf, int type)
  * Prepare NUMDesc (number description struct) via FormatNode struct
  * ----------
  */
-static void 
+static void
 NUMDesc_prepare(NUMDesc *num, FormatNode *n)
 {
 
 	if (n->type != NODE_TYPE_ACTION)
 		return;
-	
-	switch(n->key->id) {
-		
+
+	switch (n->key->id)
+	{
+
 		case NUM_9:
 			if (IS_BRACKET(num))
-				elog(ERROR, "to_char/to_number(): '9' must be ahead of 'PR'.");   
-			
-			if (IS_MULTI(num)) {
+				elog(ERROR, "to_char/to_number(): '9' must be ahead of 'PR'.");
+
+			if (IS_MULTI(num))
+			{
 				++num->multi;
 				break;
 			}
 			if (IS_DECIMAL(num))
 				++num->post;
-			else 
+			else
 				++num->pre;
 			break;
-		
+
 		case NUM_0:
 			if (IS_BRACKET(num))
-				elog(ERROR, "to_char/to_number(): '0' must be ahead of 'PR'.");   
+				elog(ERROR, "to_char/to_number(): '0' must be ahead of 'PR'.");
 
-			if (!IS_ZERO(num) && !IS_DECIMAL(num)) {
-				num->flag |= NUM_F_ZERO; 
+			if (!IS_ZERO(num) && !IS_DECIMAL(num))
+			{
+				num->flag |= NUM_F_ZERO;
 				num->zero_start = num->pre + 1;
 			}
-			if (! IS_DECIMAL(num))
+			if (!IS_DECIMAL(num))
 				++num->pre;
-			else 
+			else
 				++num->post;
-				
+
 			num->zero_end = num->pre + num->post;
-			break;	
-		
+			break;
+
 		case NUM_B:
-			if (num->pre == 0 && num->post == 0 && (! IS_ZERO(num)))
-				num->flag |= NUM_F_BLANK; 				
-			break;		
-		
+			if (num->pre == 0 && num->post == 0 && (!IS_ZERO(num)))
+				num->flag |= NUM_F_BLANK;
+			break;
+
 		case NUM_D:
 			num->flag |= NUM_F_LDECIMAL;
 			num->need_locale = TRUE;
 		case NUM_DEC:
 			if (IS_DECIMAL(num))
-				elog(ERROR, "to_char/to_number(): not unique decimal poit."); 
+				elog(ERROR, "to_char/to_number(): not unique decimal poit.");
 			if (IS_MULTI(num))
-				elog(ERROR, "to_char/to_number(): can't use 'V' and decimal poin together."); 	
+				elog(ERROR, "to_char/to_number(): can't use 'V' and decimal poin together.");
 			num->flag |= NUM_F_DECIMAL;
 			break;
-		
+
 		case NUM_FM:
 			num->flag |= NUM_F_FILLMODE;
 			break;
-		
+
 		case NUM_S:
 			if (IS_LSIGN(num))
-				elog(ERROR, "to_char/to_number(): not unique 'S'.");   
-			
+				elog(ERROR, "to_char/to_number(): not unique 'S'.");
+
 			if (IS_PLUS(num) || IS_MINUS(num) || IS_BRACKET(num))
-				elog(ERROR, "to_char/to_number(): can't use 'S' and 'PL'/'MI'/'SG'/'PR' together."); 	
-			
-			if (! IS_DECIMAL(num)) {
+				elog(ERROR, "to_char/to_number(): can't use 'S' and 'PL'/'MI'/'SG'/'PR' together.");
+
+			if (!IS_DECIMAL(num))
+			{
 				num->lsign = NUM_LSIGN_PRE;
 				num->pre_lsign_num = num->pre;
 				num->need_locale = TRUE;
 				num->flag |= NUM_F_LSIGN;
-				
-			} else if (num->lsign == NUM_LSIGN_NONE) {
-				num->lsign = NUM_LSIGN_POST;	
+
+			}
+			else if (num->lsign == NUM_LSIGN_NONE)
+			{
+				num->lsign = NUM_LSIGN_POST;
 				num->need_locale = TRUE;
 				num->flag |= NUM_F_LSIGN;
-			}	
+			}
 			break;
-		
+
 		case NUM_MI:
 			if (IS_LSIGN(num))
-				elog(ERROR, "to_char/to_number(): can't use 'S' and 'MI' together."); 	
-			
+				elog(ERROR, "to_char/to_number(): can't use 'S' and 'MI' together.");
+
 			num->flag |= NUM_F_MINUS;
 			break;
-		
+
 		case NUM_PL:
 			if (IS_LSIGN(num))
-				elog(ERROR, "to_char/to_number(): can't use 'S' and 'PL' together."); 	
-			
+				elog(ERROR, "to_char/to_number(): can't use 'S' and 'PL' together.");
+
 			num->flag |= NUM_F_PLUS;
-			break;		
-		
+			break;
+
 		case NUM_SG:
 			if (IS_LSIGN(num))
-				elog(ERROR, "to_char/to_number(): can't use 'S' and 'SG' together."); 	
-			
+				elog(ERROR, "to_char/to_number(): can't use 'S' and 'SG' together.");
+
 			num->flag |= NUM_F_MINUS;
 			num->flag |= NUM_F_PLUS;
 			break;
-		
+
 		case NUM_PR:
 			if (IS_LSIGN(num) || IS_PLUS(num) || IS_MINUS(num))
-				elog(ERROR, "to_char/to_number(): can't use 'PR' and 'S'/'PL'/'MI'/'SG' together.");   
+				elog(ERROR, "to_char/to_number(): can't use 'PR' and 'S'/'PL'/'MI'/'SG' together.");
 			num->flag |= NUM_F_BRACKET;
-			break;	
-	
+			break;
+
 		case NUM_rn:
 		case NUM_RN:
 			num->flag |= NUM_F_ROMAN;
 			break;
-			
+
 		case NUM_L:
 		case NUM_G:
-			num->need_locale = TRUE;	
+			num->need_locale = TRUE;
 			break;
-		
+
 		case NUM_V:
 			if (IS_DECIMAL(num))
-				elog(ERROR, "to_char/to_number(): can't use 'V' and decimal poin together."); 	
+				elog(ERROR, "to_char/to_number(): can't use 'V' and decimal poin together.");
 			num->flag |= NUM_F_MULTI;
-			break;	
-		
+			break;
+
 		case NUM_E:
-			elog(ERROR, "to_char/to_number(): 'E' is not supported."); 	
+			elog(ERROR, "to_char/to_number(): 'E' is not supported.");
 	}
-	
+
 	return;
 }
 
 /* ----------
- * Format parser, search small keywords and keyword's suffixes, and make 
+ * Format parser, search small keywords and keyword's suffixes, and make
  * format-node tree.
  *
- * for DATE-TIME & NUMBER version 
+ * for DATE-TIME & NUMBER version
  * ----------
  */
-static void 
-parse_format(FormatNode *node, char *str, KeyWord *kw, 
-		KeySuffix *suf, int *index, int ver, NUMDesc *Num)
+static void
+parse_format(FormatNode *node, char *str, KeyWord *kw,
+			 KeySuffix *suf, int *index, int ver, NUMDesc *Num)
 {
-	KeySuffix	*s;
-	FormatNode	*n;
-	int		node_set=0,
-			suffix,
-			last=0;
+	KeySuffix  *s;
+	FormatNode *n;
+	int			node_set = 0,
+				suffix,
+				last = 0;
 
 #ifdef DEBUG_TO_FROM_CHAR
 	elog(DEBUG_elog_output, "to_char/number(): run parser.");
@@ -997,63 +1020,74 @@ parse_format(FormatNode *node, char *str, KeyWord *kw,
 
 	n = node;
 
-	while(*str) {
-		suffix=0;
-		
-		/* ---------- 
-		 * Prefix 
+	while (*str)
+	{
+		suffix = 0;
+
+		/* ----------
+		 * Prefix
 		 * ----------
 		 */
-		if (ver==DCH_TYPE && (s = suff_search(str, suf, SUFFTYPE_PREFIX)) != NULL) {
+		if (ver == DCH_TYPE && (s = suff_search(str, suf, SUFFTYPE_PREFIX)) != NULL)
+		{
 			suffix |= s->id;
 			if (s->len)
 				str += s->len;
 		}
-	
+
 		/* ----------
-		 * Keyword 
+		 * Keyword
 		 * ----------
 		 */
-		if (*str && (n->key = index_seq_search(str, kw, index)) != NULL) {
-		
+		if (*str && (n->key = index_seq_search(str, kw, index)) != NULL)
+		{
+
 			n->type = NODE_TYPE_ACTION;
 			n->suffix = 0;
-			node_set= 1;
+			node_set = 1;
 			if (n->key->len)
 				str += n->key->len;
-			
+
 			/* ----------
-			 * NUM version: Prepare global NUMDesc struct 
+			 * NUM version: Prepare global NUMDesc struct
 			 * ----------
 			 */
-			if (ver==NUM_TYPE)
+			if (ver == NUM_TYPE)
 				NUMDesc_prepare(Num, n);
-			
+
 			/* ----------
 			 * Postfix
 			 * ----------
 			 */
-			if (ver==DCH_TYPE && *str && (s = suff_search(str, suf, SUFFTYPE_POSTFIX)) != NULL) {
+			if (ver == DCH_TYPE && *str && (s = suff_search(str, suf, SUFFTYPE_POSTFIX)) != NULL)
+			{
 				suffix |= s->id;
 				if (s->len)
 					str += s->len;
 			}
-			
-		} else if (*str) {
-		
-			/* ---------- 
-			 * Special characters '\' and '"' 
+
+		}
+		else if (*str)
+		{
+
+			/* ----------
+			 * Special characters '\' and '"'
 			 * ----------
 			 */
-			if (*str == '"' && last != '\\') {
-				
-				int	x = 0;
-			
-				while(*(++str)) {
-					if (*str == '"' && x != '\\') {
+			if (*str == '"' && last != '\\')
+			{
+
+				int			x = 0;
+
+				while (*(++str))
+				{
+					if (*str == '"' && x != '\\')
+					{
 						str++;
 						break;
-					} else if (*str == '\\' && x != '\\') {
+					}
+					else if (*str == '\\' && x != '\\')
+					{
 						x = '\\';
 						continue;
 					}
@@ -1062,17 +1096,21 @@ parse_format(FormatNode *node, char *str, KeyWord *kw,
 					n->key = (KeyWord *) NULL;
 					n->suffix = 0;
 					++n;
-					x = *str; 
+					x = *str;
 				}
 				node_set = 0;
 				suffix = 0;
 				last = 0;
-				
-			} else if (*str && *str == '\\' && last!='\\' && *(str+1) =='"') {
+
+			}
+			else if (*str && *str == '\\' && last != '\\' && *(str + 1) == '"')
+			{
 				last = *str;
 				str++;
-			
-			} else if (*str) {
+
+			}
+			else if (*str)
+			{
 				n->type = NODE_TYPE_CHAR;
 				n->character = *str;
 				n->key = (KeyWord *) NULL;
@@ -1080,19 +1118,20 @@ parse_format(FormatNode *node, char *str, KeyWord *kw,
 				last = 0;
 				str++;
 			}
-			
+
 		}
-				
-		/* end */	
-		if (node_set) {
-			if (n->type == NODE_TYPE_ACTION) 
-				n->suffix = suffix;	
+
+		/* end */
+		if (node_set)
+		{
+			if (n->type == NODE_TYPE_ACTION)
+				n->suffix = suffix;
 			++n;
 
 			n->suffix = 0;
 			node_set = 0;
 		}
-			
+
 	}
 
 	n->type = NODE_TYPE_END;
@@ -1101,62 +1140,68 @@ parse_format(FormatNode *node, char *str, KeyWord *kw,
 }
 
 /* ----------
- * Call keyword's function for each of (action) node in format-node tree 
+ * Call keyword's function for each of (action) node in format-node tree
  * ----------
  */
 static char *
 DCH_processor(FormatNode *node, char *inout, int flag)
 {
-	FormatNode	*n;
-	char		*s;
-	
-	
+	FormatNode *n;
+	char	   *s;
+
+
 	/* ----------
 	 * Zeroing global flags
 	 * ----------
 	 */
 	DCH_global_flag = 0;
-	
-	for(n=node, s=inout; n->type != NODE_TYPE_END; n++) {
-		if (n->type == NODE_TYPE_ACTION) {
-			
-			int 	len;
-			
+
+	for (n = node, s = inout; n->type != NODE_TYPE_END; n++)
+	{
+		if (n->type == NODE_TYPE_ACTION)
+		{
+
+			int			len;
+
 			/* ----------
-			 * Call node action function 
+			 * Call node action function
 			 * ----------
 			 */
-			len = n->key->action(n->key->id, s, n->suffix, flag, n); 	
-			if (len > 0) 
+			len = n->key->action(n->key->id, s, n->suffix, flag, n);
+			if (len > 0)
 				s += len;
 			else if (len == -1)
-				continue;	
-				
-		} else {
-		
+				continue;
+
+		}
+		else
+		{
+
 			/* ----------
 			 * Remove to output char from input in TO_CHAR
 			 * ----------
 			 */
-			if (flag == TO_CHAR) 
+			if (flag == TO_CHAR)
 				*s = n->character;
-			
-			else {				
+
+			else
+			{
 				/* ----------
-				 * Skip blank space in FROM_CHAR's input 
+				 * Skip blank space in FROM_CHAR's input
 				 * ----------
 				 */
-				if (isspace(n->character) && IS_FX == 0) {
-					while(*s != '\0' && isspace(*(s+1)))
-						++s;	
+				if (isspace(n->character) && IS_FX == 0)
+				{
+					while (*s != '\0' && isspace(*(s + 1)))
+						++s;
 				}
 			}
 		}
-		
-		++s;	/* ! */
-		
+
+		++s;					/* ! */
+
 	}
-	
+
 	if (flag == TO_CHAR)
 		*s = '\0';
 	return inout;
@@ -1172,91 +1217,101 @@ DCH_processor(FormatNode *node, char *inout, int flag)
 #define DUMP_THth(_suf) (S_TH(_suf) ? "TH" : (S_th(_suf) ? "th" : " "))
 #define DUMP_FM(_suf)	(S_FM(_suf) ? "FM" : " ")
 
-static void 
+static void
 dump_node(FormatNode *node, int max)
 {
-	FormatNode	*n;
-	int		a;
-	
+	FormatNode *n;
+	int			a;
+
 	elog(DEBUG_elog_output, "to_from-char(): DUMP FORMAT");
-	
-	for(a=0, n=node; a<=max; n++, a++) {
-		if (n->type == NODE_TYPE_ACTION) 
-			elog(DEBUG_elog_output, "%d:\t NODE_TYPE_ACTION '%s'\t(%s,%s)", 
-					a, n->key->name, DUMP_THth(n->suffix), DUMP_FM(n->suffix));
-		else if (n->type == NODE_TYPE_CHAR) 
-			elog(DEBUG_elog_output, "%d:\t NODE_TYPE_CHAR '%c'", a, n->character);	
-		else if (n->type == NODE_TYPE_END) {
-			elog(DEBUG_elog_output, "%d:\t NODE_TYPE_END", a);		
+
+	for (a = 0, n = node; a <= max; n++, a++)
+	{
+		if (n->type == NODE_TYPE_ACTION)
+			elog(DEBUG_elog_output, "%d:\t NODE_TYPE_ACTION '%s'\t(%s,%s)",
+			  a, n->key->name, DUMP_THth(n->suffix), DUMP_FM(n->suffix));
+		else if (n->type == NODE_TYPE_CHAR)
+			elog(DEBUG_elog_output, "%d:\t NODE_TYPE_CHAR '%c'", a, n->character);
+		else if (n->type == NODE_TYPE_END)
+		{
+			elog(DEBUG_elog_output, "%d:\t NODE_TYPE_END", a);
 			return;
-		} else
-			elog(DEBUG_elog_output, "%d:\t UnKnown NODE !!!", a);	
-			
+		}
+		else
+			elog(DEBUG_elog_output, "%d:\t UnKnown NODE !!!", a);
+
 	}
 }
+
 #endif
 
 /*****************************************************************************
- *			Private utils 
+ *			Private utils
  *****************************************************************************/
 
 /* ----------
- * Return ST/ND/RD/TH for simple (1..9) numbers 
+ * Return ST/ND/RD/TH for simple (1..9) numbers
  * type --> 0 upper, 1 lower
- * ----------	
- */	
+ * ----------
+ */
 static char *
 get_th(char *num, int type)
 {
-	int	len = strlen(num),
-		last;				
-	
-	last = *(num + (len-1));
+	int			len = strlen(num),
+				last;
+
+	last = *(num + (len - 1));
 	if (!isdigit((unsigned char) last))
 		elog(ERROR, "get_th: '%s' is not number.", num);
-	
+
 	/* 11 || 12 */
-	if (len == 2 && (last=='1' || last=='2') && *num == '1') 
-		last=0;
+	if (len == 2 && (last == '1' || last == '2') && *num == '1')
+		last = 0;
 
-	switch(last) {
+	switch (last)
+	{
 		case '1':
-			if (type==TH_UPPER) return numTH[0];
+			if (type == TH_UPPER)
+				return numTH[0];
 			return numth[0];
 		case '2':
-			if (type==TH_UPPER) return numTH[1];
+			if (type == TH_UPPER)
+				return numTH[1];
 			return numth[1];
 		case '3':
-			if (type==TH_UPPER) return numTH[2];
-			return numth[2];		
+			if (type == TH_UPPER)
+				return numTH[2];
+			return numth[2];
 		default:
-			if (type==TH_UPPER) return numTH[3];
+			if (type == TH_UPPER)
+				return numTH[3];
 			return numth[3];
 	}
 	return NULL;
 }
 
 /* ----------
- * Convert string-number to ordinal string-number 
- * type --> 0 upper, 1 lower	
+ * Convert string-number to ordinal string-number
+ * type --> 0 upper, 1 lower
  * ----------
  */
 static char *
 str_numth(char *dest, char *num, int type)
 {
 	sprintf(dest, "%s%s", num, get_th(num, type));
-	return dest; 
+	return dest;
 }
 
 /* ----------
- * Return length of integer writed in string 
+ * Return length of integer writed in string
  * ----------
  */
-static int 
+static int
 int4len(int4 num)
 {
- 	char b[16];
- 	return sprintf(b, "%d", num);
+	char		b[16];
+
+	return sprintf(b, "%d", num);
 }
 
 /* ----------
@@ -1265,10 +1320,11 @@ int4len(int4 num)
  */
 static char *
 str_toupper(char *buff)
-{	
-	char	*p_buff=buff;
+{
+	char	   *p_buff = buff;
 
-	while (*p_buff) {
+	while (*p_buff)
+	{
 		*p_buff = toupper((unsigned char) *p_buff);
 		++p_buff;
 	}
@@ -1281,10 +1337,11 @@ str_toupper(char *buff)
  */
 static char *
 str_tolower(char *buff)
-{	
-	char	*p_buff=buff;
+{
+	char	   *p_buff = buff;
 
-	while (*p_buff) {
+	while (*p_buff)
+	{
 		*p_buff = tolower((unsigned char) *p_buff);
 		++p_buff;
 	}
@@ -1292,132 +1349,151 @@ str_tolower(char *buff)
 }
 
 /* ----------
- * Check if in string is AC or BC (return: 0==none; -1==BC; 1==AC)  
+ * Check if in string is AC or BC (return: 0==none; -1==BC; 1==AC)
  * ----------
  */
 /************* not used - use AD/BC format pictures instead  **********
-static int 
+static int
 is_acdc(char *str, int *len)
 {
 	char	*p;
-	
+
 	for(p=str; *p != '\0'; p++) {
 		if (isspace(*p))
 			continue;
-			
-		if (*(p+1)) { 
+
+		if (*(p+1)) {
 			if (toupper(*p)=='B' && toupper(*(++p))=='C') {
-			   	*len += (p - str) +1;
-				return -1;   	
+				*len += (p - str) +1;
+				return -1;
 			} else if (toupper(*p)=='A' && toupper(*(++p))=='C') {
-		   		*len += (p - str) +1;
-				return 1;   	
-		 	}
-		} 
-		return 0; 	
+				*len += (p - str) +1;
+				return 1;
+			}
+		}
+		return 0;
 	}
 	return 0;
-} 
+}
 ******************************/
- 
+
 /* ----------
  * Sequential search with to upper/lower conversion
  * ----------
  */
-static int 
+static int
 seq_search(char *name, char **array, int type, int max, int *len)
 {
-	char	*p, *n, **a;
-	int	last, i;
-	
+	char	   *p,
+			   *n,
+			  **a;
+	int			last,
+				i;
+
 	*len = 0;
-	
-	if (!*name) 
+
+	if (!*name)
 		return -1;
-	
-        /* set first char */	
-	if (type == ONE_UPPER || ALL_UPPER) 
+
+	/* set first char */
+	if (type == ONE_UPPER || ALL_UPPER)
 		*name = toupper((unsigned char) *name);
 	else if (type == ALL_LOWER)
 		*name = tolower((unsigned char) *name);
-		
-	for(last=0, a=array; *a != NULL; a++) {
-		
+
+	for (last = 0, a = array; *a != NULL; a++)
+	{
+
 		/* comperate first chars */
 		if (*name != **a)
 			continue;
-		
-		for(i=1, p=*a+1, n=name+1; ; n++, p++, i++) {
-			
+
+		for (i = 1, p = *a + 1, n = name + 1;; n++, p++, i++)
+		{
+
 			/* search fragment (max) only */
-			if (max && i == max) {
+			if (max && i == max)
+			{
 				*len = i;
 				return a - array;
-			} 
+			}
 			/* full size */
-			if (*p=='\0') {
+			if (*p == '\0')
+			{
 				*len = i;
 				return a - array;
 			}
 			/* Not found in array 'a' */
-			if (*n=='\0')
+			if (*n == '\0')
 				break;
-			
-			/* 
+
+			/*
 			 * Convert (but convert new chars only)
 			 */
-			if (i > last) {
-				if (type == ONE_UPPER || type == ALL_LOWER) 
+			if (i > last)
+			{
+				if (type == ONE_UPPER || type == ALL_LOWER)
 					*n = tolower((unsigned char) *n);
-				else if (type == ALL_UPPER)	
+				else if (type == ALL_UPPER)
 					*n = toupper((unsigned char) *n);
-				last=i;
+				last = i;
 			}
 
-#ifdef DEBUG_TO_FROM_CHAR			
-			/* elog(DEBUG_elog_output, "N: %c, P: %c, A: %s (%s)", *n, *p, *a, name);*/
-#endif			
+#ifdef DEBUG_TO_FROM_CHAR
+
+			/*
+			 * elog(DEBUG_elog_output, "N: %c, P: %c, A: %s (%s)", *n, *p,
+			 * *a, name);
+			 */
+#endif
 			if (*n != *p)
-				break; 
-		}  	
+				break;
+		}
 	}
-		
-	return -1;		
+
+	return -1;
 }
 
 
 #ifdef DEBUG_TO_FROM_CHAR
 /* -----------
- * DEBUG: Call for debug and for index checking; (Show ASCII char 
- * and defined keyword for each used position  
+ * DEBUG: Call for debug and for index checking; (Show ASCII char
+ * and defined keyword for each used position
  * ----------
- */	
-static void 
+ */
+static void
 dump_index(KeyWord *k, int *index)
 {
-	int	i, count=0, free_i=0;
-	
+	int			i,
+				count = 0,
+				free_i = 0;
+
 	elog(DEBUG_elog_output, "TO-FROM_CHAR: Dump KeyWord Index:");
-	
-	for(i=0; i < KeyWord_INDEX_SIZE; i++) {
-		if (index[i] != -1) {
-			elog(DEBUG_elog_output, "\t%c: %s, ", i+32, k[ index[i] ].name);
+
+	for (i = 0; i < KeyWord_INDEX_SIZE; i++)
+	{
+		if (index[i] != -1)
+		{
+			elog(DEBUG_elog_output, "\t%c: %s, ", i + 32, k[index[i]].name);
 			count++;
-		} else {
-			free_i++;	
-			elog(DEBUG_elog_output, "\t(%d) %c %d", i, i+32, index[i]);
 		}
-	}	
+		else
+		{
+			free_i++;
+			elog(DEBUG_elog_output, "\t(%d) %c %d", i, i + 32, index[i]);
+		}
+	}
 	elog(DEBUG_elog_output, "\n\t\tUsed positions: %d,\n\t\tFree positions: %d",
-		count, free_i);		
+		 count, free_i);
 }
+
 #endif
 
 /* ----------
  * Skip TM / th in FROM_CHAR
  * ----------
  */
-#define SKIP_THth(_suf)		(S_THth(_suf) ? 2 : 0)   
+#define SKIP_THth(_suf)		(S_THth(_suf) ? 2 : 0)
 
 
 /* ----------
@@ -1425,725 +1501,865 @@ dump_index(KeyWord *k, int *index)
  * ----------
  */
 static int
-dch_global(int arg, char *inout, int suf, int flag, FormatNode *node) 
+dch_global(int arg, char *inout, int suf, int flag, FormatNode *node)
 {
-	switch(arg) {
-	
-	case DCH_FX:
-		DCH_global_flag	|= DCH_F_FX;
-		break;
+	switch (arg)
+	{
+
+			case DCH_FX:
+			DCH_global_flag |= DCH_F_FX;
+			break;
 	}
 	return -1;
 }
 
 /* ----------
- * Master function of TIME for: 
- *                    TO_CHAR   - write (inout) formated string
- *                    FROM_CHAR - scan (inout) string by course of FormatNode 
+ * Master function of TIME for:
+ *					  TO_CHAR	- write (inout) formated string
+ *					  FROM_CHAR - scan (inout) string by course of FormatNode
  * ----------
  */
-static int 
-dch_time(int arg, char *inout, int suf, int flag, FormatNode *node) 
+static int
+dch_time(int arg, char *inout, int suf, int flag, FormatNode *node)
 {
-	char	*p_inout = inout;
-
-	switch(arg) {
-
-	case DCH_A_M:
-	case DCH_P_M:
-		if (flag == TO_CHAR) {
-			strcpy(inout, (tm->tm_hour > 13 ? P_M_STR : A_M_STR ));
-			return 3;
-			
-		} else if (flag == FROM_CHAR) {
-			if (strncmp(inout, P_M_STR, 4)==0 && tm->tm_hour < 13)
-				tm->tm_hour += 12;
-			return 3;	 	
-		}
-
-	case DCH_AM:
-	case DCH_PM:
-		if (flag == TO_CHAR) {
-			strcpy(inout, (tm->tm_hour > 13 ? PM_STR : AM_STR ));
-			return 1;
-		
-		} else if (flag == FROM_CHAR) {
-			if (strncmp(inout, PM_STR, 2)==0 && tm->tm_hour < 13)
-				tm->tm_hour += 12;
-			return 1;	 	
-		}
-
-	case DCH_a_m:
-	case DCH_p_m:
-		if (flag == TO_CHAR) {
-			strcpy(inout, (tm->tm_hour > 13 ? p_m_STR : a_m_STR ));
-			return 3;
-		
-		} else if (flag == FROM_CHAR) {
-			if (strncmp(inout, p_m_STR, 4)==0 && tm->tm_hour < 13)
-				tm->tm_hour += 12;
-			return 3;	 	
-		}
-	
-	case DCH_am:
-	case DCH_pm:
-		if (flag == TO_CHAR) {
-			strcpy(inout, (tm->tm_hour > 13 ? pm_STR : am_STR ));
-			return 1;
-		
-		} else if (flag == FROM_CHAR) {
-			if (strncmp(inout, pm_STR, 2)==0 && tm->tm_hour < 13)
-				tm->tm_hour += 12;
-			return 1;	 	
-		}		
-	
-	case DCH_HH:	
-	case DCH_HH12:
-		if (flag == TO_CHAR) {
-			sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, 
-				tm->tm_hour==0 ? 12 :
-				tm->tm_hour <13	? tm->tm_hour : tm->tm_hour-12);
-			if (S_THth(suf)) 
-				str_numth(p_inout, inout, 0);
-			if (S_FM(suf) || S_THth(suf)) 
-				return strlen(p_inout)-1;
-			else 
-				return 1;
-			
-		} else if (flag == FROM_CHAR) {
-			if (S_FM(suf)) {
-				sscanf(inout, "%d", &tm->tm_hour);
-				return int4len((int4) tm->tm_hour)-1 + SKIP_THth(suf);
-			} else {
-				sscanf(inout, "%02d", &tm->tm_hour);
-				return 1 + SKIP_THth(suf);
+	char	   *p_inout = inout;
+
+	switch (arg)
+	{
+
+		case DCH_A_M:
+		case DCH_P_M:
+			if (flag == TO_CHAR)
+			{
+				strcpy(inout, (tm->tm_hour > 13 ? P_M_STR : A_M_STR));
+				return 3;
+
+			}
+			else if (flag == FROM_CHAR)
+			{
+				if (strncmp(inout, P_M_STR, 4) == 0 && tm->tm_hour < 13)
+					tm->tm_hour += 12;
+				return 3;
 			}
-		}
 
-	case DCH_HH24:
-		if (flag == TO_CHAR) {
-			sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, tm->tm_hour);
-			if (S_THth(suf)) 
-				str_numth(p_inout, inout, S_TH_TYPE(suf));
-			if (S_FM(suf) || S_THth(suf)) 
-				return strlen(p_inout) -1;
-			else 
+		case DCH_AM:
+		case DCH_PM:
+			if (flag == TO_CHAR)
+			{
+				strcpy(inout, (tm->tm_hour > 13 ? PM_STR : AM_STR));
 				return 1;
-		
-		} else if (flag == FROM_CHAR) {
-			if (S_FM(suf)) {
-				sscanf(inout, "%d", &tm->tm_hour);
-				return int4len((int4) tm->tm_hour)-1 + SKIP_THth(suf);
-			} else {
-				sscanf(inout, "%02d", &tm->tm_hour);
-				return 1 + SKIP_THth(suf);
+
 			}
-		}
-		
-	case DCH_MI:	
-		if (flag == TO_CHAR) {
-			sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, tm->tm_min);
-			if (S_THth(suf)) 
-				str_numth(p_inout, inout, S_TH_TYPE(suf));
-			if (S_FM(suf) || S_THth(suf)) 
-				return strlen(p_inout)-1;
-			else 
+			else if (flag == FROM_CHAR)
+			{
+				if (strncmp(inout, PM_STR, 2) == 0 && tm->tm_hour < 13)
+					tm->tm_hour += 12;
 				return 1;
-		
-		} else if (flag == FROM_CHAR) {
-			if (S_FM(suf)) {
-				sscanf(inout, "%d", &tm->tm_min);
-				return int4len((int4) tm->tm_min)-1 + SKIP_THth(suf);
-			} else {
-				sscanf(inout, "%02d", &tm->tm_min);
-				return 1 + SKIP_THth(suf);
 			}
-		}
-	case DCH_SS:	
-		if (flag == TO_CHAR) {
-			sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, tm->tm_sec);
-			if (S_THth(suf)) 
-				str_numth(p_inout, inout, S_TH_TYPE(suf));
-			if (S_FM(suf) || S_THth(suf)) 
-				return strlen(p_inout) -1;
-			else 
+
+		case DCH_a_m:
+		case DCH_p_m:
+			if (flag == TO_CHAR)
+			{
+				strcpy(inout, (tm->tm_hour > 13 ? p_m_STR : a_m_STR));
+				return 3;
+
+			}
+			else if (flag == FROM_CHAR)
+			{
+				if (strncmp(inout, p_m_STR, 4) == 0 && tm->tm_hour < 13)
+					tm->tm_hour += 12;
+				return 3;
+			}
+
+		case DCH_am:
+		case DCH_pm:
+			if (flag == TO_CHAR)
+			{
+				strcpy(inout, (tm->tm_hour > 13 ? pm_STR : am_STR));
 				return 1;
-		
-		} else if (flag == FROM_CHAR) {
-			if (S_FM(suf)) {
-				sscanf(inout, "%d", &tm->tm_sec);
-				return int4len((int4) tm->tm_sec)-1 + SKIP_THth(suf);
-			} else {
-				sscanf(inout, "%02d", &tm->tm_sec);
-				return 1 + SKIP_THth(suf);
+
 			}
-		}
-	case DCH_SSSS:	
-		if (flag == TO_CHAR) {
-			sprintf(inout, "%d", tm->tm_hour	* 3600	+
-				    tm->tm_min	* 60	+
-				    tm->tm_sec);
-			if (S_THth(suf)) 
-				str_numth(p_inout, inout, S_TH_TYPE(suf));
-			return strlen(p_inout)-1;		
-		}  else if (flag == FROM_CHAR) 
-			elog(ERROR, "to_timestamp(): SSSS is not supported");
-	}	
-	return -1;	
+			else if (flag == FROM_CHAR)
+			{
+				if (strncmp(inout, pm_STR, 2) == 0 && tm->tm_hour < 13)
+					tm->tm_hour += 12;
+				return 1;
+			}
+
+		case DCH_HH:
+		case DCH_HH12:
+			if (flag == TO_CHAR)
+			{
+				sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2,
+						tm->tm_hour == 0 ? 12 :
+					  tm->tm_hour < 13 ? tm->tm_hour : tm->tm_hour - 12);
+				if (S_THth(suf))
+					str_numth(p_inout, inout, 0);
+				if (S_FM(suf) || S_THth(suf))
+					return strlen(p_inout) - 1;
+				else
+					return 1;
+
+			}
+			else if (flag == FROM_CHAR)
+			{
+				if (S_FM(suf))
+				{
+					sscanf(inout, "%d", &tm->tm_hour);
+					return int4len((int4) tm->tm_hour) - 1 + SKIP_THth(suf);
+				}
+				else
+				{
+					sscanf(inout, "%02d", &tm->tm_hour);
+					return 1 + SKIP_THth(suf);
+				}
+			}
+
+		case DCH_HH24:
+			if (flag == TO_CHAR)
+			{
+				sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, tm->tm_hour);
+				if (S_THth(suf))
+					str_numth(p_inout, inout, S_TH_TYPE(suf));
+				if (S_FM(suf) || S_THth(suf))
+					return strlen(p_inout) - 1;
+				else
+					return 1;
+
+			}
+			else if (flag == FROM_CHAR)
+			{
+				if (S_FM(suf))
+				{
+					sscanf(inout, "%d", &tm->tm_hour);
+					return int4len((int4) tm->tm_hour) - 1 + SKIP_THth(suf);
+				}
+				else
+				{
+					sscanf(inout, "%02d", &tm->tm_hour);
+					return 1 + SKIP_THth(suf);
+				}
+			}
+
+		case DCH_MI:
+			if (flag == TO_CHAR)
+			{
+				sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, tm->tm_min);
+				if (S_THth(suf))
+					str_numth(p_inout, inout, S_TH_TYPE(suf));
+				if (S_FM(suf) || S_THth(suf))
+					return strlen(p_inout) - 1;
+				else
+					return 1;
+
+			}
+			else if (flag == FROM_CHAR)
+			{
+				if (S_FM(suf))
+				{
+					sscanf(inout, "%d", &tm->tm_min);
+					return int4len((int4) tm->tm_min) - 1 + SKIP_THth(suf);
+				}
+				else
+				{
+					sscanf(inout, "%02d", &tm->tm_min);
+					return 1 + SKIP_THth(suf);
+				}
+			}
+		case DCH_SS:
+			if (flag == TO_CHAR)
+			{
+				sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, tm->tm_sec);
+				if (S_THth(suf))
+					str_numth(p_inout, inout, S_TH_TYPE(suf));
+				if (S_FM(suf) || S_THth(suf))
+					return strlen(p_inout) - 1;
+				else
+					return 1;
+
+			}
+			else if (flag == FROM_CHAR)
+			{
+				if (S_FM(suf))
+				{
+					sscanf(inout, "%d", &tm->tm_sec);
+					return int4len((int4) tm->tm_sec) - 1 + SKIP_THth(suf);
+				}
+				else
+				{
+					sscanf(inout, "%02d", &tm->tm_sec);
+					return 1 + SKIP_THth(suf);
+				}
+			}
+		case DCH_SSSS:
+			if (flag == TO_CHAR)
+			{
+				sprintf(inout, "%d", tm->tm_hour * 3600 +
+						tm->tm_min * 60 +
+						tm->tm_sec);
+				if (S_THth(suf))
+					str_numth(p_inout, inout, S_TH_TYPE(suf));
+				return strlen(p_inout) - 1;
+			}
+			else if (flag == FROM_CHAR)
+				elog(ERROR, "to_timestamp(): SSSS is not supported");
+	}
+	return -1;
 }
 
 #define CHECK_SEQ_SEARCH(_l, _s) {					\
-	if (_l <= 0) { 							\
+	if (_l <= 0) {							\
 		elog(ERROR, "to_timestamp(): bad value for %s", _s);	\
 	}								\
 }
 
 /* ----------
  * Master of DATE for:
- *                    TO_CHAR   - write (inout) formated string
- *                    FROM_CHAR - scan (inout) string by course of FormatNode 
+ *					  TO_CHAR	- write (inout) formated string
+ *					  FROM_CHAR - scan (inout) string by course of FormatNode
  * ----------
  */
-static int 
+static int
 dch_date(int arg, char *inout, int suf, int flag, FormatNode *node)
 {
-	char	buff[ DCH_CACHE_SIZE ], 		
-		*p_inout;
-	int	i, len;
+	char		buff[DCH_CACHE_SIZE],
+			   *p_inout;
+	int			i,
+				len;
 
 	p_inout = inout;
 
 	/* ----------
-	 * In the FROM-char is not difference between "January" or "JANUARY" 
-	 * or "january", all is before search convert to "first-upper".    
+	 * In the FROM-char is not difference between "January" or "JANUARY"
+	 * or "january", all is before search convert to "first-upper".
 	 * This convention is used for MONTH, MON, DAY, DY
 	 * ----------
 	 */
-	if (flag == FROM_CHAR) {
-		if (arg == DCH_MONTH || arg == DCH_Month || arg == DCH_month) {
-	
+	if (flag == FROM_CHAR)
+	{
+		if (arg == DCH_MONTH || arg == DCH_Month || arg == DCH_month)
+		{
+
 			tm->tm_mon = seq_search(inout, months_full, ONE_UPPER, FULL_SIZ, &len);
 			CHECK_SEQ_SEARCH(len, "MONTH/Month/month");
 			++tm->tm_mon;
-			if (S_FM(suf))	return len-1;
-			else 		return 8;
+			if (S_FM(suf))
+				return len - 1;
+			else
+				return 8;
+
+		}
+		else if (arg == DCH_MON || arg == DCH_Mon || arg == DCH_mon)
+		{
 
-		} else if (arg == DCH_MON || arg == DCH_Mon || arg == DCH_mon) {
-		
 			tm->tm_mon = seq_search(inout, months, ONE_UPPER, MAX_MON_LEN, &len);
 			CHECK_SEQ_SEARCH(len, "MON/Mon/mon");
 			++tm->tm_mon;
 			return 2;
-		
-		} else if (arg == DCH_DAY || arg == DCH_Day || arg == DCH_day) {
-		
-			tm->tm_wday =  seq_search(inout, days, ONE_UPPER, FULL_SIZ, &len);
+
+		}
+		else if (arg == DCH_DAY || arg == DCH_Day || arg == DCH_day)
+		{
+
+			tm->tm_wday = seq_search(inout, days, ONE_UPPER, FULL_SIZ, &len);
 			CHECK_SEQ_SEARCH(len, "DAY/Day/day");
-			if (S_FM(suf))	return len-1;
-			else 		return 8;
-			
-		} else if (arg == DCH_DY || arg == DCH_Dy || arg == DCH_dy) {
-			
-			tm->tm_wday =  seq_search(inout, days, ONE_UPPER, MAX_DY_LEN, &len);
+			if (S_FM(suf))
+				return len - 1;
+			else
+				return 8;
+
+		}
+		else if (arg == DCH_DY || arg == DCH_Dy || arg == DCH_dy)
+		{
+
+			tm->tm_wday = seq_search(inout, days, ONE_UPPER, MAX_DY_LEN, &len);
 			CHECK_SEQ_SEARCH(len, "DY/Dy/dy");
 			return 2;
-			
-		} 
-	} 
-	
-	switch(arg) {
-
-	case DCH_A_D:
-	case DCH_B_C:
-		if (flag == TO_CHAR) {
-			strcpy(inout, (tm->tm_year < 0 ? B_C_STR : A_D_STR ));
-			return 3;
-			
-		} else if (flag == FROM_CHAR) {
-			if (strncmp(inout, B_C_STR, 4)==0 && tm->tm_year > 0)
-				tm->tm_year = -(tm->tm_year);
-			if (tm->tm_year < 0) 
-				tm->tm_year = tm->tm_year+1; 
-			return 3;
-		}
-
-	case DCH_AD:
-	case DCH_BC:
-		if (flag == TO_CHAR) {
-			strcpy(inout, (tm->tm_year < 0 ? BC_STR : AD_STR ));
-			return 1;
-		
-		} else if (flag == FROM_CHAR) {
-			if (strncmp(inout, BC_STR, 2)==0 && tm->tm_year > 0)
-				tm->tm_year = -(tm->tm_year);
-			if (tm->tm_year < 0) 
-				tm->tm_year = tm->tm_year+1; 
-			return 1;
-		}
-
-	case DCH_a_d:
-	case DCH_b_c:
-		if (flag == TO_CHAR) {
-			strcpy(inout, (tm->tm_year < 0 ? b_c_STR : a_d_STR ));
-			return 3;
-			
-		} else if (flag == FROM_CHAR) {
-			if (strncmp(inout, b_c_STR, 4)==0 && tm->tm_year > 0)
-				tm->tm_year = -(tm->tm_year);
-			if (tm->tm_year < 0) 
-				tm->tm_year = tm->tm_year+1; 
-			return 3;
-		}
-
-	case DCH_ad:
-	case DCH_bc:
-		if (flag == TO_CHAR) {
-			strcpy(inout, (tm->tm_year < 0 ? bc_STR : ad_STR ));
-			return 1;
-		
-		} else if (flag == FROM_CHAR) {
-			if (strncmp(inout, bc_STR, 2)==0 && tm->tm_year > 0)
-				tm->tm_year = -(tm->tm_year);
-			if (tm->tm_year < 0) 
-				tm->tm_year = tm->tm_year+1; 
-			return 1;
-		}
-
-	case DCH_MONTH:
-		strcpy(inout, months_full[ tm->tm_mon - 1]);		
-		sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, str_toupper(inout));	
-		if (S_FM(suf)) 
-			return strlen(p_inout)-1;
-		else 
-			return 8;
-		
-	case DCH_Month:
-		sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, months_full[ tm->tm_mon -1 ]);		
-	        if (S_FM(suf)) 
-	        	return strlen(p_inout)-1;
-		else 
-			return 8;
-			
-	case DCH_month:
-		sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, months_full[ tm->tm_mon -1 ]);
-		*inout = tolower(*inout);
-	        if (S_FM(suf)) 
-	        	return strlen(p_inout)-1;
-		else 
-			return 8;
-			
-	case DCH_MON:
-		strcpy(inout, months[ tm->tm_mon -1 ]);		
-		inout = str_toupper(inout);
-		return 2;
-		
-	case DCH_Mon:
-		strcpy(inout, months[ tm->tm_mon -1 ]);		
-		return 2;     
-		
-	case DCH_mon:
-		strcpy(inout, months[ tm->tm_mon -1 ]);		
-		*inout = tolower(*inout);
-		return 2;
-		
-	case DCH_MM:
-		if (flag == TO_CHAR) {
-			sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, tm->tm_mon );
-			if (S_THth(suf)) 
-				str_numth(p_inout, inout, S_TH_TYPE(suf));
-			if (S_FM(suf) || S_THth(suf)) 
-				return strlen(p_inout)-1;
-			else 
-				return 1;
-				
-		} else if (flag == FROM_CHAR) {
-			if (S_FM(suf)) {
-				sscanf(inout, "%d", &tm->tm_mon);
-				return int4len((int4) tm->tm_mon)-1 + SKIP_THth(suf);
-			} else {
-				sscanf(inout, "%02d", &tm->tm_mon);
-				return 1 + SKIP_THth(suf);
-			}	
-		}	
-		
-	case DCH_DAY:
-		strcpy(inout, days[ tm->tm_wday ]); 			        
-		sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, str_toupper(inout)); 
-	        if (S_FM(suf)) 
-	        	return strlen(p_inout)-1;
-		else 
-			return 8;	
-			
-	case DCH_Day:
-		sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, days[ tm->tm_wday]);			
-	       	if (S_FM(suf)) 
-	       		return strlen(p_inout)-1;
-		else 
-			return 8;			
-			
-	case DCH_day:
-		sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, days[ tm->tm_wday]);			
-		*inout = tolower(*inout);
-	       	if (S_FM(suf)) 
-	       		return strlen(p_inout)-1;
-		else 
-			return 8;
-			
-	case DCH_DY:	        
-		strcpy(inout, days[ tm->tm_wday]);
-		inout = str_toupper(inout);		
-		return 2;
-		
-	case DCH_Dy:
-		strcpy(inout, days[ tm->tm_wday]);			
-		return 2;			
-		
-	case DCH_dy:
-		strcpy(inout, days[ tm->tm_wday]);			
-		*inout = tolower(*inout);
-		return 2;
-		
-	case DCH_DDD:
-		if (flag == TO_CHAR) {
-			sprintf(inout, "%0*d", S_FM(suf) ? 0 : 3, tm->tm_yday);
-	        	if (S_THth(suf)) 
-				str_numth(p_inout, inout, S_TH_TYPE(suf));
-			if (S_FM(suf) || S_THth(suf)) 
-				return strlen(p_inout)-1;
-			else return 2;
-			
-		} else if (flag == FROM_CHAR) {	
-			if (S_FM(suf)) {
-				sscanf(inout, "%d", &tm->tm_yday);
-				return int4len((int4) tm->tm_yday)-1 + SKIP_THth(suf);
-			} else {
-				sscanf(inout, "%03d", &tm->tm_yday);
-				return 2 + SKIP_THth(suf);
-			}	
-		}
-		
-	case DCH_DD:
-		if (flag == TO_CHAR) {	
-			sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, tm->tm_mday);	
-	        	if (S_THth(suf)) 
-				str_numth(p_inout, inout, S_TH_TYPE(suf));
-			if (S_FM(suf) || S_THth(suf)) 
-				return strlen(p_inout)-1;
-			else 
+
+		}
+	}
+
+	switch (arg)
+	{
+
+		case DCH_A_D:
+		case DCH_B_C:
+			if (flag == TO_CHAR)
+			{
+				strcpy(inout, (tm->tm_year < 0 ? B_C_STR : A_D_STR));
+				return 3;
+
+			}
+			else if (flag == FROM_CHAR)
+			{
+				if (strncmp(inout, B_C_STR, 4) == 0 && tm->tm_year > 0)
+					tm->tm_year = -(tm->tm_year);
+				if (tm->tm_year < 0)
+					tm->tm_year = tm->tm_year + 1;
+				return 3;
+			}
+
+		case DCH_AD:
+		case DCH_BC:
+			if (flag == TO_CHAR)
+			{
+				strcpy(inout, (tm->tm_year < 0 ? BC_STR : AD_STR));
 				return 1;
-				
-		} else if (flag == FROM_CHAR) {	
-			if (S_FM(suf)) {
-				sscanf(inout, "%d", &tm->tm_mday);
-				return int4len((int4) tm->tm_mday)-1 + SKIP_THth(suf);
-			} else {
-				sscanf(inout, "%02d", &tm->tm_mday);
-				return 1 + SKIP_THth(suf);
-			}	
-		}	
-	case DCH_D:
-		if (flag == TO_CHAR) {
-			sprintf(inout, "%d", tm->tm_wday+1);
-	        	if (S_THth(suf)) {
-				str_numth(p_inout, inout, S_TH_TYPE(suf));
-				return 2;
-	        	}
-	        	return 0;
-	        } else if (flag == FROM_CHAR) {	
-			sscanf(inout, "%1d", &tm->tm_wday);
-			if(tm->tm_wday) --tm->tm_wday;
-			return 0 + SKIP_THth(suf);
-		} 
-		
-	case DCH_WW:
-		if (flag == TO_CHAR) {
-			sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2,  
-				(tm->tm_yday - tm->tm_wday + 7) / 7);		
-	        	if (S_THth(suf)) 
-				str_numth(p_inout, inout, S_TH_TYPE(suf));
-			if (S_FM(suf) || S_THth(suf)) 
-				return strlen(p_inout)-1;
-			else 
+
+			}
+			else if (flag == FROM_CHAR)
+			{
+				if (strncmp(inout, BC_STR, 2) == 0 && tm->tm_year > 0)
+					tm->tm_year = -(tm->tm_year);
+				if (tm->tm_year < 0)
+					tm->tm_year = tm->tm_year + 1;
 				return 1;
-			
-		}  else if (flag == FROM_CHAR)
-			elog(ERROR, "to_datatime(): WW is not supported");
-	case DCH_Q:
-		if (flag == TO_CHAR) {
-			sprintf(inout, "%d", (tm->tm_mon-1)/3+1);		
-			if (S_THth(suf)) {
-				str_numth(p_inout, inout, S_TH_TYPE(suf));
-				return 2;
-	        	} 
-	        	return 0;
-	        	
-	        } else if (flag == FROM_CHAR)
-			elog(ERROR, "to_datatime(): Q is not supported");
-			
-	case DCH_CC:
-		if (flag == TO_CHAR) {
-			i = tm->tm_year/100 +1;
-			if (i <= 99 && i >= -99)	
-				sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, i);
-			else
-				sprintf(inout, "%d", i);			
-			if (S_THth(suf)) 
-				str_numth(p_inout, inout, S_TH_TYPE(suf));
-			return strlen(p_inout)-1;
-			
-		} else if (flag == FROM_CHAR)
-			elog(ERROR, "to_datatime(): CC is not supported");
-	case DCH_Y_YYY:	
-		if (flag == TO_CHAR) {
-			i= YEAR_ABS(tm->tm_year) / 1000;
-			sprintf(inout, "%d,%03d", i, YEAR_ABS(tm->tm_year) -(i*1000));
-			if (S_THth(suf)) 
-				str_numth(p_inout, inout, S_TH_TYPE(suf));
-		/*	
-			if (tm->tm_year < 0)
-				strcat(inout, BC_STR_ORIG);	
-		*/
-			return strlen(p_inout)-1;
-			
-		} else if (flag == FROM_CHAR) {
-			int	cc, yy;
-			sscanf(inout, "%d,%03d", &cc, &yy);
-			tm->tm_year = (cc * 1000) + yy;
-			
-			if (!S_FM(suf) && tm->tm_year <= 9999 && tm->tm_year >= -9999)	
-				len = 5; 
-			else 					
-				len = int4len((int4) tm->tm_year)+1;
-			len +=  SKIP_THth(suf);	
-		/* AC/BC  	
-			if (is_acdc(inout+len, &len) < 0 && tm->tm_year > 0) 
-				tm->tm_year = -(tm->tm_year);
-			if (tm->tm_year < 0) 
-				tm->tm_year = tm->tm_year+1; 
-		*/		
-			return len-1;
-		}	
-		
-	case DCH_YYYY	:
-		if (flag == TO_CHAR) {
-			if (tm->tm_year <= 9999 && tm->tm_year >= -9998)
-				sprintf(inout, "%0*d", S_FM(suf) ? 0 : 4,  YEAR_ABS(tm->tm_year));
-			else
-				sprintf(inout, "%d", YEAR_ABS(tm->tm_year));	
-			if (S_THth(suf)) 
-				str_numth(p_inout, inout, S_TH_TYPE(suf));
-		/*	
-			if (tm->tm_year < 0)
-				strcat(inout, BC_STR_ORIG);
-		*/		
-			return strlen(p_inout)-1;
-			
-		} else if (flag == FROM_CHAR) {
-			sscanf(inout, "%d", &tm->tm_year);
-			if (!S_FM(suf) && tm->tm_year <= 9999 && tm->tm_year >= -9999)	
-				len = 4;
-			else 					
-				len = int4len((int4) tm->tm_year);
-			len +=  SKIP_THth(suf);
-		/* AC/BC  	
-			if (is_acdc(inout+len, &len) < 0 && tm->tm_year > 0) 
-				tm->tm_year = -(tm->tm_year);
-			if (tm->tm_year < 0) 
-				tm->tm_year = tm->tm_year+1; 
-		*/		
-			return len-1;
-		}	
-		
-	case DCH_YYY:
-		if (flag == TO_CHAR) {
-			sprintf(buff, "%03d", YEAR_ABS(tm->tm_year));
-			i=strlen(buff);
-			strcpy(inout, buff+(i-3));
-			if (S_THth(suf)) {
-				str_numth(p_inout, inout, S_TH_TYPE(suf));
-				return 4;
 			}
-			return 2;
-			
-		} else if (flag == FROM_CHAR) {
-			int	yy;
-			sscanf(inout, "%03d", &yy);
-			tm->tm_year = (tm->tm_year/1000)*1000 +yy;
-			return 2 +  SKIP_THth(suf);
-		}
-			
-	case DCH_YY:
-		if (flag == TO_CHAR) {
-			sprintf(buff, "%02d", YEAR_ABS(tm->tm_year));
-			i=strlen(buff);
-			strcpy(inout, buff+(i-2));
-			if (S_THth(suf)) {
-				str_numth(p_inout, inout, S_TH_TYPE(suf));
-				return 3;
-			}	
-			return 1;
-			
-		} else if (flag == FROM_CHAR) {
-			int	yy;
-			sscanf(inout, "%02d", &yy);
-			tm->tm_year = (tm->tm_year/100)*100 +yy;
-			return 1 +  SKIP_THth(suf);
-		}	
-		
-	case DCH_Y:
-		if (flag == TO_CHAR) {
-			sprintf(buff, "%1d", YEAR_ABS(tm->tm_year));
-			i=strlen(buff);
-			strcpy(inout, buff+(i-1));
-			if (S_THth(suf)) {
-				str_numth(p_inout, inout, S_TH_TYPE(suf));
-				return 2;
-			}	
-			return 0;
-			
-		} else if (flag == FROM_CHAR) {
-			int	yy;
-			sscanf(inout, "%1d", &yy);
-			tm->tm_year = (tm->tm_year/10)*10 +yy;
-			return 0 +  SKIP_THth(suf);
-		}	
-		
-	case DCH_RM:
-		if (flag == TO_CHAR) {
-			sprintf(inout, "%*s", S_FM(suf) ? 0 : -4,   
-				rm_months_upper[ 12 - tm->tm_mon ]);
-			if (S_FM(suf)) 
-				return strlen(p_inout)-1;
-			else 
-				return 3;
-				
-		} else if (flag == FROM_CHAR) {
-			tm->tm_mon = 11-seq_search(inout, rm_months_upper, ALL_UPPER, FULL_SIZ, &len);
-			CHECK_SEQ_SEARCH(len, "RM");
-			++tm->tm_mon;
-			if (S_FM(suf))	
-				return len-1;
-			else 		
-				return 3;
-		}	
-	
-	case DCH_rm:
-		if (flag == TO_CHAR) {
-			sprintf(inout, "%*s", S_FM(suf) ? 0 : -4,   
-				rm_months_lower[ 12 - tm->tm_mon ]);
-			if (S_FM(suf)) 
-				return strlen(p_inout)-1;
-			else 
+
+		case DCH_a_d:
+		case DCH_b_c:
+			if (flag == TO_CHAR)
+			{
+				strcpy(inout, (tm->tm_year < 0 ? b_c_STR : a_d_STR));
 				return 3;
-				
-		} else if (flag == FROM_CHAR) {
-			tm->tm_mon = 11-seq_search(inout, rm_months_lower, ALL_UPPER, FULL_SIZ, &len);
-			CHECK_SEQ_SEARCH(len, "rm");
-			++tm->tm_mon;
-			if (S_FM(suf))	
-				return len-1;
-			else 		
+
+			}
+			else if (flag == FROM_CHAR)
+			{
+				if (strncmp(inout, b_c_STR, 4) == 0 && tm->tm_year > 0)
+					tm->tm_year = -(tm->tm_year);
+				if (tm->tm_year < 0)
+					tm->tm_year = tm->tm_year + 1;
 				return 3;
-		}
-		
-	case DCH_W:
-		if (flag == TO_CHAR) {
-			sprintf(inout, "%d", (tm->tm_mday - tm->tm_wday +7) / 7 );
-			if (S_THth(suf)) {
-				str_numth(p_inout, inout, S_TH_TYPE(suf));
-				return 2;
 			}
-			return 0;
-			
-		} else if (flag == FROM_CHAR)
-			elog(ERROR, "to_datatime(): W is not supported");
-			
-	case DCH_J:
-		if (flag == TO_CHAR) {
-			sprintf(inout, "%d", date2j(tm->tm_year, tm->tm_mon, tm->tm_mday));		
-			if (S_THth(suf)) 
-				str_numth(p_inout, inout, S_TH_TYPE(suf));
-			return strlen(p_inout)-1;
-		} else if (flag == FROM_CHAR)
-			elog(ERROR, "to_datatime(): J is not supported");	
-	}	
-	return -1;	
-}
+
+		case DCH_ad:
+		case DCH_bc:
+			if (flag == TO_CHAR)
+			{
+				strcpy(inout, (tm->tm_year < 0 ? bc_STR : ad_STR));
+				return 1;
+
+			}
+			else if (flag == FROM_CHAR)
+			{
+				if (strncmp(inout, bc_STR, 2) == 0 && tm->tm_year > 0)
+					tm->tm_year = -(tm->tm_year);
+				if (tm->tm_year < 0)
+					tm->tm_year = tm->tm_year + 1;
+				return 1;
+			}
+
+		case DCH_MONTH:
+			strcpy(inout, months_full[tm->tm_mon - 1]);
+			sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, str_toupper(inout));
+			if (S_FM(suf))
+				return strlen(p_inout) - 1;
+			else
+				return 8;
+
+		case DCH_Month:
+			sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, months_full[tm->tm_mon - 1]);
+			if (S_FM(suf))
+				return strlen(p_inout) - 1;
+			else
+				return 8;
+
+		case DCH_month:
+			sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, months_full[tm->tm_mon - 1]);
+			*inout = tolower(*inout);
+			if (S_FM(suf))
+				return strlen(p_inout) - 1;
+			else
+				return 8;
+
+		case DCH_MON:
+			strcpy(inout, months[tm->tm_mon - 1]);
+			inout = str_toupper(inout);
+			return 2;
+
+		case DCH_Mon:
+			strcpy(inout, months[tm->tm_mon - 1]);
+			return 2;
+
+		case DCH_mon:
+			strcpy(inout, months[tm->tm_mon - 1]);
+			*inout = tolower(*inout);
+			return 2;
+
+		case DCH_MM:
+			if (flag == TO_CHAR)
+			{
+				sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, tm->tm_mon);
+				if (S_THth(suf))
+					str_numth(p_inout, inout, S_TH_TYPE(suf));
+				if (S_FM(suf) || S_THth(suf))
+					return strlen(p_inout) - 1;
+				else
+					return 1;
+
+			}
+			else if (flag == FROM_CHAR)
+			{
+				if (S_FM(suf))
+				{
+					sscanf(inout, "%d", &tm->tm_mon);
+					return int4len((int4) tm->tm_mon) - 1 + SKIP_THth(suf);
+				}
+				else
+				{
+					sscanf(inout, "%02d", &tm->tm_mon);
+					return 1 + SKIP_THth(suf);
+				}
+			}
+
+		case DCH_DAY:
+			strcpy(inout, days[tm->tm_wday]);
+			sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, str_toupper(inout));
+			if (S_FM(suf))
+				return strlen(p_inout) - 1;
+			else
+				return 8;
+
+		case DCH_Day:
+			sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, days[tm->tm_wday]);
+			if (S_FM(suf))
+				return strlen(p_inout) - 1;
+			else
+				return 8;
+
+		case DCH_day:
+			sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, days[tm->tm_wday]);
+			*inout = tolower(*inout);
+			if (S_FM(suf))
+				return strlen(p_inout) - 1;
+			else
+				return 8;
+
+		case DCH_DY:
+			strcpy(inout, days[tm->tm_wday]);
+			inout = str_toupper(inout);
+			return 2;
+
+		case DCH_Dy:
+			strcpy(inout, days[tm->tm_wday]);
+			return 2;
+
+		case DCH_dy:
+			strcpy(inout, days[tm->tm_wday]);
+			*inout = tolower(*inout);
+			return 2;
+
+		case DCH_DDD:
+			if (flag == TO_CHAR)
+			{
+				sprintf(inout, "%0*d", S_FM(suf) ? 0 : 3, tm->tm_yday);
+				if (S_THth(suf))
+					str_numth(p_inout, inout, S_TH_TYPE(suf));
+				if (S_FM(suf) || S_THth(suf))
+					return strlen(p_inout) - 1;
+				else
+					return 2;
+
+			}
+			else if (flag == FROM_CHAR)
+			{
+				if (S_FM(suf))
+				{
+					sscanf(inout, "%d", &tm->tm_yday);
+					return int4len((int4) tm->tm_yday) - 1 + SKIP_THth(suf);
+				}
+				else
+				{
+					sscanf(inout, "%03d", &tm->tm_yday);
+					return 2 + SKIP_THth(suf);
+				}
+			}
+
+		case DCH_DD:
+			if (flag == TO_CHAR)
+			{
+				sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, tm->tm_mday);
+				if (S_THth(suf))
+					str_numth(p_inout, inout, S_TH_TYPE(suf));
+				if (S_FM(suf) || S_THth(suf))
+					return strlen(p_inout) - 1;
+				else
+					return 1;
+
+			}
+			else if (flag == FROM_CHAR)
+			{
+				if (S_FM(suf))
+				{
+					sscanf(inout, "%d", &tm->tm_mday);
+					return int4len((int4) tm->tm_mday) - 1 + SKIP_THth(suf);
+				}
+				else
+				{
+					sscanf(inout, "%02d", &tm->tm_mday);
+					return 1 + SKIP_THth(suf);
+				}
+			}
+		case DCH_D:
+			if (flag == TO_CHAR)
+			{
+				sprintf(inout, "%d", tm->tm_wday + 1);
+				if (S_THth(suf))
+				{
+					str_numth(p_inout, inout, S_TH_TYPE(suf));
+					return 2;
+				}
+				return 0;
+			}
+			else if (flag == FROM_CHAR)
+			{
+				sscanf(inout, "%1d", &tm->tm_wday);
+				if (tm->tm_wday)
+					--tm->tm_wday;
+				return 0 + SKIP_THth(suf);
+			}
+
+		case DCH_WW:
+			if (flag == TO_CHAR)
+			{
+				sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2,
+						(tm->tm_yday - tm->tm_wday + 7) / 7);
+				if (S_THth(suf))
+					str_numth(p_inout, inout, S_TH_TYPE(suf));
+				if (S_FM(suf) || S_THth(suf))
+					return strlen(p_inout) - 1;
+				else
+					return 1;
+
+			}
+			else if (flag == FROM_CHAR)
+				elog(ERROR, "to_datatime(): WW is not supported");
+		case DCH_Q:
+			if (flag == TO_CHAR)
+			{
+				sprintf(inout, "%d", (tm->tm_mon - 1) / 3 + 1);
+				if (S_THth(suf))
+				{
+					str_numth(p_inout, inout, S_TH_TYPE(suf));
+					return 2;
+				}
+				return 0;
+
+			}
+			else if (flag == FROM_CHAR)
+				elog(ERROR, "to_datatime(): Q is not supported");
+
+		case DCH_CC:
+			if (flag == TO_CHAR)
+			{
+				i = tm->tm_year / 100 + 1;
+				if (i <= 99 && i >= -99)
+					sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, i);
+				else
+					sprintf(inout, "%d", i);
+				if (S_THth(suf))
+					str_numth(p_inout, inout, S_TH_TYPE(suf));
+				return strlen(p_inout) - 1;
+
+			}
+			else if (flag == FROM_CHAR)
+				elog(ERROR, "to_datatime(): CC is not supported");
+		case DCH_Y_YYY:
+			if (flag == TO_CHAR)
+			{
+				i = YEAR_ABS(tm->tm_year) / 1000;
+				sprintf(inout, "%d,%03d", i, YEAR_ABS(tm->tm_year) - (i * 1000));
+				if (S_THth(suf))
+					str_numth(p_inout, inout, S_TH_TYPE(suf));
+
+				/*
+				 * if (tm->tm_year < 0) strcat(inout, BC_STR_ORIG);
+				 */
+				return strlen(p_inout) - 1;
+
+			}
+			else if (flag == FROM_CHAR)
+			{
+				int			cc,
+							yy;
+
+				sscanf(inout, "%d,%03d", &cc, &yy);
+				tm->tm_year = (cc * 1000) + yy;
+
+				if (!S_FM(suf) && tm->tm_year <= 9999 && tm->tm_year >= -9999)
+					len = 5;
+				else
+					len = int4len((int4) tm->tm_year) + 1;
+				len += SKIP_THth(suf);
+
+				/*
+				 * AC/BC if (is_acdc(inout+len, &len) < 0 && tm->tm_year >
+				 * 0) tm->tm_year = -(tm->tm_year); if (tm->tm_year < 0)
+				 * tm->tm_year = tm->tm_year+1;
+				 */
+				return len - 1;
+			}
+
+		case DCH_YYYY:
+			if (flag == TO_CHAR)
+			{
+				if (tm->tm_year <= 9999 && tm->tm_year >= -9998)
+					sprintf(inout, "%0*d", S_FM(suf) ? 0 : 4, YEAR_ABS(tm->tm_year));
+				else
+					sprintf(inout, "%d", YEAR_ABS(tm->tm_year));
+				if (S_THth(suf))
+					str_numth(p_inout, inout, S_TH_TYPE(suf));
+
+				/*
+				 * if (tm->tm_year < 0) strcat(inout, BC_STR_ORIG);
+				 */
+				return strlen(p_inout) - 1;
+
+			}
+			else if (flag == FROM_CHAR)
+			{
+				sscanf(inout, "%d", &tm->tm_year);
+				if (!S_FM(suf) && tm->tm_year <= 9999 && tm->tm_year >= -9999)
+					len = 4;
+				else
+					len = int4len((int4) tm->tm_year);
+				len += SKIP_THth(suf);
+
+				/*
+				 * AC/BC if (is_acdc(inout+len, &len) < 0 && tm->tm_year >
+				 * 0) tm->tm_year = -(tm->tm_year); if (tm->tm_year < 0)
+				 * tm->tm_year = tm->tm_year+1;
+				 */
+				return len - 1;
+			}
+
+		case DCH_YYY:
+			if (flag == TO_CHAR)
+			{
+				sprintf(buff, "%03d", YEAR_ABS(tm->tm_year));
+				i = strlen(buff);
+				strcpy(inout, buff + (i - 3));
+				if (S_THth(suf))
+				{
+					str_numth(p_inout, inout, S_TH_TYPE(suf));
+					return 4;
+				}
+				return 2;
+
+			}
+			else if (flag == FROM_CHAR)
+			{
+				int			yy;
+
+				sscanf(inout, "%03d", &yy);
+				tm->tm_year = (tm->tm_year / 1000) * 1000 + yy;
+				return 2 + SKIP_THth(suf);
+			}
+
+		case DCH_YY:
+			if (flag == TO_CHAR)
+			{
+				sprintf(buff, "%02d", YEAR_ABS(tm->tm_year));
+				i = strlen(buff);
+				strcpy(inout, buff + (i - 2));
+				if (S_THth(suf))
+				{
+					str_numth(p_inout, inout, S_TH_TYPE(suf));
+					return 3;
+				}
+				return 1;
+
+			}
+			else if (flag == FROM_CHAR)
+			{
+				int			yy;
+
+				sscanf(inout, "%02d", &yy);
+				tm->tm_year = (tm->tm_year / 100) * 100 + yy;
+				return 1 + SKIP_THth(suf);
+			}
+
+		case DCH_Y:
+			if (flag == TO_CHAR)
+			{
+				sprintf(buff, "%1d", YEAR_ABS(tm->tm_year));
+				i = strlen(buff);
+				strcpy(inout, buff + (i - 1));
+				if (S_THth(suf))
+				{
+					str_numth(p_inout, inout, S_TH_TYPE(suf));
+					return 2;
+				}
+				return 0;
+
+			}
+			else if (flag == FROM_CHAR)
+			{
+				int			yy;
+
+				sscanf(inout, "%1d", &yy);
+				tm->tm_year = (tm->tm_year / 10) * 10 + yy;
+				return 0 + SKIP_THth(suf);
+			}
+
+		case DCH_RM:
+			if (flag == TO_CHAR)
+			{
+				sprintf(inout, "%*s", S_FM(suf) ? 0 : -4,
+						rm_months_upper[12 - tm->tm_mon]);
+				if (S_FM(suf))
+					return strlen(p_inout) - 1;
+				else
+					return 3;
+
+			}
+			else if (flag == FROM_CHAR)
+			{
+				tm->tm_mon = 11 - seq_search(inout, rm_months_upper, ALL_UPPER, FULL_SIZ, &len);
+				CHECK_SEQ_SEARCH(len, "RM");
+				++tm->tm_mon;
+				if (S_FM(suf))
+					return len - 1;
+				else
+					return 3;
+			}
+
+		case DCH_rm:
+			if (flag == TO_CHAR)
+			{
+				sprintf(inout, "%*s", S_FM(suf) ? 0 : -4,
+						rm_months_lower[12 - tm->tm_mon]);
+				if (S_FM(suf))
+					return strlen(p_inout) - 1;
+				else
+					return 3;
+
+			}
+			else if (flag == FROM_CHAR)
+			{
+				tm->tm_mon = 11 - seq_search(inout, rm_months_lower, ALL_UPPER, FULL_SIZ, &len);
+				CHECK_SEQ_SEARCH(len, "rm");
+				++tm->tm_mon;
+				if (S_FM(suf))
+					return len - 1;
+				else
+					return 3;
+			}
+
+		case DCH_W:
+			if (flag == TO_CHAR)
+			{
+				sprintf(inout, "%d", (tm->tm_mday - tm->tm_wday + 7) / 7);
+				if (S_THth(suf))
+				{
+					str_numth(p_inout, inout, S_TH_TYPE(suf));
+					return 2;
+				}
+				return 0;
+
+			}
+			else if (flag == FROM_CHAR)
+				elog(ERROR, "to_datatime(): W is not supported");
+
+		case DCH_J:
+			if (flag == TO_CHAR)
+			{
+				sprintf(inout, "%d", date2j(tm->tm_year, tm->tm_mon, tm->tm_mday));
+				if (S_THth(suf))
+					str_numth(p_inout, inout, S_TH_TYPE(suf));
+				return strlen(p_inout) - 1;
+			}
+			else if (flag == FROM_CHAR)
+				elog(ERROR, "to_datatime(): J is not supported");
+	}
+	return -1;
+}
 
 static DCHCacheEntry *
-DCH_cache_getnew( char *str )
+DCH_cache_getnew(char *str)
 {
-	DCHCacheEntry 	*ent	= NULL;
-	
+	DCHCacheEntry *ent = NULL;
+
 	/* counter overload check  - paranoa? */
-	if (DCHCounter + DCH_CACHE_FIELDS >= MAX_INT32) {
+	if (DCHCounter + DCH_CACHE_FIELDS >= MAX_INT32)
+	{
 		DCHCounter = 0;
 
-		for(ent = DCHCache; ent <= (DCHCache + DCH_CACHE_FIELDS); ent++)
-		        ent->age = (++DCHCounter);
+		for (ent = DCHCache; ent <= (DCHCache + DCH_CACHE_FIELDS); ent++)
+			ent->age = (++DCHCounter);
 	}
-	
+
 	/* ----------
 	 * Cache is full - needs remove any older entry
 	 * ----------
 	 */
-	if (n_DCHCache > DCH_CACHE_FIELDS) {
+	if (n_DCHCache > DCH_CACHE_FIELDS)
+	{
+
+		DCHCacheEntry *old = DCHCache + 0;
 
-		DCHCacheEntry   *old 	= DCHCache+0;
 #ifdef DEBUG_TO_FROM_CHAR
 		elog(DEBUG_elog_output, "Cache is full (%d)", n_DCHCache);
-#endif	
-		for(ent = DCHCache; ent <= (DCHCache + DCH_CACHE_FIELDS); ent++) {
+#endif
+		for (ent = DCHCache; ent <= (DCHCache + DCH_CACHE_FIELDS); ent++)
+		{
 			if (ent->age < old->age)
 				old = ent;
-		}	
+		}
 #ifdef DEBUG_TO_FROM_CHAR
 		elog(DEBUG_elog_output, "OLD: '%s' AGE: %d", old->str, old->age);
-#endif		
-		strcpy(old->str, str);		/* check str size before this func. */
+#endif
+		strcpy(old->str, str);	/* check str size before this func. */
 		/* old->format fill parser */
 		old->age = (++DCHCounter);
 		return old;
-		
-	} else {
-#ifdef DEBUG_TO_FROM_CHAR	
+
+	}
+	else
+	{
+#ifdef DEBUG_TO_FROM_CHAR
 		elog(DEBUG_elog_output, "NEW (%d)", n_DCHCache);
-#endif	
+#endif
 		ent = DCHCache + n_DCHCache;
-		strcpy(ent->str, str);		/* check str size before this func. */
+		strcpy(ent->str, str);	/* check str size before this func. */
 		/* ent->format fill parser */
 		ent->age = (++DCHCounter);
 		++n_DCHCache;
 		return ent;
 	}
-	
+
 	return (DCHCacheEntry *) NULL;		/* never */
 }
 
 static DCHCacheEntry *
-DCH_cache_search( char *str )
+DCH_cache_search(char *str)
 {
-	int		i = 0;
-	DCHCacheEntry 	*ent;
+	int			i = 0;
+	DCHCacheEntry *ent;
 
 	/* counter overload check  - paranoa? */
-	if (DCHCounter + DCH_CACHE_FIELDS >= MAX_INT32) {
+	if (DCHCounter + DCH_CACHE_FIELDS >= MAX_INT32)
+	{
 		DCHCounter = 0;
 
-		for(ent = DCHCache; ent <= (DCHCache + DCH_CACHE_FIELDS); ent++)
-		        ent->age = (++DCHCounter);
+		for (ent = DCHCache; ent <= (DCHCache + DCH_CACHE_FIELDS); ent++)
+			ent->age = (++DCHCounter);
 	}
 
-	for(ent = DCHCache; ent <= (DCHCache + DCH_CACHE_FIELDS); ent++) {
+	for (ent = DCHCache; ent <= (DCHCache + DCH_CACHE_FIELDS); ent++)
+	{
 		if (i == n_DCHCache)
 			break;
-		if (strcmp(ent->str, str) == 0) {
+		if (strcmp(ent->str, str) == 0)
+		{
 			ent->age = (++DCHCounter);
 			return ent;
-		}	
-		i++;	
+		}
+		i++;
 	}
-	
+
 	return (DCHCacheEntry *) NULL;
 }
 
@@ -2159,103 +2375,119 @@ DCH_cache_search( char *str )
 text *
 timestamp_to_char(Timestamp *dt, text *fmt)
 {
-	text 			*result, *result_tmp;
-	FormatNode		*format;
-	char			*str;
-	double          	fsec;
-	char       		*tzn;
-	int			len=0, tz, flag = 0, x=0;
+	text	   *result,
+			   *result_tmp;
+	FormatNode *format;
+	char	   *str;
+	double		fsec;
+	char	   *tzn;
+	int			len = 0,
+				tz,
+				flag = 0,
+				x = 0;
 
 	if ((!PointerIsValid(dt)) || (!PointerIsValid(fmt)))
 		return NULL;
-	
-	len 	= VARSIZE(fmt) - VARHDRSZ; 
-	
+
+	len = VARSIZE(fmt) - VARHDRSZ;
+
 	if ((!len) || (TIMESTAMP_NOT_FINITE(*dt)))
 		return textin("");
 
-	tm->tm_sec	=0;	tm->tm_year	=0;
-	tm->tm_min	=0;	tm->tm_wday	=0;
-	tm->tm_hour	=0;	tm->tm_yday	=0;
-	tm->tm_mday	=1;	tm->tm_isdst	=0;
-	tm->tm_mon	=1;
-
- 	if (TIMESTAMP_IS_EPOCH(*dt)) {
- 		x = timestamp2tm(SetTimestamp(*dt), NULL, tm, &fsec, NULL);
- 		
-  	} else if (TIMESTAMP_IS_CURRENT(*dt)) {
- 		x = timestamp2tm(SetTimestamp(*dt), &tz, tm, &fsec, &tzn);
- 			
-  	} else {
- 		x = timestamp2tm(*dt, &tz, tm, &fsec, &tzn);
-  	}
-  
- 	if (x!=0)
- 		elog(ERROR, "to_char(): Unable to convert timestamp to tm");
- 
-	tm->tm_wday = (date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) + 1) % 7; 
-	tm->tm_yday = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - date2j(tm->tm_year, 1,1) +1;
+	tm->tm_sec = 0;
+	tm->tm_year = 0;
+	tm->tm_min = 0;
+	tm->tm_wday = 0;
+	tm->tm_hour = 0;
+	tm->tm_yday = 0;
+	tm->tm_mday = 1;
+	tm->tm_isdst = 0;
+	tm->tm_mon = 1;
+
+	if (TIMESTAMP_IS_EPOCH(*dt))
+	{
+		x = timestamp2tm(SetTimestamp(*dt), NULL, tm, &fsec, NULL);
+
+	}
+	else if (TIMESTAMP_IS_CURRENT(*dt))
+	{
+		x = timestamp2tm(SetTimestamp(*dt), &tz, tm, &fsec, &tzn);
+
+	}
+	else
+		x = timestamp2tm(*dt, &tz, tm, &fsec, &tzn);
+
+	if (x != 0)
+		elog(ERROR, "to_char(): Unable to convert timestamp to tm");
+
+	tm->tm_wday = (date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) + 1) % 7;
+	tm->tm_yday = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - date2j(tm->tm_year, 1, 1) + 1;
 
 	/* ----------
 	 * Convert VARDATA() to string
 	 * ----------
 	 */
-	str = (char *) palloc(len + 1);    
+	str = (char *) palloc(len + 1);
 	memcpy(str, VARDATA(fmt), len);
-	*(str + len) = '\0'; 
+	*(str + len) = '\0';
 
 	/* ----------
 	 * Allocate result
 	 * ----------
 	 */
-	result	= (text *) palloc( (len * DCH_MAX_ITEM_SIZ) + 1 + VARHDRSZ);	
+	result = (text *) palloc((len * DCH_MAX_ITEM_SIZ) + 1 + VARHDRSZ);
 
 	/* ----------
-	 * Allocate new memory if format picture is bigger than static cache 
+	 * Allocate new memory if format picture is bigger than static cache
 	 * and not use cache (call parser always) - flag=1 show this variant
 	 * ----------
-         */
-	if ( len > DCH_CACHE_SIZE ) {
-		
+		 */
+	if (len > DCH_CACHE_SIZE)
+	{
+
 		format = (FormatNode *) palloc((len + 1) * sizeof(FormatNode));
-		flag  = 1;
+		flag = 1;
+
+		parse_format(format, str, DCH_keywords,
+					 DCH_suff, DCH_index, DCH_TYPE, NULL);
+
+		(format + len)->type = NODE_TYPE_END;	/* Paranoa? */
 
-		parse_format(format, str, DCH_keywords, 
-         		     DCH_suff, DCH_index, DCH_TYPE, NULL);
-	
-		(format + len)->type = NODE_TYPE_END;		/* Paranoa? */	
-				
-	} else {
+	}
+	else
+	{
 
 		/* ----------
 		 * Use cache buffers
 		 * ----------
 		 */
-		DCHCacheEntry	*ent;
+		DCHCacheEntry *ent;
+
 		flag = 0;
 
-       		if ((ent = DCH_cache_search(str)) == NULL) {
-	
+		if ((ent = DCH_cache_search(str)) == NULL)
+		{
+
 			ent = DCH_cache_getnew(str);
-	
+
 			/* ----------
 			 * Not in the cache, must run parser and save a new
-			 * format-picture to the cache. 
+			 * format-picture to the cache.
 			 * ----------
-        		 */		
-         		parse_format(ent->format, str, DCH_keywords, 
-         		     DCH_suff, DCH_index, DCH_TYPE, NULL);
-			
-			(ent->format + len)->type = NODE_TYPE_END;		/* Paranoa? */	
-			
-#ifdef DEBUG_TO_FROM_CHAR	 
+				 */
+			parse_format(ent->format, str, DCH_keywords,
+						 DCH_suff, DCH_index, DCH_TYPE, NULL);
+
+			(ent->format + len)->type = NODE_TYPE_END;	/* Paranoa? */
+
+#ifdef DEBUG_TO_FROM_CHAR
 			/* dump_node(ent->format, len); */
 			/* dump_index(DCH_keywords, DCH_index);  */
-#endif         	
-        	} 
-        	format = ent->format; 
+#endif
+		}
+		format = ent->format;
 	}
-	
+
 	DCH_processor(format, VARDATA(result), TO_CHAR);
 
 	if (flag)
@@ -2267,13 +2499,13 @@ timestamp_to_char(Timestamp *dt, text *fmt)
 	 * for result is allocated max memory, which current format-picture
 	 * needs, now it must be re-allocate to result real size
 	 * ----------
-	 */	
-	len 		= strlen(VARDATA(result));
-	result_tmp 	= result;
-	result 		= (text *) palloc( len + 1 + VARHDRSZ);
-	
-	strcpy( VARDATA(result), VARDATA(result_tmp));  
-	VARSIZE(result) = len + VARHDRSZ; 
+	 */
+	len = strlen(VARDATA(result));
+	result_tmp = result;
+	result = (text *) palloc(len + 1 + VARHDRSZ);
+
+	strcpy(VARDATA(result), VARDATA(result_tmp));
+	VARSIZE(result) = len + VARHDRSZ;
 	pfree(result_tmp);
 
 	return result;
@@ -2283,113 +2515,124 @@ timestamp_to_char(Timestamp *dt, text *fmt)
 /* ---------------------
  * TO_TIMESTAMP()
  *
- * Make Timestamp from date_str which is formated at argument 'fmt'  	 
+ * Make Timestamp from date_str which is formated at argument 'fmt'
  * ( to_timestamp is reverse to_char() )
  * ---------------------
  */
-Timestamp *
+Timestamp  *
 to_timestamp(text *date_str, text *fmt)
 {
-	FormatNode		*format;
-	int			flag=0;
-	Timestamp		*result;
-	char			*str;
-	int			len=0,
-				fsec=0,
-				tz=0;
+	FormatNode *format;
+	int			flag = 0;
+	Timestamp  *result;
+	char	   *str;
+	int			len = 0,
+				fsec = 0,
+				tz = 0;
 
 	if ((!PointerIsValid(date_str)) || (!PointerIsValid(fmt)))
 		return NULL;
-	
-	tm->tm_sec	=0;	tm->tm_year	=0;
-	tm->tm_min	=0;	tm->tm_wday	=0;
-	tm->tm_hour	=0;	tm->tm_yday	=0;
-	tm->tm_mday	=1;	tm->tm_isdst	=0;
-	tm->tm_mon	=1;
-	
+
+	tm->tm_sec = 0;
+	tm->tm_year = 0;
+	tm->tm_min = 0;
+	tm->tm_wday = 0;
+	tm->tm_hour = 0;
+	tm->tm_yday = 0;
+	tm->tm_mday = 1;
+	tm->tm_isdst = 0;
+	tm->tm_mon = 1;
+
 	result = palloc(sizeof(Timestamp));
-	
-	len 	= VARSIZE(fmt) - VARHDRSZ; 
-	
-	if (len) { 
-		
+
+	len = VARSIZE(fmt) - VARHDRSZ;
+
+	if (len)
+	{
+
 		/* ----------
 		 * Convert VARDATA() to string
 		 * ----------
 		 */
-		str = (char *) palloc(len + 1);    
+		str = (char *) palloc(len + 1);
 		memcpy(str, VARDATA(fmt), len);
-		*(str + len) = '\0'; 
+		*(str + len) = '\0';
 
 		/* ----------
-		 * Allocate new memory if format picture is bigger than static cache 
+		 * Allocate new memory if format picture is bigger than static cache
 		 * and not use cache (call parser always) - flag=1 show this variant
 		 * ----------
-        	 */
-		if ( len > DCH_CACHE_SIZE ) {
+			 */
+		if (len > DCH_CACHE_SIZE)
+		{
 
 			format = (FormatNode *) palloc((len + 1) * sizeof(FormatNode));
-			flag  = 1;
+			flag = 1;
+
+			parse_format(format, str, DCH_keywords,
+						 DCH_suff, DCH_index, DCH_TYPE, NULL);
 
-			parse_format(format, str, DCH_keywords, 
-         			     DCH_suff, DCH_index, DCH_TYPE, NULL);
-	
-			(format + len)->type = NODE_TYPE_END;		/* Paranoa? */	
-		} else {
+			(format + len)->type = NODE_TYPE_END;		/* Paranoa? */
+		}
+		else
+		{
 
 			/* ----------
 			 * Use cache buffers
 			 * ----------
 			 */
-			DCHCacheEntry	*ent;
+			DCHCacheEntry *ent;
+
 			flag = 0;
 
-	       		if ((ent = DCH_cache_search(str)) == NULL) {
-	
+			if ((ent = DCH_cache_search(str)) == NULL)
+			{
+
 				ent = DCH_cache_getnew(str);
-	
+
 				/* ----------
 				 * Not in the cache, must run parser and save a new
-				 * format-picture to the cache. 
+				 * format-picture to the cache.
 				 * ----------
-        			 */		
-         			parse_format(ent->format, str, DCH_keywords, 
-         			     DCH_suff, DCH_index, DCH_TYPE, NULL);
-			
-				(ent->format + len)->type = NODE_TYPE_END;		/* Paranoa? */				
-#ifdef DEBUG_TO_FROM_CHAR	 
+					 */
+				parse_format(ent->format, str, DCH_keywords,
+							 DCH_suff, DCH_index, DCH_TYPE, NULL);
+
+				(ent->format + len)->type = NODE_TYPE_END;		/* Paranoa? */
+#ifdef DEBUG_TO_FROM_CHAR
 				/* dump_node(ent->format, len); */
 				/* dump_index(DCH_keywords, DCH_index); */
-#endif         	
-        		} 
-        		format = ent->format; 
-		}				
-	
+#endif
+			}
+			format = ent->format;
+		}
+
 		/* ----------
-		 * Call action for each node in FormatNode tree 
+		 * Call action for each node in FormatNode tree
 		 * ----------
-		 */	 
-#ifdef DEBUG_TO_FROM_CHAR	 
+		 */
+#ifdef DEBUG_TO_FROM_CHAR
 		/* dump_node(format, len); */
 #endif
-		VARDATA(date_str)[ VARSIZE(date_str) - VARHDRSZ ] = '\0';
-		DCH_processor(format, VARDATA(date_str), FROM_CHAR);	
+		VARDATA(date_str)[VARSIZE(date_str) - VARHDRSZ] = '\0';
+		DCH_processor(format, VARDATA(date_str), FROM_CHAR);
 
 		pfree(str);
-		
+
 		if (flag)
 			pfree(format);
 	}
 
 #ifdef DEBUG_TO_FROM_CHAR
-	NOTICE_TM; 
+	NOTICE_TM;
 #endif
-	if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday)) {
+	if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday))
+	{
 
 #ifdef USE_POSIX_TIME
 		tm->tm_isdst = -1;
 		tm->tm_year -= 1900;
-			tm->tm_mon -= 1;
+		tm->tm_mon -= 1;
 
 #ifdef DEBUG_TO_FROM_CHAR
 		elog(DEBUG_elog_output, "TO-FROM_CHAR: Call mktime()");
@@ -2413,35 +2656,37 @@ to_timestamp(text *date_str, text *fmt)
 #error USE_POSIX_TIME is defined but neither HAVE_TM_ZONE or HAVE_INT_TIMEZONE are defined
 #endif
 
-#else		/* !USE_POSIX_TIME */
+#else							/* !USE_POSIX_TIME */
 		tz = CTimeZone;
 #endif
-	} else {
+	}
+	else
+	{
 		tm->tm_isdst = 0;
 		tz = 0;
 	}
 #ifdef DEBUG_TO_FROM_CHAR
-	NOTICE_TM; 
+	NOTICE_TM;
 #endif
 	if (tm2timestamp(tm, fsec, &tz, result) != 0)
-        	elog(ERROR, "to_datatime(): can't convert 'tm' to timestamp.");
-	
+		elog(ERROR, "to_datatime(): can't convert 'tm' to timestamp.");
+
 	return result;
 }
 
 /* ----------
  * TO_DATE
- * 	Make Date from date_str which is formated at argument 'fmt'  	 
+ *	Make Date from date_str which is formated at argument 'fmt'
  * ----------
  */
-DateADT  
+DateADT
 to_date(text *date_str, text *fmt)
 {
-	return timestamp_date( to_timestamp(date_str, fmt) );
+	return timestamp_date(to_timestamp(date_str, fmt));
 }
 
 /**********************************************************************
- *  the NUMBER version part
+ *	the NUMBER version part
  *********************************************************************/
 
 
@@ -2449,16 +2694,16 @@ static char *
 fill_str(char *str, int c, int max)
 {
 	memset(str, c, max);
-	*(str+max+1) = '\0';	
-	return str;	
+	*(str + max + 1) = '\0';
+	return str;
 }
 
 #define zeroize_NUM(_n) {		\
-	(_n)->flag 		= 0;	\
+	(_n)->flag		= 0;	\
 	(_n)->lsign		= 0;	\
 	(_n)->pre		= 0;	\
 	(_n)->post		= 0;	\
-	(_n)->pre_lsign_num	= 0;	\
+	(_n)->pre_lsign_num = 0;	\
 	(_n)->need_locale	= 0;	\
 	(_n)->multi		= 0;	\
 	(_n)->zero_start	= 0;	\
@@ -2466,83 +2711,91 @@ fill_str(char *str, int c, int max)
 }
 
 static NUMCacheEntry *
-NUM_cache_getnew( char *str )
+NUM_cache_getnew(char *str)
 {
-	NUMCacheEntry 	*ent	= NULL;
-	
+	NUMCacheEntry *ent = NULL;
+
 	/* counter overload check  - paranoa? */
-	if (NUMCounter + NUM_CACHE_FIELDS >= MAX_INT32) {
+	if (NUMCounter + NUM_CACHE_FIELDS >= MAX_INT32)
+	{
 		NUMCounter = 0;
 
-		for(ent = NUMCache; ent <= (NUMCache + NUM_CACHE_FIELDS); ent++)
-		        ent->age = (++NUMCounter);
+		for (ent = NUMCache; ent <= (NUMCache + NUM_CACHE_FIELDS); ent++)
+			ent->age = (++NUMCounter);
 	}
-	
+
 	/* ----------
 	 * Cache is full - needs remove any older entry
 	 * ----------
 	 */
-	if (n_NUMCache > NUM_CACHE_FIELDS) {
+	if (n_NUMCache > NUM_CACHE_FIELDS)
+	{
+
+		NUMCacheEntry *old = NUMCache + 0;
 
-		NUMCacheEntry   *old 	= NUMCache+0;
-		
 #ifdef DEBUG_TO_FROM_CHAR
 		elog(DEBUG_elog_output, "Cache is full (%d)", n_NUMCache);
 #endif
-	
-		for(ent = NUMCache; ent <= (NUMCache + NUM_CACHE_FIELDS); ent++) {
+
+		for (ent = NUMCache; ent <= (NUMCache + NUM_CACHE_FIELDS); ent++)
+		{
 			if (ent->age < old->age)
 				old = ent;
-		}	
-#ifdef DEBUG_TO_FROM_CHAR		
+		}
+#ifdef DEBUG_TO_FROM_CHAR
 		elog(DEBUG_elog_output, "OLD: '%s' AGE: %d", old->str, old->age);
-#endif		
-		strcpy(old->str, str);		/* check str size before this func. */
+#endif
+		strcpy(old->str, str);	/* check str size before this func. */
 		/* old->format fill parser */
 		old->age = (++NUMCounter);
-		
+
 		ent = old;
-		
-	} else {
-#ifdef DEBUG_TO_FROM_CHAR	
+
+	}
+	else
+	{
+#ifdef DEBUG_TO_FROM_CHAR
 		elog(DEBUG_elog_output, "NEW (%d)", n_NUMCache);
-#endif	
+#endif
 		ent = NUMCache + n_NUMCache;
-		strcpy(ent->str, str);		/* check str size before this func. */
+		strcpy(ent->str, str);	/* check str size before this func. */
 		/* ent->format fill parser */
 		ent->age = (++NUMCounter);
 		++n_NUMCache;
 	}
-	
+
 	zeroize_NUM(&ent->Num);
-	
-	return ent;		/* never */
+
+	return ent;					/* never */
 }
 
 static NUMCacheEntry *
-NUM_cache_search( char *str )
+NUM_cache_search(char *str)
 {
-	int		i = 0;
-	NUMCacheEntry 	*ent;
+	int			i = 0;
+	NUMCacheEntry *ent;
 
 	/* counter overload check  - paranoa? */
-	if (NUMCounter + NUM_CACHE_FIELDS >= MAX_INT32) {
+	if (NUMCounter + NUM_CACHE_FIELDS >= MAX_INT32)
+	{
 		NUMCounter = 0;
 
-		for(ent = NUMCache; ent <= (NUMCache + NUM_CACHE_FIELDS); ent++)
-		        ent->age = (++NUMCounter);
+		for (ent = NUMCache; ent <= (NUMCache + NUM_CACHE_FIELDS); ent++)
+			ent->age = (++NUMCounter);
 	}
 
-	for(ent = NUMCache; ent <= (NUMCache + NUM_CACHE_FIELDS); ent++) {
+	for (ent = NUMCache; ent <= (NUMCache + NUM_CACHE_FIELDS); ent++)
+	{
 		if (i == n_NUMCache)
 			break;
-		if (strcmp(ent->str, str) == 0) {
+		if (strcmp(ent->str, str) == 0)
+		{
 			ent->age = (++NUMCounter);
 			return ent;
-		}	
-		i++;	
+		}
+		i++;
 	}
-	
+
 	return (NUMCacheEntry *) NULL;
 }
 
@@ -2551,82 +2804,87 @@ NUM_cache_search( char *str )
  * ----------
  */
 static FormatNode *
-NUM_cache( int len, NUMDesc *Num, char *pars_str, int *flag)
-{	
-	FormatNode 	*format = NULL;
-	char		*str;
+NUM_cache(int len, NUMDesc *Num, char *pars_str, int *flag)
+{
+	FormatNode *format = NULL;
+	char	   *str;
 
 	/* ----------
 	 * Convert VARDATA() to string
 	 * ----------
 	 */
-	str = (char *) palloc(len + 1);    
+	str = (char *) palloc(len + 1);
 	memcpy(str, pars_str, len);
-	*(str + len) = '\0'; 
+	*(str + len) = '\0';
 
 	/* ----------
-	 * Allocate new memory if format picture is bigger than static cache 
+	 * Allocate new memory if format picture is bigger than static cache
 	 * and not use cache (call parser always) - flag=1 show this variant
 	 * ----------
-         */
-	if ( len > NUM_CACHE_SIZE ) {
+		 */
+	if (len > NUM_CACHE_SIZE)
+	{
 
 		format = (FormatNode *) palloc((len + 1) * sizeof(FormatNode));
-		*flag  = 1;
-		
-        	zeroize_NUM(Num);
-		
-		parse_format(format, str, NUM_keywords, 
-         			NULL, NUM_index, NUM_TYPE, Num);
-	
-		(format + len)->type = NODE_TYPE_END;		/* Paranoa? */	
-		
-	} else {
-		
+		*flag = 1;
+
+		zeroize_NUM(Num);
+
+		parse_format(format, str, NUM_keywords,
+					 NULL, NUM_index, NUM_TYPE, Num);
+
+		(format + len)->type = NODE_TYPE_END;	/* Paranoa? */
+
+	}
+	else
+	{
+
 		/* ----------
 		 * Use cache buffers
 		 * ----------
 		 */
-		NUMCacheEntry	*ent;
+		NUMCacheEntry *ent;
+
 		flag = 0;
 
-       		if ((ent = NUM_cache_search(str)) == NULL) {
-	
+		if ((ent = NUM_cache_search(str)) == NULL)
+		{
+
 			ent = NUM_cache_getnew(str);
-	
+
 			/* ----------
 			 * Not in the cache, must run parser and save a new
-			 * format-picture to the cache. 
+			 * format-picture to the cache.
 			 * ----------
-        		 */		
-         		parse_format(ent->format, str, NUM_keywords, 
-         			NULL, NUM_index, NUM_TYPE, &ent->Num);
-			
-			(ent->format + len)->type = NODE_TYPE_END;		/* Paranoa? */	
-			
-        	} 
-        	
-        	format = ent->format;
-        	
+				 */
+			parse_format(ent->format, str, NUM_keywords,
+						 NULL, NUM_index, NUM_TYPE, &ent->Num);
+
+			(ent->format + len)->type = NODE_TYPE_END;	/* Paranoa? */
+
+		}
+
+		format = ent->format;
+
 		/* ----------
 		 * Copy cache to used struct
 		 * ----------
 		 */
-		Num->flag 		= ent->Num.flag;
-		Num->lsign		= ent->Num.lsign;
-		Num->pre		= ent->Num.pre;
-		Num->post		= ent->Num.post;
-		Num->pre_lsign_num 	= ent->Num.pre_lsign_num;	
-		Num->need_locale	= ent->Num.need_locale; 
-		Num->multi		= ent->Num.multi; 	
-		Num->zero_start		= ent->Num.zero_start;
-		Num->zero_end		= ent->Num.zero_end;
-	}
-
-#ifdef DEBUG_TO_FROM_CHAR	 
+		Num->flag = ent->Num.flag;
+		Num->lsign = ent->Num.lsign;
+		Num->pre = ent->Num.pre;
+		Num->post = ent->Num.post;
+		Num->pre_lsign_num = ent->Num.pre_lsign_num;
+		Num->need_locale = ent->Num.need_locale;
+		Num->multi = ent->Num.multi;
+		Num->zero_start = ent->Num.zero_start;
+		Num->zero_end = ent->Num.zero_end;
+	}
+
+#ifdef DEBUG_TO_FROM_CHAR
 	/* dump_node(format, len); */
-	dump_index(NUM_keywords, NUM_index);  
-#endif         	
+	dump_index(NUM_keywords, NUM_index);
+#endif
 
 	pfree(str);
 	return format;
@@ -2636,39 +2894,44 @@ NUM_cache( int len, NUMDesc *Num, char *pars_str, int *flag)
 static char *
 int_to_roman(int number)
 {
-	int	len	= 0, 
-		num	= 0, 
-		set	= 0;		
-	char	*p	= NULL,
-		*result,
-		numstr[5];	
-
-	result = (char *) palloc( 16 );
+	int			len = 0,
+				num = 0,
+				set = 0;
+	char	   *p = NULL,
+			   *result,
+				numstr[5];
+
+	result = (char *) palloc(16);
 	*result = '\0';
-	
-	if (number > 3999 || number < 1) {
+
+	if (number > 3999 || number < 1)
+	{
 		fill_str(result, '#', 15);
 		return result;
 	}
 	len = sprintf(numstr, "%d", number);
-	
-	for(p=numstr; *p!='\0'; p++, --len) {
-		num = *p - 49; 			/* 48 ascii + 1 */
+
+	for (p = numstr; *p != '\0'; p++, --len)
+	{
+		num = *p - 49;			/* 48 ascii + 1 */
 		if (num < 0)
 			continue;
-		if (num == -1 && set==0)
+		if (num == -1 && set == 0)
 			continue;
 		set = 1;
-			
-		if (len > 3) { 
-			while(num-- != -1)
+
+		if (len > 3)
+		{
+			while (num-- != -1)
 				strcat(result, "M");
-		} else {
-			if (len==3)	
-				strcat(result, rm100[num]);	
-			else if (len==2)	
+		}
+		else
+		{
+			if (len == 3)
+				strcat(result, rm100[num]);
+			else if (len == 2)
 				strcat(result, rm10[num]);
-			else if (len==1)	
+			else if (len == 1)
 				strcat(result, rm1[num]);
 		}
 	}
@@ -2687,17 +2950,18 @@ NUM_prepare_locale(NUMProc *Np)
 
 #ifdef USE_LOCALE
 
-	if (Np->Num->need_locale) {
+	if (Np->Num->need_locale)
+	{
 
-		struct lconv	*lconv;
+		struct lconv *lconv;
 
 		/* ----------
 		 * Get locales
 		 * ----------
 		 */
 		lconv = PGLC_localeconv();
-			
-		/* ---------- 	
+
+		/* ----------
 		 * Positive / Negative number sign
 		 * ----------
 		 */
@@ -2705,54 +2969,56 @@ NUM_prepare_locale(NUMProc *Np)
 			Np->L_negative_sign = lconv->negative_sign;
 		else
 			Np->L_negative_sign = "-";
-				
+
 		if (lconv->positive_sign && *lconv->positive_sign)
 			Np->L_positive_sign = lconv->positive_sign;
-		else	
-			Np->L_positive_sign = "+";	
-		
+		else
+			Np->L_positive_sign = "+";
+
 		/* ----------
 		 * Number thousands separator
 		 * ----------
-		 */	
+		 */
 		if (lconv->thousands_sep && *lconv->thousands_sep)
 			Np->L_thousands_sep = lconv->thousands_sep;
-		else	
+		else
 			Np->L_thousands_sep = ",";
-		
+
 		/* ----------
 		 * Number decimal point
 		 * ----------
 		 */
 		if (lconv->decimal_point && *lconv->decimal_point)
 			Np->decimal = lconv->decimal_point;
-		else	
+		else
 			Np->decimal = ".";
-		
+
 		/* ----------
 		 * Currency symbol
 		 * ----------
 		 */
-		if (lconv->currency_symbol && *lconv->currency_symbol)	
+		if (lconv->currency_symbol && *lconv->currency_symbol)
 			Np->L_currency_symbol = lconv->currency_symbol;
-		else	
-			Np->L_currency_symbol = " ";	
+		else
+			Np->L_currency_symbol = " ";
+
 
-	
 		if (!IS_LDECIMAL(Np->Num))
-			Np->decimal = ".";	
-	} else {			  
+			Np->decimal = ".";
+	}
+	else
+	{
 
 #endif
 		/* ----------
 		 * Default values
 		 * ----------
 		 */
-		Np->L_negative_sign	= "-"; 
-		Np->L_positive_sign	= "+";
-		Np->decimal	  	= ".";	
-		Np->L_thousands_sep	= ",";
-		Np->L_currency_symbol 	= " ";
+		Np->L_negative_sign = "-";
+		Np->L_positive_sign = "+";
+		Np->decimal = ".";
+		Np->L_thousands_sep = ",";
+		Np->L_currency_symbol = " ";
 
 #ifdef USE_LOCALE
 	}
@@ -2761,28 +3027,29 @@ NUM_prepare_locale(NUMProc *Np)
 
 /* ----------
  * Return pointer of last relevant number after decimal point
- *	12.0500	--> last relevant is '5'
+ *	12.0500 --> last relevant is '5'
  * ----------
- */ 
+ */
 static char *
 get_last_relevant_decnum(char *num)
 {
-	char	*result, 
-		*p = strchr(num, '.');
-		
-#ifdef DEBUG_TO_FROM_CHAR	
+	char	   *result,
+			   *p = strchr(num, '.');
+
+#ifdef DEBUG_TO_FROM_CHAR
 	elog(DEBUG_elog_output, "CALL: get_last_relevant_decnum()");
 #endif
-	
-	if (!p)	
+
+	if (!p)
 		p = num;
 	result = p;
-	
-	while(*(++p)) {
-		if (*p!='0')
+
+	while (*(++p))
+	{
+		if (*p != '0')
 			result = p;
 	}
-	
+
 	return result;
 }
 
@@ -2791,53 +3058,57 @@ get_last_relevant_decnum(char *num)
  * ----------
  */
 static void
-NUM_numpart_from_char(NUMProc *Np, int id, int plen) 
+NUM_numpart_from_char(NUMProc *Np, int id, int plen)
 {
-	
+
 #ifdef DEBUG_TO_FROM_CHAR
 	elog(DEBUG_elog_output, " --- scan start --- ");
 #endif
 
-	if (*Np->inout_p == ' ') 
-		Np->inout_p++;		
+	if (*Np->inout_p == ' ')
+		Np->inout_p++;
 
 #define OVERLOAD_TEST	(Np->inout_p >= Np->inout + plen)
 
-  	if (*Np->inout_p == ' ') 
-  		Np->inout_p++;		
-  
+	if (*Np->inout_p == ' ')
+		Np->inout_p++;
+
 	if (OVERLOAD_TEST)
 		return;
- 
+
 	/* ----------
 	 * read sign
 	 * ----------
 	 */
-	if (*Np->number == ' ' && (id == NUM_0 || id == NUM_9 || NUM_S)) {
+	if (*Np->number == ' ' && (id == NUM_0 || id == NUM_9 || NUM_S))
+	{
 
 #ifdef DEBUG_TO_FROM_CHAR
 		elog(DEBUG_elog_output, "Try read sign (%c).", *Np->inout_p);
-#endif		
+#endif
 		/* ----------
 		 * locale sign
 		 * ----------
 		 */
-		if (IS_LSIGN(Np->Num)) {
-		
-			int x = strlen(Np->L_negative_sign);
-			
+		if (IS_LSIGN(Np->Num))
+		{
+
+			int			x = strlen(Np->L_negative_sign);
+
 #ifdef DEBUG_TO_FROM_CHAR
 			elog(DEBUG_elog_output, "Try read locale sign (%c).", *Np->inout_p);
-#endif			
-			if (!strncmp(Np->inout_p, Np->L_negative_sign, x)) {
-				Np->inout_p += x-1;
+#endif
+			if (!strncmp(Np->inout_p, Np->L_negative_sign, x))
+			{
+				Np->inout_p += x - 1;
 				*Np->number = '-';
 				return;
 			}
-						
+
 			x = strlen(Np->L_positive_sign);
-			if (!strncmp(Np->inout_p, Np->L_positive_sign, x)) {
-				Np->inout_p += x-1;
+			if (!strncmp(Np->inout_p, Np->L_positive_sign, x))
+			{
+				Np->inout_p += x - 1;
 				*Np->number = '+';
 				return;
 			}
@@ -2845,76 +3116,86 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen)
 
 #ifdef DEBUG_TO_FROM_CHAR
 		elog(DEBUG_elog_output, "Try read sipmle sign (%c).", *Np->inout_p);
-#endif		
+#endif
 		/* ----------
 		 * simple + - < >
 		 * ----------
 		 */
-		if (*Np->inout_p == '-' || (IS_BRACKET(Np->Num) && 
-		    *Np->inout_p == '<' )) {
-			
-			*Np->number = '-';		/* set - */
+		if (*Np->inout_p == '-' || (IS_BRACKET(Np->Num) &&
+									*Np->inout_p == '<'))
+		{
+
+			*Np->number = '-';	/* set - */
 			Np->inout_p++;
-			
-		} else if (*Np->inout_p == '+') {
-				
-			*Np->number = '+';		/* set + */
+
+		}
+		else if (*Np->inout_p == '+')
+		{
+
+			*Np->number = '+';	/* set + */
 			Np->inout_p++;
-		} 		
+		}
 	}
 
 	if (OVERLOAD_TEST)
 		return;
-	
+
 	/* ----------
 	 * read digit
 	 * ----------
 	 */
-	if (isdigit((unsigned char) *Np->inout_p)) {
-		
+	if (isdigit((unsigned char) *Np->inout_p))
+	{
+
 		if (Np->read_dec && Np->read_post == Np->Num->post)
 			return;
-		
+
 		*Np->number_p = *Np->inout_p;
 		Np->number_p++;
-	
+
 		if (Np->read_dec)
 			Np->read_post++;
 
-#ifdef DEBUG_TO_FROM_CHAR	
+#ifdef DEBUG_TO_FROM_CHAR
 		elog(DEBUG_elog_output, "Read digit (%c).", *Np->inout_p);
-#endif	
-	
-	/* ----------
-	 * read decimal point
-	 * ----------
-	 */
-	} else if (IS_DECIMAL(Np->Num)) {
+#endif
+
+		/* ----------
+		 * read decimal point
+		 * ----------
+		 */
+	}
+	else if (IS_DECIMAL(Np->Num))
+	{
 
 #ifdef DEBUG_TO_FROM_CHAR
 		elog(DEBUG_elog_output, "Try read decimal point (%c).", *Np->inout_p);
-#endif		
-		if (*Np->inout_p == '.') {
-		
+#endif
+		if (*Np->inout_p == '.')
+		{
+
 			*Np->number_p = '.';
 			Np->number_p++;
 			Np->read_dec = TRUE;
-			
-		} else {
-			
-			int x = strlen(Np->decimal);
-			
+
+		}
+		else
+		{
+
+			int			x = strlen(Np->decimal);
+
 #ifdef DEBUG_TO_FROM_CHAR
 			elog(DEBUG_elog_output, "Try read locale point (%c).", *Np->inout_p);
-#endif			
-			if (!strncmp(Np->inout_p, Np->decimal, x)) {
-				Np->inout_p += x-1;
+#endif
+			if (!strncmp(Np->inout_p, Np->decimal, x))
+			{
+				Np->inout_p += x - 1;
 				*Np->number_p = '.';
 				Np->number_p++;
 				Np->read_dec = TRUE;
 			}
 		}
-	}	
+	}
 }
 
 /* ----------
@@ -2922,334 +3203,379 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen)
  * ----------
  */
 static void
-NUM_numpart_to_char(NUMProc *Np, int id) 
-{	
+NUM_numpart_to_char(NUMProc *Np, int id)
+{
 	if (IS_ROMAN(Np->Num))
 		return;
-			
+
 	/* Note: in this elog() output not set '\0' in 'inout' */
 
-#ifdef DEBUG_TO_FROM_CHAR	
+#ifdef DEBUG_TO_FROM_CHAR
+
 	/*
- 	 * Np->num_curr is number of current item in format-picture, it is not
- 	 * current position in inout! 
- 	 */
-	elog(DEBUG_elog_output, 
-	
-	"SIGN_WROTE: %d, CURRENT: %d, NUMBER_P: '%s', INOUT: '%s'", 
-		Np->sign_wrote, 
-		Np->num_curr,
-		Np->number_p, 
-		Np->inout);
-#endif	
+	 * Np->num_curr is number of current item in format-picture, it is not
+	 * current position in inout!
+	 */
+	elog(DEBUG_elog_output,
+
+		 "SIGN_WROTE: %d, CURRENT: %d, NUMBER_P: '%s', INOUT: '%s'",
+		 Np->sign_wrote,
+		 Np->num_curr,
+		 Np->number_p,
+		 Np->inout);
+#endif
 	Np->num_in = FALSE;
-	
+
 	/* ----------
 	 * Write sign
 	 * ----------
 	 */
-	if (Np->num_curr == Np->sign_pos && Np->sign_wrote==FALSE) {
+	if (Np->num_curr == Np->sign_pos && Np->sign_wrote == FALSE)
+	{
 
-#ifdef DEBUG_TO_FROM_CHAR	
+#ifdef DEBUG_TO_FROM_CHAR
 		elog(DEBUG_elog_output, "Writing sign to position: %d", Np->num_curr);
-#endif	
-		if (IS_LSIGN(Np->Num)) {
-		
+#endif
+		if (IS_LSIGN(Np->Num))
+		{
+
 			/* ----------
-			 * Write locale SIGN 
+			 * Write locale SIGN
 			 * ----------
 			 */
-			if (Np->sign=='-')		
-					strcpy(Np->inout_p, Np->L_negative_sign);
-				else 
-					strcpy(Np->inout_p, Np->L_positive_sign);
-			Np->inout_p += strlen(Np->inout_p);			
-		
-		} else if (IS_BRACKET(Np->Num)) {
-			*Np->inout_p = '<';		/* Write < */
-			++Np->inout_p;	
-		
-		} else if (Np->sign=='+') {
-			*Np->inout_p = ' ';		/* Write + */
+			if (Np->sign == '-')
+				strcpy(Np->inout_p, Np->L_negative_sign);
+			else
+				strcpy(Np->inout_p, Np->L_positive_sign);
+			Np->inout_p += strlen(Np->inout_p);
+
+		}
+		else if (IS_BRACKET(Np->Num))
+		{
+			*Np->inout_p = '<'; /* Write < */
 			++Np->inout_p;
-			
-		} else if (Np->sign=='-') {		/* Write - */
+
+		}
+		else if (Np->sign == '+')
+		{
+			*Np->inout_p = ' '; /* Write + */
+			++Np->inout_p;
+
+		}
+		else if (Np->sign == '-')
+		{						/* Write - */
 			*Np->inout_p = '-';
-			++Np->inout_p;	
-		}	
+			++Np->inout_p;
+		}
 		Np->sign_wrote = TRUE;
 
-	} else if (Np->sign_wrote && IS_BRACKET(Np->Num) && 
-		  (Np->num_curr == Np->num_count + (Np->num_pre ? 1 : 0)
-		  			+ (IS_DECIMAL(Np->Num) ? 1 : 0))) {
+	}
+	else if (Np->sign_wrote && IS_BRACKET(Np->Num) &&
+			 (Np->num_curr == Np->num_count + (Np->num_pre ? 1 : 0)
+			  + (IS_DECIMAL(Np->Num) ? 1 : 0)))
+	{
 		/* ----------
 		 * Write close BRACKET
 		 * ----------
-		 */		
+		 */
 #ifdef DEBUG_TO_FROM_CHAR
 		elog(DEBUG_elog_output, "Writing bracket to position %d", Np->num_curr);
-#endif		
-		*Np->inout_p = '>';			/* Write '>' */
-		++Np->inout_p;	
+#endif
+		*Np->inout_p = '>';		/* Write '>' */
+		++Np->inout_p;
 	}
-	
+
 	/* ----------
 	 * digits / FM / Zero / Dec. point
 	 * ----------
 	 */
-	if (id == NUM_9 || id == NUM_0 || id == NUM_D || id == NUM_DEC || 
-	   (id == NUM_S && Np->num_curr < Np->num_pre)) {
-	
-		if (Np->num_curr < Np->num_pre && 
-		    (Np->Num->zero_start > Np->num_curr || !IS_ZERO(Np->Num))) {
-		    
- 			/* ----------
- 			 * Write blank space
- 			 * ----------
- 			 */ 			
- 			if (!IS_FILLMODE(Np->Num)) { 
- #ifdef DEBUG_TO_FROM_CHAR			
- 				elog(DEBUG_elog_output, "Writing blank space to position %d", Np->num_curr);
- #endif			
- 				*Np->inout_p = ' ';		/* Write ' ' */
+	if (id == NUM_9 || id == NUM_0 || id == NUM_D || id == NUM_DEC ||
+		(id == NUM_S && Np->num_curr < Np->num_pre))
+	{
+
+		if (Np->num_curr < Np->num_pre &&
+			(Np->Num->zero_start > Np->num_curr || !IS_ZERO(Np->Num)))
+		{
+
+			/* ----------
+			 * Write blank space
+			 * ----------
+			 */
+			if (!IS_FILLMODE(Np->Num))
+			{
+#ifdef DEBUG_TO_FROM_CHAR
+				elog(DEBUG_elog_output, "Writing blank space to position %d", Np->num_curr);
+#endif
+				*Np->inout_p = ' ';		/* Write ' ' */
 				++Np->inout_p;
 			}
 
-		} else if (IS_ZERO(Np->Num) && 
-			   Np->num_curr < Np->num_pre &&
-			   Np->Num->zero_start <= Np->num_curr) {
-		
+		}
+		else if (IS_ZERO(Np->Num) &&
+				 Np->num_curr < Np->num_pre &&
+				 Np->Num->zero_start <= Np->num_curr)
+		{
+
 			/* ----------
 			 * Write ZERO
 			 * ----------
 			 */
-#ifdef DEBUG_TO_FROM_CHAR		
+#ifdef DEBUG_TO_FROM_CHAR
 			elog(DEBUG_elog_output, "Writing zero to position %d", Np->num_curr);
-#endif			
-			*Np->inout_p = '0';		/* Write '0' */
+#endif
+			*Np->inout_p = '0'; /* Write '0' */
 			++Np->inout_p;
 			Np->num_in = TRUE;
-		
-		} else {
+
+		}
+		else
+		{
 
 			/* ----------
-			* Write Decinal point 
+			* Write Decinal point
 			* ----------
-		 	*/
-			if (*Np->number_p=='.') {
-			 
-				if (!Np->last_relevant || *Np->last_relevant!='.' ) {
-#ifdef DEBUG_TO_FROM_CHAR					
+			*/
+			if (*Np->number_p == '.')
+			{
+
+				if (!Np->last_relevant || *Np->last_relevant != '.')
+				{
+#ifdef DEBUG_TO_FROM_CHAR
 					elog(DEBUG_elog_output, "Writing decimal point to position %d", Np->num_curr);
-#endif					
+#endif
 					strcpy(Np->inout_p, Np->decimal);	/* Write DEC/D */
 					Np->inout_p += strlen(Np->inout_p);
-				
-				/* terrible Ora
-				 *	'0' -- 9.9 --> '0.'
-				 */
-				} else if (IS_FILLMODE(Np->Num) && *Np->number == '0' && 
-					   Np->last_relevant && *Np->last_relevant=='.' ) {
-					   
+
+					/*
+					 * terrible Ora '0' -- 9.9 --> '0.'
+					 */
+				}
+				else if (IS_FILLMODE(Np->Num) && *Np->number == '0' &&
+						 Np->last_relevant && *Np->last_relevant == '.')
+				{
+
 					strcpy(Np->inout_p, Np->decimal);	/* Write DEC/D */
 					Np->inout_p += strlen(Np->inout_p);
 				}
-				
-			} else  {
+
+			}
+			else
+			{
 
 				/* ----------
 				 * Write Digits
 				 * ----------
 				 */
 				if (Np->last_relevant && Np->number_p > Np->last_relevant &&
-				    id != NUM_0)
+					id != NUM_0)
 					;
-				
-				/* terrible Ora format: 
-				 *	'0.1' -- 9.9 --> '  .1' 
+
+				/*
+				 * terrible Ora format: '0.1' -- 9.9 --> '  .1'
 				 */
-				else if (!IS_ZERO(Np->Num) && *Np->number == '0' && 
-				          Np->number == Np->number_p && Np->Num->post !=0) {
-					
-					if (!IS_FILLMODE(Np->Num)) {
+				else if (!IS_ZERO(Np->Num) && *Np->number == '0' &&
+						 Np->number == Np->number_p && Np->Num->post != 0)
+				{
+
+					if (!IS_FILLMODE(Np->Num))
+					{
 						*Np->inout_p = ' ';
 						++Np->inout_p;
-					
-					/* total terible Ora:
-					 *	'0' -- FM9.9 --> '0.'
-					 */	
-					} else if (Np->last_relevant && *Np->last_relevant=='.') { 
+
+						/*
+						 * total terible Ora: '0' -- FM9.9 --> '0.'
+						 */
+					}
+					else if (Np->last_relevant && *Np->last_relevant == '.')
+					{
 						*Np->inout_p = '0';
 						++Np->inout_p;
 					}
-					
-				} else {
+
+				}
+				else
+				{
 #ifdef DEBUG_TO_FROM_CHAR
 					elog(DEBUG_elog_output, "Writing digit '%c' to position %d", *Np->number_p, Np->num_curr);
-#endif				
-					*Np->inout_p = *Np->number_p;	/* Write DIGIT */
+#endif
+					*Np->inout_p = *Np->number_p;		/* Write DIGIT */
 					++Np->inout_p;
 					Np->num_in = TRUE;
-				}	
+				}
 			}
 			++Np->number_p;
-		}	
+		}
 	}
-	
+
 	++Np->num_curr;
 }
-		
+
 static char *
-NUM_processor (FormatNode *node, NUMDesc *Num, char *inout, char *number, 
-					int plen, int sign, int type)
+NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
+			  int plen, int sign, int type)
 {
-	FormatNode	*n;
-	NUMProc		_Np, *Np = &_Np;
-	
-	Np->Num 	= Num;
-	Np->type	= type;
-	Np->number	= number;
-	Np->inout	= inout;
+	FormatNode *n;
+	NUMProc		_Np,
+			   *Np = &_Np;
+
+	Np->Num = Num;
+	Np->type = type;
+	Np->number = number;
+	Np->inout = inout;
 	Np->last_relevant = NULL;
-	Np->read_post	= 0;
-	Np->read_dec	= FALSE;
+	Np->read_post = 0;
+	Np->read_dec = FALSE;
 
 	if (Np->Num->zero_start)
 		--Np->Num->zero_start;
 
-	/* ---------- 
-	 * Roman correction 
+	/* ----------
+	 * Roman correction
 	 * ----------
 	 */
-	if (IS_ROMAN(Np->Num)) {		
-		if (Np->type==FROM_CHAR)
-			elog(ERROR, "to_number(): RN is not supported");	
-			
-		Np->Num->lsign = Np->Num->pre_lsign_num = Np->Num->post = 
-		Np->Num->pre = Np->num_pre = Np->sign = 0;
-		
-		if (IS_FILLMODE(Np->Num)){
+	if (IS_ROMAN(Np->Num))
+	{
+		if (Np->type == FROM_CHAR)
+			elog(ERROR, "to_number(): RN is not supported");
+
+		Np->Num->lsign = Np->Num->pre_lsign_num = Np->Num->post =
+			Np->Num->pre = Np->num_pre = Np->sign = 0;
+
+		if (IS_FILLMODE(Np->Num))
+		{
 			Np->Num->flag = 0;
 			Np->Num->flag |= NUM_F_FILLMODE;
-		} else {
+		}
+		else
 			Np->Num->flag = 0;
-		}	
-		Np->Num->flag |= NUM_F_ROMAN; 
+		Np->Num->flag |= NUM_F_ROMAN;
 	}
-	
+
 	/* ----------
 	 * Sign
 	 * ----------
 	 */
-	if (type == FROM_CHAR) {
-		Np->sign 	= FALSE; 
-		Np->sign_pos	= -1;
-	} else {
-		Np->sign = sign; 
-		
-		if (Np->sign != '-') {
+	if (type == FROM_CHAR)
+	{
+		Np->sign = FALSE;
+		Np->sign_pos = -1;
+	}
+	else
+	{
+		Np->sign = sign;
+
+		if (Np->sign != '-')
+		{
 			Np->Num->flag &= ~NUM_F_BRACKET;
 			Np->Num->flag &= ~NUM_F_MINUS;
-		} else if (Np->sign != '+') {
-			Np->Num->flag &= ~NUM_F_PLUS;
 		}
-	
-		if (Np->sign=='+' && IS_FILLMODE(Np->Num) && !IS_LSIGN(Np->Num)) 
-			Np->sign_wrote	= TRUE;		/* needn't sign */	
+		else if (Np->sign != '+')
+			Np->Num->flag &= ~NUM_F_PLUS;
+
+		if (Np->sign == '+' && IS_FILLMODE(Np->Num) && !IS_LSIGN(Np->Num))
+			Np->sign_wrote = TRUE;		/* needn't sign */
 		else
-			Np->sign_wrote  = FALSE;        /* need sign */
+			Np->sign_wrote = FALSE;		/* need sign */
 
 		Np->sign_pos = -1;
-	
+
 		if (Np->Num->lsign == NUM_LSIGN_PRE && Np->Num->pre == Np->Num->pre_lsign_num)
 			Np->Num->lsign = NUM_LSIGN_POST;
-	
+
 		/* MI/PL/SG - write sign itself and not in number */
 		if (IS_PLUS(Np->Num) || IS_MINUS(Np->Num))
-			Np->sign_wrote = TRUE;         /* needn't sign */
+			Np->sign_wrote = TRUE;		/* needn't sign */
 	}
 
 	/* ----------
 	 * Count
 	 * ----------
 	 */
-	Np->num_count = Np->Num->post + Np->Num->pre -1;
+	Np->num_count = Np->Num->post + Np->Num->pre - 1;
 
-	if (type == TO_CHAR)  {
+	if (type == TO_CHAR)
+	{
 		Np->num_pre = plen;
 
-		if (IS_FILLMODE(Np->Num)) {
+		if (IS_FILLMODE(Np->Num))
+		{
 			if (IS_DECIMAL(Np->Num))
 				Np->last_relevant = get_last_relevant_decnum(
-					Np->number + 
-					((Np->Num->zero_end - Np->num_pre > 0) ? 
-					 Np->Num->zero_end - Np->num_pre : 0));
-		}	
-		
-		if (!Np->sign_wrote && Np->num_pre==0)
+															 Np->number +
+								 ((Np->Num->zero_end - Np->num_pre > 0) ?
+								  Np->Num->zero_end - Np->num_pre : 0));
+		}
+
+		if (!Np->sign_wrote && Np->num_pre == 0)
 			++Np->num_count;
-		
-	        if (!Np->sign_wrote) {
-	        
-	        	/* ----------
-	        	 * Set SING position
-	        	 * ----------
-	        	 */
-	        	if (Np->Num->lsign == NUM_LSIGN_POST) {
-	        		Np->sign_pos = Np->num_count + (Np->num_pre ? 1 : 0);
-	        	
-	        		if (IS_DECIMAL(Np->Num))	/* decimal point correctio */
-	        			++Np->sign_pos;
-	        	}
-	        	else if (IS_ZERO(Np->Num) && Np->num_pre > Np->Num->zero_start)
-	        		Np->sign_pos = Np->Num->zero_start ? Np->Num->zero_start : 0;         
-	        	
-	        	else
-	        		Np->sign_pos = Np->num_pre && !IS_FILLMODE(Np->Num) ? Np->num_pre : 0;         
-	        
-	        	/* ----------
-	        	 * terrible Ora format
-	        	 * ----------
-	        	 */
-			if (!IS_ZERO(Np->Num) && *Np->number == '0' && 
-	        	    !IS_FILLMODE(Np->Num) && Np->Num->post!=0) {
-	        		
-	        		++Np->sign_pos;
-	        		
-	        		if (IS_LSIGN(Np->Num)) {
-	        			if (Np->Num->lsign == NUM_LSIGN_PRE)
-	        				++Np->sign_pos;
-	        			else
-	        				--Np->sign_pos;	
-	        		}	
-	        	}
-	        }
-	        	
-	} else {
+
+		if (!Np->sign_wrote)
+		{
+
+			/* ----------
+			 * Set SING position
+			 * ----------
+			 */
+			if (Np->Num->lsign == NUM_LSIGN_POST)
+			{
+				Np->sign_pos = Np->num_count + (Np->num_pre ? 1 : 0);
+
+				if (IS_DECIMAL(Np->Num))		/* decimal point correctio */
+					++Np->sign_pos;
+			}
+			else if (IS_ZERO(Np->Num) && Np->num_pre > Np->Num->zero_start)
+				Np->sign_pos = Np->Num->zero_start ? Np->Num->zero_start : 0;
+
+			else
+				Np->sign_pos = Np->num_pre && !IS_FILLMODE(Np->Num) ? Np->num_pre : 0;
+
+			/* ----------
+			 * terrible Ora format
+			 * ----------
+			 */
+			if (!IS_ZERO(Np->Num) && *Np->number == '0' &&
+				!IS_FILLMODE(Np->Num) && Np->Num->post != 0)
+			{
+
+				++Np->sign_pos;
+
+				if (IS_LSIGN(Np->Num))
+				{
+					if (Np->Num->lsign == NUM_LSIGN_PRE)
+						++Np->sign_pos;
+					else
+						--Np->sign_pos;
+				}
+			}
+		}
+
+	}
+	else
+	{
 		Np->num_pre = 0;
-		*Np->number	= ' ';		/* sign space */	
-		*(Np->number+1)	= '\0';	
-	}
-		
-	Np->num_in	= 0;
-	Np->num_curr 	= 0;	
-
-#ifdef DEBUG_TO_FROM_CHAR	
-	elog(DEBUG_elog_output, 
-	
-	"\n\tNUM: '%s'\n\tPRE: %d\n\tPOST: %d\n\tNUM_COUNT: %d\n\tNUM_PRE: %d\n\tSIGN_POS: %d\n\tSIGN_WROTE: %s\n\tZERO: %s\n\tZERO_START: %d\n\tZERO_END: %d\n\tLAST_RELEVANT: %s",
-			Np->number, 
-			Np->Num->pre, 
-			Np->Num->post,
-			Np->num_count, 
-			Np->num_pre,
-			Np->sign_pos,
-			Np->sign_wrote 		? "Yes" : "No",
-			IS_ZERO(Np->Num)	? "Yes" : "No",
-			Np->Num->zero_start,
-			Np->Num->zero_end,
-			Np->last_relevant ? Np->last_relevant : "<not set>"
-	);	
+		*Np->number = ' ';		/* sign space */
+		*(Np->number + 1) = '\0';
+	}
+
+	Np->num_in = 0;
+	Np->num_curr = 0;
+
+#ifdef DEBUG_TO_FROM_CHAR
+	elog(DEBUG_elog_output,
+
+		 "\n\tNUM: '%s'\n\tPRE: %d\n\tPOST: %d\n\tNUM_COUNT: %d\n\tNUM_PRE: %d\n\tSIGN_POS: %d\n\tSIGN_WROTE: %s\n\tZERO: %s\n\tZERO_START: %d\n\tZERO_END: %d\n\tLAST_RELEVANT: %s",
+		 Np->number,
+		 Np->Num->pre,
+		 Np->Num->post,
+		 Np->num_count,
+		 Np->num_pre,
+		 Np->sign_pos,
+		 Np->sign_wrote ? "Yes" : "No",
+		 IS_ZERO(Np->Num) ? "Yes" : "No",
+		 Np->Num->zero_start,
+		 Np->Num->zero_end,
+		 Np->last_relevant ? Np->last_relevant : "<not set>"
+		);
 #endif
 
 	/* ----------
@@ -3262,181 +3588,217 @@ NUM_processor (FormatNode *node, NUMDesc *Num, char *inout, char *number,
 	 * Processor direct cycle
 	 * ----------
 	 */
-	if (Np->type == FROM_CHAR) 
-		 Np->number_p=Np->number+1;  /* first char is space for sign */
+	if (Np->type == FROM_CHAR)
+		Np->number_p = Np->number + 1;	/* first char is space for sign */
 	else if (Np->type == TO_CHAR)
-		Np->number_p=Np->number;
+		Np->number_p = Np->number;
+
+	for (n = node, Np->inout_p = Np->inout; n->type != NODE_TYPE_END; n++)
+	{
 
-	for(n=node, Np->inout_p=Np->inout; n->type != NODE_TYPE_END; n++) {
-		
-		if (Np->type == FROM_CHAR) {
+		if (Np->type == FROM_CHAR)
+		{
 			/* ----------
 			 * Check non-string inout end
 			 * ----------
 			 */
-			if (Np->inout_p >= Np->inout + plen) 
+			if (Np->inout_p >= Np->inout + plen)
 				break;
 		}
-		
+
 		/* ----------
 		 * Format pictures actions
 		 * ----------
 		 */
-		if (n->type == NODE_TYPE_ACTION) {
-			
+		if (n->type == NODE_TYPE_ACTION)
+		{
+
 			/* ----------
-			 * Create/reading digit/zero/blank/sing 
+			 * Create/reading digit/zero/blank/sing
 			 * ----------
 			 */
-			switch( n->key->id ) {
-			
-			case NUM_9:
-			case NUM_0:
-			case NUM_DEC:
-			case NUM_D:
-			case NUM_S:
-			case NUM_PR:
-				if (Np->type == TO_CHAR) {
-					NUM_numpart_to_char(Np, n->key->id);
-					continue;	/* for() */
-				} else {
-					NUM_numpart_from_char(Np, n->key->id, plen);
-					break;		/* switch() case: */
-				}
-			
-			case NUM_COMMA:
-				if (Np->type == TO_CHAR) {
-					if (!Np->num_in) {
-						if (IS_FILLMODE(Np->Num))
-							continue;
+			switch (n->key->id)
+			{
+
+				case NUM_9:
+				case NUM_0:
+				case NUM_DEC:
+				case NUM_D:
+				case NUM_S:
+				case NUM_PR:
+					if (Np->type == TO_CHAR)
+					{
+						NUM_numpart_to_char(Np, n->key->id);
+						continue;		/* for() */
+					}
+					else
+					{
+						NUM_numpart_from_char(Np, n->key->id, plen);
+						break;	/* switch() case: */
+					}
+
+				case NUM_COMMA:
+					if (Np->type == TO_CHAR)
+					{
+						if (!Np->num_in)
+						{
+							if (IS_FILLMODE(Np->Num))
+								continue;
+							else
+								*Np->inout_p = ' ';
+						}
 						else
-							*Np->inout_p= ' ';
-					} else
-						*Np->inout_p = ',';
-				
-				} else if (Np->type == FROM_CHAR) {
-					if (!Np->num_in) {
-						if (IS_FILLMODE(Np->Num))
-							continue;
+							*Np->inout_p = ',';
+
 					}
-				}
-				break;
-				
-			case NUM_G:
-				if (Np->type == TO_CHAR) {
-					if (!Np->num_in) {
-						if (IS_FILLMODE(Np->Num)) 
-							continue;
-						else {
-							int	x = strlen(Np->L_thousands_sep);
-							memset(Np->inout_p,  ' ', x);
-							Np->inout_p += x-1;
+					else if (Np->type == FROM_CHAR)
+					{
+						if (!Np->num_in)
+						{
+							if (IS_FILLMODE(Np->Num))
+								continue;
 						}
-					} else {
-						strcpy(Np->inout_p, Np->L_thousands_sep);
-						Np->inout_p += strlen(Np->inout_p)-1;
 					}
-					
-				} else if (Np->type == FROM_CHAR) {		
-					if (!Np->num_in) {
-						if (IS_FILLMODE(Np->Num)) 
-							continue;
+					break;
+
+				case NUM_G:
+					if (Np->type == TO_CHAR)
+					{
+						if (!Np->num_in)
+						{
+							if (IS_FILLMODE(Np->Num))
+								continue;
+							else
+							{
+								int			x = strlen(Np->L_thousands_sep);
+
+								memset(Np->inout_p, ' ', x);
+								Np->inout_p += x - 1;
+							}
+						}
+						else
+						{
+							strcpy(Np->inout_p, Np->L_thousands_sep);
+							Np->inout_p += strlen(Np->inout_p) - 1;
+						}
+
+					}
+					else if (Np->type == FROM_CHAR)
+					{
+						if (!Np->num_in)
+						{
+							if (IS_FILLMODE(Np->Num))
+								continue;
+						}
+						Np->inout_p += strlen(Np->L_thousands_sep) - 1;
+					}
+					break;
+
+				case NUM_L:
+					if (Np->type == TO_CHAR)
+					{
+						strcpy(Np->inout_p, Np->L_currency_symbol);
+						Np->inout_p += strlen(Np->inout_p) - 1;
+
+					}
+					else if (Np->type == FROM_CHAR)
+						Np->inout_p += strlen(Np->L_currency_symbol) - 1;
+					break;
+
+				case NUM_RN:
+					if (IS_FILLMODE(Np->Num))
+					{
+						strcpy(Np->inout_p, Np->number_p);
+						Np->inout_p += strlen(Np->inout_p) - 1;
 					}
-					Np->inout_p += strlen(Np->L_thousands_sep)-1;
-				}
-				break;	
-				
-			case NUM_L:
-				if (Np->type == TO_CHAR) {
-					strcpy(Np->inout_p, Np->L_currency_symbol);
-					Np->inout_p += strlen(Np->inout_p)-1;
-				
-				} else if (Np->type == FROM_CHAR) {
-					Np->inout_p += strlen(Np->L_currency_symbol)-1;
-				}
-				break;		
-				
-			case NUM_RN:
-				if (IS_FILLMODE(Np->Num)) {
-					strcpy(Np->inout_p, Np->number_p);	
-					Np->inout_p += strlen(Np->inout_p) - 1;
-				} else 
-					Np->inout_p += sprintf(Np->inout_p, "%15s", Np->number_p) -1;
-				break;	
-				
-			case NUM_rn:
-				if (IS_FILLMODE(Np->Num)) {
-					strcpy(Np->inout_p, str_tolower(Np->number_p));	
-					Np->inout_p += strlen(Np->inout_p) - 1;
-				} else 
-					Np->inout_p += sprintf(Np->inout_p, "%15s", str_tolower(Np->number_p)) -1;
-				break;		
-				
-			case NUM_th:
-				if (IS_ROMAN(Np->Num) || *Np->number=='#' || 
-				    Np->sign=='-' || IS_DECIMAL(Np->Num))
-						continue; 
-					
-				if (Np->type == TO_CHAR)
-					strcpy(Np->inout_p, get_th(Np->number, TH_LOWER));
-				Np->inout_p += 1;
-				break;
-				
-			case NUM_TH:
-				if (IS_ROMAN(Np->Num) || *Np->number=='#' || 
-				    Np->sign=='-' || IS_DECIMAL(Np->Num))
-					continue;			
-					
-				if (Np->type == TO_CHAR)	
-					strcpy(Np->inout_p, get_th(Np->number, TH_UPPER));
-				Np->inout_p += 1;
-				break;	
-			
-			case NUM_MI:
-				if (Np->type == TO_CHAR) {
-					if (Np->sign=='-')
-						*Np->inout_p = '-';
-					else	
-						*Np->inout_p = ' ';
-						
-				} else if (Np->type == FROM_CHAR) {
-					if (*Np->inout_p == '-')
-						*Np->number = '-';
-				}
-				break;
-				
-			case NUM_PL:
-				if (Np->type == TO_CHAR) {
-					if (Np->sign=='+')
-						*Np->inout_p = '+';
 					else
-						*Np->inout_p = ' ';
-						
-				}  else if (Np->type == FROM_CHAR) {
-					if (*Np->inout_p == '+')
-						*Np->number = '+';
-				}
-				break;	
-				
-			case NUM_SG:
-				if (Np->type == TO_CHAR) 
-					*Np->inout_p = Np->sign;
-				
-				else if (Np->type == FROM_CHAR) {
-					if (*Np->inout_p == '-')
-						*Np->number = '-';
-					else if (*Np->inout_p == '+')
-						*Np->number = '+';	
-				}
-				break;	
-			
-			
-			default:
-				continue;
-				break;
+						Np->inout_p += sprintf(Np->inout_p, "%15s", Np->number_p) - 1;
+					break;
+
+				case NUM_rn:
+					if (IS_FILLMODE(Np->Num))
+					{
+						strcpy(Np->inout_p, str_tolower(Np->number_p));
+						Np->inout_p += strlen(Np->inout_p) - 1;
+					}
+					else
+						Np->inout_p += sprintf(Np->inout_p, "%15s", str_tolower(Np->number_p)) - 1;
+					break;
+
+				case NUM_th:
+					if (IS_ROMAN(Np->Num) || *Np->number == '#' ||
+						Np->sign == '-' || IS_DECIMAL(Np->Num))
+						continue;
+
+					if (Np->type == TO_CHAR)
+						strcpy(Np->inout_p, get_th(Np->number, TH_LOWER));
+					Np->inout_p += 1;
+					break;
+
+				case NUM_TH:
+					if (IS_ROMAN(Np->Num) || *Np->number == '#' ||
+						Np->sign == '-' || IS_DECIMAL(Np->Num))
+						continue;
+
+					if (Np->type == TO_CHAR)
+						strcpy(Np->inout_p, get_th(Np->number, TH_UPPER));
+					Np->inout_p += 1;
+					break;
+
+				case NUM_MI:
+					if (Np->type == TO_CHAR)
+					{
+						if (Np->sign == '-')
+							*Np->inout_p = '-';
+						else
+							*Np->inout_p = ' ';
+
+					}
+					else if (Np->type == FROM_CHAR)
+					{
+						if (*Np->inout_p == '-')
+							*Np->number = '-';
+					}
+					break;
+
+				case NUM_PL:
+					if (Np->type == TO_CHAR)
+					{
+						if (Np->sign == '+')
+							*Np->inout_p = '+';
+						else
+							*Np->inout_p = ' ';
+
+					}
+					else if (Np->type == FROM_CHAR)
+					{
+						if (*Np->inout_p == '+')
+							*Np->number = '+';
+					}
+					break;
+
+				case NUM_SG:
+					if (Np->type == TO_CHAR)
+						*Np->inout_p = Np->sign;
+
+					else if (Np->type == FROM_CHAR)
+					{
+						if (*Np->inout_p == '-')
+							*Np->number = '-';
+						else if (*Np->inout_p == '+')
+							*Np->number = '+';
+					}
+					break;
+
+
+				default:
+					continue;
+					break;
 			}
 
-		} else {
+		}
+		else
+		{
 			/* ----------
 			 * Remove to output char from input in TO_CHAR
 			 * ----------
@@ -3444,34 +3806,38 @@ NUM_processor (FormatNode *node, NUMDesc *Num, char *inout, char *number,
 			if (Np->type == TO_CHAR)
 				*Np->inout_p = n->character;
 		}
-		Np->inout_p++;	
+		Np->inout_p++;
 	}
-	
-	if (Np->type == TO_CHAR) {
+
+	if (Np->type == TO_CHAR)
+	{
 		*Np->inout_p = '\0';
-		return Np->inout;	
-	
-	} else if (Np->type == FROM_CHAR) {
-		
-		if (*(Np->number_p-1) == '.')
-			*(Np->number_p-1) = '\0';
+		return Np->inout;
+
+	}
+	else if (Np->type == FROM_CHAR)
+	{
+
+		if (*(Np->number_p - 1) == '.')
+			*(Np->number_p - 1) = '\0';
 		else
 			*Np->number_p = '\0';
-			
+
 		/* ----------
 		 * Correction - precision of dec. number
 		 * ----------
 		 */
-		 Np->Num->post = Np->read_post;
+		Np->Num->post = Np->read_post;
 
 #ifdef DEBUG_TO_FROM_CHAR
-	        elog(DEBUG_elog_output, "TO_NUMBER (number): '%s'", Np->number);
+		elog(DEBUG_elog_output, "TO_NUMBER (number): '%s'", Np->number);
 #endif
 		return Np->number;
-	} else
-		return NULL;	
-	
-	return NULL;	
+	}
+	else
+		return NULL;
+
+	return NULL;
 }
 
 /* ----------
@@ -3483,13 +3849,13 @@ NUM_processor (FormatNode *node, NUMDesc *Num, char *inout, char *number,
 	if (!PointerIsValid(fmt))					\
 		return NULL;						\
 									\
-	len = VARSIZE(fmt) - VARHDRSZ; 					\
+	len = VARSIZE(fmt) - VARHDRSZ;					\
 									\
-	if (!len) 							\
+	if (!len)							\
 		return textin("");					\
 									\
 	result	= (text *) palloc( (len * NUM_MAX_ITEM_SIZ) + 1 + VARHDRSZ);	\
-	format  = NUM_cache(len, &Num, VARDATA(fmt), &flag);		\
+	format	= NUM_cache(len, &Num, VARDATA(fmt), &flag);		\
 }
 
 /* ----------
@@ -3498,65 +3864,66 @@ NUM_processor (FormatNode *node, NUMDesc *Num, char *inout, char *number,
  */
 #define NUM_TOCHAR_finish {						\
 									\
-	NUM_processor(format, &Num, VARDATA(result), 			\
+	NUM_processor(format, &Num, VARDATA(result),			\
 		numstr, plen, sign, TO_CHAR);				\
 	pfree(orgnum);							\
 									\
 	if (flag)							\
 		pfree(format);						\
 									\
-	/* ----------							\
+	/* ----------						\
 	 * for result is allocated max memory, which current format-picture\
 	 * needs, now it must be re-allocate to result real size	\
 	 * ----------							\
 	 */								\
-	len 		= strlen(VARDATA(result));			\
-	result_tmp 	= result;					\
-	result 		= (text *) palloc( len + 1 + VARHDRSZ);		\
+	len			= strlen(VARDATA(result));			\
+	result_tmp	= result;					\
+	result		= (text *) palloc( len + 1 + VARHDRSZ);		\
 									\
-	strcpy( VARDATA(result), VARDATA(result_tmp));  		\
-	VARSIZE(result) = len + VARHDRSZ; 				\
+	strcpy( VARDATA(result), VARDATA(result_tmp));			\
+	VARSIZE(result) = len + VARHDRSZ;				\
 	pfree(result_tmp);						\
 }
 
 /* -------------------
- * NUMERIC to_number() (convert string to numeric) 
+ * NUMERIC to_number() (convert string to numeric)
  * -------------------
  */
-Numeric 
+Numeric
 numeric_to_number(text *value, text *fmt)
 {
-	NUMDesc			Num;
-	Numeric			result;
-	FormatNode		*format;
-	char 			*numstr;
-	int			flag=0;
-	int			len=0;
-	
-	int			scale, precision;
-	
+	NUMDesc		Num;
+	Numeric		result;
+	FormatNode *format;
+	char	   *numstr;
+	int			flag = 0;
+	int			len = 0;
+
+	int			scale,
+				precision;
+
 	if ((!PointerIsValid(value)) || (!PointerIsValid(fmt)))
-		return NULL;									
+		return NULL;
+
+	len = VARSIZE(fmt) - VARHDRSZ;
+
+	if (!len)
+		return numeric_in(NULL, 0, 0);
 
-	len = VARSIZE(fmt) - VARHDRSZ; 					
-									
-	if (!len) 							
-		return numeric_in(NULL, 0, 0);					
-									
 	format = NUM_cache(len, &Num, VARDATA(fmt), &flag);
-	
-	numstr	= (char *) palloc( (len * NUM_MAX_ITEM_SIZ) + 1);	
-	
-	NUM_processor(format, &Num, VARDATA(value), numstr, 
-			VARSIZE(value) - VARHDRSZ, 0, FROM_CHAR);
-	
+
+	numstr = (char *) palloc((len * NUM_MAX_ITEM_SIZ) + 1);
+
+	NUM_processor(format, &Num, VARDATA(value), numstr,
+				  VARSIZE(value) - VARHDRSZ, 0, FROM_CHAR);
+
 	scale = Num.post;
 	precision = MAX(0, Num.pre) + scale;
 
 	if (flag)
 		pfree(format);
-	
-	result = numeric_in(numstr, 0, ((precision << 16) | scale) + VARHDRSZ);						
+
+	result = numeric_in(numstr, 0, ((precision << 16) | scale) + VARHDRSZ);
 	pfree(numstr);
 	return result;
 }
@@ -3564,17 +3931,22 @@ numeric_to_number(text *value, text *fmt)
 /* ------------------
  * NUMERIC to_char()
  * ------------------
- */	
+ */
 text *
 numeric_to_char(Numeric value, text *fmt)
 {
-	NUMDesc			Num;
-	FormatNode		*format;
-	text 			*result, *result_tmp;
-	int			flag=0;
-	int			len=0, plen=0, sign=0;
-	char			*numstr, *orgnum, *p;
-	Numeric 		x 	= NULL;
+	NUMDesc		Num;
+	FormatNode *format;
+	text	   *result,
+			   *result_tmp;
+	int			flag = 0;
+	int			len = 0,
+				plen = 0,
+				sign = 0;
+	char	   *numstr,
+			   *orgnum,
+			   *p;
+	Numeric		x = NULL;
 
 	NUM_TOCHAR_prepare;
 
@@ -3582,54 +3954,62 @@ numeric_to_char(Numeric value, text *fmt)
 	 * On DateType depend part (numeric)
 	 * ----------
 	 */
-	if (IS_ROMAN(&Num)) {
+	if (IS_ROMAN(&Num))
+	{
 		x = numeric_round(value, 0);
-	 	numstr = orgnum = int_to_roman( numeric_int4( x ));
-	 	pfree(x);
-	 	
-	} else { 
-		Numeric val 	= value;
-	
-		if (IS_MULTI(&Num)) {
-			Numeric a = int4_numeric(10);
-			Numeric b = int4_numeric(Num.multi);
-			
+		numstr = orgnum = int_to_roman(numeric_int4(x));
+		pfree(x);
+
+	}
+	else
+	{
+		Numeric		val = value;
+
+		if (IS_MULTI(&Num))
+		{
+			Numeric		a = int4_numeric(10);
+			Numeric		b = int4_numeric(Num.multi);
+
 			x = numeric_power(a, b);
-			val = numeric_mul(value, x); 
+			val = numeric_mul(value, x);
 			pfree(x);
 			pfree(a);
 			pfree(b);
 			Num.pre += Num.multi;
 		}
-		
+
 		x = numeric_round(val, Num.post);
-		orgnum = numeric_out( x );
+		orgnum = numeric_out(x);
 		pfree(x);
-		
-		if (*orgnum == '-') { 					/* < 0 */
+
+		if (*orgnum == '-')
+		{						/* < 0 */
 			sign = '-';
-			numstr = orgnum+1; 
-		} else {
+			numstr = orgnum + 1;
+		}
+		else
+		{
 			sign = '+';
 			numstr = orgnum;
 		}
 		if ((p = strchr(numstr, '.')))
-			len = p - numstr; 
+			len = p - numstr;
 		else
 			len = strlen(numstr);
-		
-		if (Num.pre > len) 
+
+		if (Num.pre > len)
 			plen = Num.pre - len;
-			
-		else if (len > Num.pre) {
+
+		else if (len > Num.pre)
+		{
 			fill_str(numstr, '#', Num.pre);
 			*(numstr + Num.pre) = '.';
 			fill_str(numstr + 1 + Num.pre, '#', Num.post);
 		}
-		
+
 		if (IS_MULTI(&Num))
-			pfree(val); 
-	}	
+			pfree(val);
+	}
 
 	NUM_TOCHAR_finish;
 	return result;
@@ -3638,16 +4018,20 @@ numeric_to_char(Numeric value, text *fmt)
 /* ---------------
  * INT4 to_char()
  * ---------------
- */	
+ */
 text *
 int4_to_char(int32 value, text *fmt)
 {
-	NUMDesc			Num;
-	FormatNode		*format;
-	text 			*result, *result_tmp;
-	int			flag=0;
-	int			len=0, plen=0, sign=0;
-	char			*numstr, *orgnum;
+	NUMDesc		Num;
+	FormatNode *format;
+	text	   *result,
+			   *result_tmp;
+	int			flag = 0;
+	int			len = 0,
+				plen = 0,
+				sign = 0;
+	char	   *numstr,
+			   *orgnum;
 
 	NUM_TOCHAR_prepare;
 
@@ -3655,41 +4039,51 @@ int4_to_char(int32 value, text *fmt)
 	 * On DateType depend part (int32)
 	 * ----------
 	 */
-	 if (IS_ROMAN(&Num)) {
-	 	numstr = orgnum = int_to_roman( value );
-	 	
-	 } else {
-		if (IS_MULTI(&Num)) {
-			orgnum = int4out(int4mul(value, (int32) pow( (double)10, (double) Num.multi)));
+	if (IS_ROMAN(&Num))
+	{
+		numstr = orgnum = int_to_roman(value);
+
+	}
+	else
+	{
+		if (IS_MULTI(&Num))
+		{
+			orgnum = int4out(int4mul(value, (int32) pow((double) 10, (double) Num.multi)));
 			Num.pre += Num.multi;
-		} else
+		}
+		else
 			orgnum = int4out(value);
-		len    = strlen(orgnum);
-	
-		if (*orgnum == '-') {  					/* < 0 */
+		len = strlen(orgnum);
+
+		if (*orgnum == '-')
+		{						/* < 0 */
 			sign = '-';
-			--len; 	
-		} else
+			--len;
+		}
+		else
 			sign = '+';
-		
-		if (Num.post) {
-			int	i;
-			
-			numstr = palloc( len + 1 + Num.post ); 
+
+		if (Num.post)
+		{
+			int			i;
+
+			numstr = palloc(len + 1 + Num.post);
 			strcpy(numstr, orgnum + (*orgnum == '-' ? 1 : 0));
-			*(numstr + len) = '.';	
-			
-			for(i=len+1; i<=Num.post+len+1; i++)
-				*(numstr+i) = '0';
-			*(numstr + Num.post + len + 1)  = '\0';
+			*(numstr + len) = '.';
+
+			for (i = len + 1; i <= Num.post + len + 1; i++)
+				*(numstr + i) = '0';
+			*(numstr + Num.post + len + 1) = '\0';
 			pfree(orgnum);
-			orgnum = numstr;  	 
-		} else
+			orgnum = numstr;
+		}
+		else
 			numstr = orgnum + (*orgnum == '-' ? 1 : 0);
-	
-		if (Num.pre > len) 
-			plen = Num.pre - len;		
-		else if (len > Num.pre) {
+
+		if (Num.pre > len)
+			plen = Num.pre - len;
+		else if (len > Num.pre)
+		{
 			fill_str(numstr, '#', Num.pre);
 			*(numstr + Num.pre) = '.';
 			fill_str(numstr + 1 + Num.pre, '#', Num.post);
@@ -3703,16 +4097,20 @@ int4_to_char(int32 value, text *fmt)
 /* ---------------
  * INT8 to_char()
  * ---------------
- */	
+ */
 text *
 int8_to_char(int64 *value, text *fmt)
 {
-	NUMDesc			Num;
-	FormatNode		*format;
-	text 			*result, *result_tmp;
-	int			flag=0;
-	int			len=0, plen=0, sign=0;
-	char			*numstr, *orgnum;
+	NUMDesc		Num;
+	FormatNode *format;
+	text	   *result,
+			   *result_tmp;
+	int			flag = 0;
+	int			len = 0,
+				plen = 0,
+				sign = 0;
+	char	   *numstr,
+			   *orgnum;
 
 	NUM_TOCHAR_prepare;
 
@@ -3720,48 +4118,59 @@ int8_to_char(int64 *value, text *fmt)
 	 * On DateType depend part (int32)
 	 * ----------
 	 */
-	if (IS_ROMAN(&Num)) {
-	 	numstr = orgnum = int_to_roman( int84( value ));
-	 	
-	} else { 
-		if (IS_MULTI(&Num)) {
-			double multi = pow( (double)10, (double) Num.multi);
-			orgnum = int8out( int8mul(value, dtoi8( (float64) &multi )));
+	if (IS_ROMAN(&Num))
+	{
+		numstr = orgnum = int_to_roman(int84(value));
+
+	}
+	else
+	{
+		if (IS_MULTI(&Num))
+		{
+			double		multi = pow((double) 10, (double) Num.multi);
+
+			orgnum = int8out(int8mul(value, dtoi8((float64) &multi)));
 			Num.pre += Num.multi;
-		} else
+		}
+		else
 			orgnum = int8out(value);
-		len    = strlen(orgnum);
-		
-		if (*orgnum == '-') {  					/* < 0 */
+		len = strlen(orgnum);
+
+		if (*orgnum == '-')
+		{						/* < 0 */
 			sign = '-';
-			--len; 	
-		} else
+			--len;
+		}
+		else
 			sign = '+';
-		
-		if (Num.post) {
-			int	i;
-			
-			numstr = palloc( len + 1 + Num.post ); 
+
+		if (Num.post)
+		{
+			int			i;
+
+			numstr = palloc(len + 1 + Num.post);
 			strcpy(numstr, orgnum + (*orgnum == '-' ? 1 : 0));
-			*(numstr + len) = '.';	
-			
-			for(i=len+1; i<=Num.post+len+1; i++)
-				*(numstr+i) = '0';
-			*(numstr + Num.post + len + 1)  = '\0';
+			*(numstr + len) = '.';
+
+			for (i = len + 1; i <= Num.post + len + 1; i++)
+				*(numstr + i) = '0';
+			*(numstr + Num.post + len + 1) = '\0';
 			pfree(orgnum);
-			orgnum = numstr;  	 
-		} else 
+			orgnum = numstr;
+		}
+		else
 			numstr = orgnum + (*orgnum == '-' ? 1 : 0);
-	
-		if (Num.pre > len) 
-			plen = Num.pre - len;		
-		else if (len > Num.pre) {
+
+		if (Num.pre > len)
+			plen = Num.pre - len;
+		else if (len > Num.pre)
+		{
 			fill_str(numstr, '#', Num.pre);
 			*(numstr + Num.pre) = '.';
 			fill_str(numstr + 1 + Num.pre, '#', Num.post);
-		}	
+		}
 	}
-	
+
 	NUM_TOCHAR_finish;
 	return result;
 }
@@ -3769,63 +4178,77 @@ int8_to_char(int64 *value, text *fmt)
 /* -----------------
  * FLOAT4 to_char()
  * -----------------
- */	
+ */
 text *
 float4_to_char(float32 value, text *fmt)
 {
-	NUMDesc			Num;
-	FormatNode		*format;
-	text 			*result, *result_tmp;
-	int			flag=0;
-	int			len=0, plen=0, sign=0;
-	char			*numstr, *orgnum, *p;
+	NUMDesc		Num;
+	FormatNode *format;
+	text	   *result,
+			   *result_tmp;
+	int			flag = 0;
+	int			len = 0,
+				plen = 0,
+				sign = 0;
+	char	   *numstr,
+			   *orgnum,
+			   *p;
 
 	NUM_TOCHAR_prepare;
 
-	if (IS_ROMAN(&Num)) {
-	 	numstr = orgnum = int_to_roman( (int) rint( *value ));
-	 	
-	} else {
-		float32	val = value;
-	
-		if (IS_MULTI(&Num)) {
-			float multi = pow( (double) 10, (double) Num.multi);
+	if (IS_ROMAN(&Num))
+	{
+		numstr = orgnum = int_to_roman((int) rint(*value));
+
+	}
+	else
+	{
+		float32		val = value;
+
+		if (IS_MULTI(&Num))
+		{
+			float		multi = pow((double) 10, (double) Num.multi);
+
 			val = float4mul(value, (float32) &multi);
 			Num.pre += Num.multi;
-		} 
-		
+		}
+
 		orgnum = (char *) palloc(MAXFLOATWIDTH + 1);
-		len = sprintf(orgnum, "%.0f",  fabs(*val));
+		len = sprintf(orgnum, "%.0f", fabs(*val));
 		if (Num.pre > len)
 			plen = Num.pre - len;
 		if (len >= FLT_DIG)
-		        Num.post = 0;
+			Num.post = 0;
 		else if (Num.post + len > FLT_DIG)
-		        Num.post = FLT_DIG - len;
+			Num.post = FLT_DIG - len;
 		sprintf(orgnum, "%.*f", Num.post, *val);
-		
-		if (*orgnum == '-') { 					/* < 0 */
+
+		if (*orgnum == '-')
+		{						/* < 0 */
 			sign = '-';
-			numstr = orgnum+1; 
-		} else {
+			numstr = orgnum + 1;
+		}
+		else
+		{
 			sign = '+';
 			numstr = orgnum;
 		}
 		if ((p = strchr(numstr, '.')))
-			len = p - numstr; 
-		else	
+			len = p - numstr;
+		else
 			len = strlen(numstr);
-			
-		if (Num.pre > len) 
+
+		if (Num.pre > len)
 			plen = Num.pre - len;
-			
-		else if (len > Num.pre) {
+
+		else if (len > Num.pre)
+		{
 			fill_str(numstr, '#', Num.pre);
 			*(numstr + Num.pre) = '.';
 			fill_str(numstr + 1 + Num.pre, '#', Num.post);
-		} 
+		}
 	}
-	
+
 	NUM_TOCHAR_finish;
 	return result;
 }
@@ -3833,62 +4256,76 @@ float4_to_char(float32 value, text *fmt)
 /* -----------------
  * FLOAT8 to_char()
  * -----------------
- */	
+ */
 text *
 float8_to_char(float64 value, text *fmt)
 {
-	NUMDesc			Num;
-	FormatNode		*format;
-	text 			*result, *result_tmp;
-	int			flag=0;
-	int			len=0, plen=0, sign=0;
-	char			*numstr, *orgnum, *p;
+	NUMDesc		Num;
+	FormatNode *format;
+	text	   *result,
+			   *result_tmp;
+	int			flag = 0;
+	int			len = 0,
+				plen = 0,
+				sign = 0;
+	char	   *numstr,
+			   *orgnum,
+			   *p;
 
 	NUM_TOCHAR_prepare;
 
-	if (IS_ROMAN(&Num)) {
-	 	numstr = orgnum = int_to_roman( (int) rint( *value ));
-	 	
-	} else {
-		float64	val = value;
-	
-		if (IS_MULTI(&Num)) {
-			double multi = pow( (double) 10, (double) Num.multi);
+	if (IS_ROMAN(&Num))
+	{
+		numstr = orgnum = int_to_roman((int) rint(*value));
+
+	}
+	else
+	{
+		float64		val = value;
+
+		if (IS_MULTI(&Num))
+		{
+			double		multi = pow((double) 10, (double) Num.multi);
+
 			val = float8mul(value, (float64) &multi);
 			Num.pre += Num.multi;
-		} 
+		}
 		orgnum = (char *) palloc(MAXDOUBLEWIDTH + 1);
-		len = sprintf(orgnum, "%.0f",  fabs(*val));
+		len = sprintf(orgnum, "%.0f", fabs(*val));
 		if (Num.pre > len)
 			plen = Num.pre - len;
 		if (len >= DBL_DIG)
-		        Num.post = 0;
+			Num.post = 0;
 		else if (Num.post + len > DBL_DIG)
-		        Num.post = DBL_DIG - len;
+			Num.post = DBL_DIG - len;
 		sprintf(orgnum, "%.*f", Num.post, *val);
-	
-		if (*orgnum == '-') { 					/* < 0 */
+
+		if (*orgnum == '-')
+		{						/* < 0 */
 			sign = '-';
-			numstr = orgnum+1; 
-		} else {
+			numstr = orgnum + 1;
+		}
+		else
+		{
 			sign = '+';
 			numstr = orgnum;
 		}
 		if ((p = strchr(numstr, '.')))
-			len = p - numstr; 
+			len = p - numstr;
 		else
 			len = strlen(numstr);
-			
-		if (Num.pre > len) 
+
+		if (Num.pre > len)
 			plen = Num.pre - len;
-			
-		else if (len > Num.pre) {
+
+		else if (len > Num.pre)
+		{
 			fill_str(numstr, '#', Num.pre);
 			*(numstr + Num.pre) = '.';
 			fill_str(numstr + 1 + Num.pre, '#', Num.post);
-		} 
+		}
 	}
-	
+
 	NUM_TOCHAR_finish;
 	return result;
 }
diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c
index 9561f9e875de42feb96ce9315f7b8f9b7dfec9d4..0e8bb4405b2bb7fee7cf6bd1df0db08eb2c5384a 100644
--- a/src/backend/utils/adt/geo_ops.c
+++ b/src/backend/utils/adt/geo_ops.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.49 2000/03/14 23:06:36 thomas Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.50 2000/04/12 17:15:50 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -877,7 +877,7 @@ line_construct_pm(Point *pt, double m)
 	/* use "mx - y + yinter = 0" */
 	result->A = m;
 	result->B = -1.0;
-	if (m==DBL_MAX) 
+	if (m == DBL_MAX)
 		result->C = pt->y;
 	else
 		result->C = pt->y - m * pt->x;
diff --git a/src/backend/utils/adt/geo_selfuncs.c b/src/backend/utils/adt/geo_selfuncs.c
index 95e594ea0ef90fa1d1f1df5df2402f8d363a6cc0..b2a281f638d8d3723008fc13adf051bd3ac0bca4 100644
--- a/src/backend/utils/adt/geo_selfuncs.c
+++ b/src/backend/utils/adt/geo_selfuncs.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_selfuncs.c,v 1.13 2000/02/17 03:39:42 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_selfuncs.c,v 1.14 2000/04/12 17:15:50 momjian Exp $
  *
  *	XXX These are totally bogus.  Perhaps someone will make them do
  *	something reasonable, someday.
@@ -34,7 +34,7 @@
  *	In general, rtrees need to search multiple subtrees in order to guarantee
  *	that all occurrences of the same key have been found.  Because of this,
  *	the estimated cost for scanning the index ought to be higher than the
- *	output selectivity would indicate.  rtcostestimate(), over in selfuncs.c,
+ *	output selectivity would indicate.	rtcostestimate(), over in selfuncs.c,
  *	ought to be adjusted accordingly --- but until we can generate somewhat
  *	realistic numbers here, it hardly matters...
  */
diff --git a/src/backend/utils/adt/int.c b/src/backend/utils/adt/int.c
index 7eb7783274c59ecdc4f760b97b82b9bff7289703..242e9c540116998c0cd70fac076ce9c7fbf9c5bd 100644
--- a/src/backend/utils/adt/int.c
+++ b/src/backend/utils/adt/int.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.35 2000/03/14 23:06:36 thomas Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.36 2000/04/12 17:15:50 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -88,7 +88,7 @@ int2vectorin(char *intString)
 
 	result = (int16 *) palloc(sizeof(int16[INDEX_MAX_KEYS]));
 
-	for (slot=0; *intString && slot < INDEX_MAX_KEYS; slot++)
+	for (slot = 0; *intString && slot < INDEX_MAX_KEYS; slot++)
 	{
 		if (sscanf(intString, "%hd", &result[slot]) != 1)
 			break;
@@ -100,7 +100,7 @@ int2vectorin(char *intString)
 	while (*intString && isspace(*intString))
 		intString++;
 	if (*intString)
-		elog(ERROR,"int2vector value has too many values");
+		elog(ERROR, "int2vector value has too many values");
 	while (slot < INDEX_MAX_KEYS)
 		result[slot++] = 0;
 
@@ -113,7 +113,8 @@ int2vectorin(char *intString)
 char *
 int2vectorout(int16 *int2Array)
 {
-	int			num, maxnum;
+	int			num,
+				maxnum;
 	char	   *rp;
 	char	   *result;
 
@@ -126,12 +127,12 @@ int2vectorout(int16 *int2Array)
 	}
 
 	/* find last non-zero value in vector */
-	for (maxnum = INDEX_MAX_KEYS-1; maxnum >= 0; maxnum--)
+	for (maxnum = INDEX_MAX_KEYS - 1; maxnum >= 0; maxnum--)
 		if (int2Array[maxnum] != 0)
 			break;
 
 	/* assumes sign, 5 digits, ' ' */
-	rp = result = (char *) palloc((maxnum+1) * 7 + 1);
+	rp = result = (char *) palloc((maxnum + 1) * 7 + 1);
 	for (num = 0; num <= maxnum; num++)
 	{
 		if (num != 0)
@@ -694,13 +695,13 @@ int2fac(int16 arg1)
 int32
 int4abs(int32 arg1)
 {
-	return ((arg1 < 0)? -arg1: arg1);
+	return ((arg1 < 0) ? -arg1 : arg1);
 }
 
 int16
 int2abs(int16 arg1)
 {
-	return ((arg1 < 0)? -arg1: arg1);
+	return ((arg1 < 0) ? -arg1 : arg1);
 }
 
 int16
diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c
index 27b0f42c97f4838a2b402782c438bf7561c468fd..018352df1ad7b8dd53aa31aedb782fac9e28b080 100644
--- a/src/backend/utils/adt/int8.c
+++ b/src/backend/utils/adt/int8.c
@@ -71,10 +71,10 @@ int8in(char *str)
 		elog(ERROR, "Bad int8 external representation \"%s\"", str);
 	while (*ptr && isdigit(*ptr))		/* process digits */
 	{
-		int64	newtmp = tmp * 10 + (*ptr++ - '0');
+		int64		newtmp = tmp * 10 + (*ptr++ - '0');
 
 		if ((newtmp / 10) != tmp)		/* overflow? */
-			elog(ERROR,"int8 value out of range: \"%s\"", str);
+			elog(ERROR, "int8 value out of range: \"%s\"", str);
 		tmp = newtmp;
 	}
 	if (*ptr)					/* trailing junk? */
@@ -372,7 +372,7 @@ int8abs(int64 *arg1)
 
 	result = palloc(sizeof(*result));
 
-	*result = ((*arg1 < 0)? -*arg1: *arg1);
+	*result = ((*arg1 < 0) ? -*arg1 : *arg1);
 
 	return result;
 }
@@ -400,7 +400,7 @@ int64 *
 int8fac(int64 *arg1)
 {
 	int64	   *result;
-	int64	   i;
+	int64		i;
 
 	if (!PointerIsValid(arg1))
 		return NULL;
@@ -581,7 +581,7 @@ int84(int64 *val)
 
 #if NOT_USED
 int64 *
-int2vector		(int16 val)
+int2vector	(int16 val)
 {
 	int64	   *result;
 
diff --git a/src/backend/utils/adt/like.c b/src/backend/utils/adt/like.c
index 2522a7471b440ea466d4f0e81bebb9eb54fbd5b8..3ec148bacb4166ba28695fdd7122822b68ee61cd 100644
--- a/src/backend/utils/adt/like.c
+++ b/src/backend/utils/adt/like.c
@@ -11,7 +11,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	$Header: /cvsroot/pgsql/src/backend/utils/adt/like.c,v 1.33 2000/01/26 05:57:14 momjian Exp $
+ *	$Header: /cvsroot/pgsql/src/backend/utils/adt/like.c,v 1.34 2000/04/12 17:15:50 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -149,7 +149,7 @@ textnlike(struct varlena * s, struct varlena * p)
 static int
 DoMatch(pg_wchar * text, pg_wchar * p)
 {
-	for (; *p && *text; text++, p++)
+	for (; *p && *text; text ++, p++)
 	{
 		switch (*p)
 		{
@@ -158,7 +158,7 @@ DoMatch(pg_wchar * text, pg_wchar * p)
 				p++;
 				/* FALLTHROUGH */
 			default:
-				if (*text != *p)
+				if (*text !=*p)
 					return LIKE_FALSE;
 				break;
 			case '_':
@@ -172,29 +172,37 @@ DoMatch(pg_wchar * text, pg_wchar * p)
 				/* Trailing percent matches everything. */
 				if (*p == '\0')
 					return LIKE_TRUE;
-				/* Otherwise, scan for a text position at which we
-				 * can match the rest of the pattern.
+
+				/*
+				 * Otherwise, scan for a text position at which we can
+				 * match the rest of the pattern.
 				 */
-				for (; *text; text++)
+				for (; *text; text ++)
 				{
-					/* Optimization to prevent most recursion: don't recurse
-					 * unless first pattern char might match this text char.
+
+					/*
+					 * Optimization to prevent most recursion: don't
+					 * recurse unless first pattern char might match this
+					 * text char.
 					 */
 					if (*text == *p || *p == '\\' || *p == '_')
 					{
-						int	matched = DoMatch(text, p);
+						int			matched = DoMatch(text, p);
+
 						if (matched != LIKE_FALSE)
-							return matched;	/* TRUE or ABORT */
+							return matched;		/* TRUE or ABORT */
 					}
 				}
-				/* End of text with no match, so no point in trying later
+
+				/*
+				 * End of text with no match, so no point in trying later
 				 * places to start matching this pattern.
 				 */
 				return LIKE_ABORT;
 		}
 	}
 
-	if (*text != '\0')
+	if (*text !='\0')
 		return LIKE_FALSE;		/* end of pattern, but not of text */
 
 	/* End of input string.  Do we have matching pattern remaining? */
@@ -202,8 +210,10 @@ DoMatch(pg_wchar * text, pg_wchar * p)
 		p++;
 	if (*p == '\0')
 		return LIKE_TRUE;
-	/* End of text with no match, so no point in trying later
-	 * places to start matching this pattern.
+
+	/*
+	 * End of text with no match, so no point in trying later places to
+	 * start matching this pattern.
 	 */
 	return LIKE_ABORT;
 }
diff --git a/src/backend/utils/adt/lztext.c b/src/backend/utils/adt/lztext.c
index 4cc6667e30558967210f439c0ee85749ad99d227..a5d72ba9f264c934e2215dc3c0ee15fd6d603741 100644
--- a/src/backend/utils/adt/lztext.c
+++ b/src/backend/utils/adt/lztext.c
@@ -1,7 +1,7 @@
 /* ----------
  * lztext.c -
  *
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/lztext.c,v 1.5 1999/12/28 13:40:48 wieck Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/lztext.c,v 1.6 2000/04/12 17:15:50 momjian Exp $
  *
  *	Text type with internal LZ compressed representation. Uses the
  *	standard PostgreSQL compression method.
@@ -34,10 +34,10 @@
 lztext *
 lztextin(char *str)
 {
-	lztext		   *result;
-	int32			rawsize;
-	lztext		   *tmp;
-	int				tmp_size;
+	lztext	   *result;
+	int32		rawsize;
+	lztext	   *tmp;
+	int			tmp_size;
 
 	/* ----------
 	 * Handle NULL
@@ -66,11 +66,11 @@ lztextin(char *str)
 	 * sequence.
 	 * ----------
 	 */
-	if (tmp_size - tmp->varsize < 256 || 
-					tmp_size - tmp->varsize < tmp_size / 4)
-	{
+	if (tmp_size - tmp->varsize < 256 ||
+		tmp_size - tmp->varsize < tmp_size / 4)
 		result = tmp;
-	} else {
+	else
+	{
 		result = (lztext *) palloc(tmp->varsize);
 		memcpy(result, tmp, tmp->varsize);
 		pfree(tmp);
@@ -89,7 +89,7 @@ lztextin(char *str)
 char *
 lztextout(lztext *lz)
 {
-	char			*result;
+	char	   *result;
 
 	/* ----------
 	 * Handle NULL
@@ -137,10 +137,12 @@ int32
 lztextlen(lztext *lz)
 {
 #ifdef MULTIBYTE
-	unsigned char	*s1,*s2;
-	int	len;
-	int	l;
-	int	wl;
+	unsigned char *s1,
+			   *s2;
+	int			len;
+	int			l;
+	int			wl;
+
 #endif
 	/* ----------
 	 * Handle NULL
@@ -151,7 +153,7 @@ lztextlen(lztext *lz)
 
 #ifdef MULTIBYTE
 	len = 0;
-	s1 = s2 = (unsigned char *)lztextout(lz);
+	s1 = s2 = (unsigned char *) lztextout(lz);
 	l = PGLZ_RAW_SIZE(lz);
 	while (l > 0)
 	{
@@ -160,7 +162,7 @@ lztextlen(lztext *lz)
 		s1 += wl;
 		len++;
 	}
-	pfree((char *)s2);
+	pfree((char *) s2);
 	return (len);
 #else
 	/* ----------
@@ -206,11 +208,11 @@ lztextoctetlen(lztext *lz)
 lztext *
 text_lztext(text *txt)
 {
-	lztext		   *result;
-	int32			rawsize;
-	lztext		   *tmp;
-	int				tmp_size;
-	char		   *str;
+	lztext	   *result;
+	int32		rawsize;
+	lztext	   *tmp;
+	int			tmp_size;
+	char	   *str;
 
 	/* ----------
 	 * Handle NULL
@@ -223,8 +225,8 @@ text_lztext(text *txt)
 	 * Determine input size and eventually tuple size
 	 * ----------
 	 */
-	rawsize  = VARSIZE(txt) - VARHDRSZ;
-	str      = VARDATA(txt);
+	rawsize = VARSIZE(txt) - VARHDRSZ;
+	str = VARDATA(txt);
 	tmp_size = PGLZ_MAX_OUTPUT(rawsize);
 
 	/* ----------
@@ -240,11 +242,11 @@ text_lztext(text *txt)
 	 * sequence.
 	 * ----------
 	 */
-	if (tmp_size - tmp->varsize < 256 || 
-					tmp_size - tmp->varsize < tmp_size / 4)
-	{
+	if (tmp_size - tmp->varsize < 256 ||
+		tmp_size - tmp->varsize < tmp_size / 4)
 		result = tmp;
-	} else {
+	else
+	{
 		result = (lztext *) palloc(tmp->varsize);
 		memcpy(result, tmp, tmp->varsize);
 		pfree(tmp);
@@ -303,12 +305,12 @@ lztext_cmp(lztext *lz1, lztext *lz2)
 {
 #ifdef USE_LOCALE
 
-	char   *cp1;
-	char   *cp2;
-	int		result;
+	char	   *cp1;
+	char	   *cp2;
+	int			result;
 
 	if (lz1 == NULL || lz2 == NULL)
-		return (int32)0;
+		return (int32) 0;
 
 	cp1 = lztextout(lz1);
 	cp2 = lztextout(lz2);
@@ -320,21 +322,21 @@ lztext_cmp(lztext *lz1, lztext *lz2)
 
 	return result;
 
-#else /* !USE_LOCALE */
+#else							/* !USE_LOCALE */
 
-	PGLZ_DecompState	ds1;
-	PGLZ_DecompState	ds2;
-	int					c1;
-	int					c2;
-	int32				result = (int32)0;
+	PGLZ_DecompState ds1;
+	PGLZ_DecompState ds2;
+	int			c1;
+	int			c2;
+	int32		result = (int32) 0;
 
 	if (lz1 == NULL || lz2 == NULL)
-		return (int32)0;
+		return (int32) 0;
 
 	pglz_decomp_init(&ds1, lz1);
 	pglz_decomp_init(&ds2, lz2);
 
-	for(;;)
+	for (;;)
 	{
 		c1 = pglz_decomp_getchar(&ds1);
 		c2 = pglz_decomp_getchar(&ds2);
@@ -342,17 +344,17 @@ lztext_cmp(lztext *lz1, lztext *lz2)
 		if (c1 == EOF)
 		{
 			if (c2 != EOF)
-				result = (int32)-1;
+				result = (int32) -1;
 			break;
-		} else {
+		}
+		else
+		{
 			if (c2 == EOF)
-			{
-				result = (int32)1;
-			}
+				result = (int32) 1;
 		}
 		if (c1 != c2)
 		{
-			result = (int32)(c1 - c2);
+			result = (int32) (c1 - c2);
 			break;
 		}
 	}
@@ -362,7 +364,7 @@ lztext_cmp(lztext *lz1, lztext *lz2)
 
 	return result;
 
-#endif /* USE_LOCALE */
+#endif	 /* USE_LOCALE */
 }
 
 
@@ -379,7 +381,7 @@ lztext_eq(lztext *lz1, lztext *lz2)
 	if (lz1 == NULL || lz2 == NULL)
 		return false;
 
-	return (bool)(lztext_cmp(lz1, lz2) == 0);
+	return (bool) (lztext_cmp(lz1, lz2) == 0);
 }
 
 
@@ -389,7 +391,7 @@ lztext_ne(lztext *lz1, lztext *lz2)
 	if (lz1 == NULL || lz2 == NULL)
 		return false;
 
-	return (bool)(lztext_cmp(lz1, lz2) != 0);
+	return (bool) (lztext_cmp(lz1, lz2) != 0);
 }
 
 
@@ -399,7 +401,7 @@ lztext_gt(lztext *lz1, lztext *lz2)
 	if (lz1 == NULL || lz2 == NULL)
 		return false;
 
-	return (bool)(lztext_cmp(lz1, lz2) > 0);
+	return (bool) (lztext_cmp(lz1, lz2) > 0);
 }
 
 
@@ -409,7 +411,7 @@ lztext_ge(lztext *lz1, lztext *lz2)
 	if (lz1 == NULL || lz2 == NULL)
 		return false;
 
-	return (bool)(lztext_cmp(lz1, lz2) >= 0);
+	return (bool) (lztext_cmp(lz1, lz2) >= 0);
 }
 
 
@@ -419,7 +421,7 @@ lztext_lt(lztext *lz1, lztext *lz2)
 	if (lz1 == NULL || lz2 == NULL)
 		return false;
 
-	return (bool)(lztext_cmp(lz1, lz2) < 0);
+	return (bool) (lztext_cmp(lz1, lz2) < 0);
 }
 
 
@@ -429,7 +431,5 @@ lztext_le(lztext *lz1, lztext *lz2)
 	if (lz1 == NULL || lz2 == NULL)
 		return false;
 
-	return (bool)(lztext_cmp(lz1, lz2) <= 0);
+	return (bool) (lztext_cmp(lz1, lz2) <= 0);
 }
-
-
diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c
index 28a94f5e168f272cb7ddc01ca7a62b8a6fe4f19a..ef18ad027931842e00b3f5f411c5085847d85c78 100644
--- a/src/backend/utils/adt/nabstime.c
+++ b/src/backend/utils/adt/nabstime.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.66 2000/02/16 17:24:48 thomas Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.67 2000/04/12 17:15:50 momjian Exp $
  *
  * NOTES
  *
@@ -47,6 +47,7 @@
 
 #if 0
 static AbsoluteTime tm2abstime(struct tm * tm, int tz);
+
 #endif
 
 
@@ -101,6 +102,7 @@ static int	sec_tab[] = {
 	1, 1, 60, 60,
 	3600, 3600, 86400, 86400, 604800, 604800,
 2592000, 2592000, 31536000, 31536000};
+
 #endif
 
 /*
@@ -246,8 +248,11 @@ abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn)
 	/* XXX FreeBSD man pages indicate that this should work - tgl 97/04/23 */
 	if (tzn != NULL)
 	{
-		/* Copy no more than MAXTZLEN bytes of timezone to tzn, in case it
-		   contains an error message, which doesn't fit in the buffer */
+
+		/*
+		 * Copy no more than MAXTZLEN bytes of timezone to tzn, in case it
+		 * contains an error message, which doesn't fit in the buffer
+		 */
 		strncpy(tzn, tm->tm_zone, MAXTZLEN);
 		if (strlen(tm->tm_zone) > MAXTZLEN)
 		{
@@ -264,8 +269,11 @@ abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn)
 #endif
 	if (tzn != NULL)
 	{
-		/* Copy no more than MAXTZLEN bytes of timezone to tzn, in case it
-		   contains an error message, which doesn't fit in the buffer */
+
+		/*
+		 * Copy no more than MAXTZLEN bytes of timezone to tzn, in case it
+		 * contains an error message, which doesn't fit in the buffer
+		 */
 		strncpy(tzn, tzname[tm->tm_isdst], MAXTZLEN);
 		if (strlen(tzname[tm->tm_isdst]) > MAXTZLEN)
 		{
@@ -634,10 +642,10 @@ timestamp_abstime(Timestamp *timestamp)
 /* abstime_timestamp()
  * Convert abstime to timestamp.
  */
-Timestamp   *
+Timestamp  *
 abstime_timestamp(AbsoluteTime abstime)
 {
-	Timestamp   *result;
+	Timestamp  *result;
 
 	if (!PointerIsValid(result = palloc(sizeof(Timestamp))))
 		elog(ERROR, "Unable to allocate space to convert abstime to timestamp");
diff --git a/src/backend/utils/adt/name.c b/src/backend/utils/adt/name.c
index 48223b25977eed4fed09daa9a6caa401e1a70616..630070ce3b3fb53cbe7c2ded320b5ec6d50d5812 100644
--- a/src/backend/utils/adt/name.c
+++ b/src/backend/utils/adt/name.c
@@ -12,7 +12,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.27 2000/01/26 05:57:14 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.28 2000/04/12 17:15:50 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -149,7 +149,8 @@ namecpy(Name n1, Name n2)
 int
 namecat(Name n1, Name n2)
 {
-	return namestrcat(n1, NameStr(*n2));	/* n2 can't be any longer than n1 */
+	return namestrcat(n1, NameStr(*n2));		/* n2 can't be any longer
+												 * than n1 */
 }
 
 #endif
diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c
index 8ee70ec276f53ccc7d9b4d5e2ddc5a1c3a2eb457..7e1a9ead6664840788bd7bb61ecc307f24cf8d24 100644
--- a/src/backend/utils/adt/network.c
+++ b/src/backend/utils/adt/network.c
@@ -3,7 +3,7 @@
  *	is for IP V4 CIDR notation, but prepared for V6: just
  *	add the necessary bits where the comments indicate.
  *
- *	$Id: network.c,v 1.20 2000/03/08 01:44:37 momjian Exp $
+ *	$Id: network.c,v 1.21 2000/04/12 17:15:50 momjian Exp $
  *	Jon Postel RIP 16 Oct 1998
  */
 
@@ -448,8 +448,8 @@ network_netmask(inet *ip)
 	if (ip_family(ip) == AF_INET)
 	{
 		/* It's an IP V4 address: */
-		int	addr = htonl(ip_bits(ip) ?
-			(-1 << (32 - ip_bits(ip))) & 0xffffffff : 0x00000000);
+		int			addr = htonl(ip_bits(ip) ?
+				   (-1 << (32 - ip_bits(ip))) & 0xffffffff : 0x00000000);
 
 		if (inet_net_ntop(AF_INET, &addr, 32, tmp, sizeof(tmp)) == NULL)
 			elog(ERROR, "unable to print netmask (%s)", strerror(errno));
diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c
index 4d46992e4035ec779fce925edcbd0b6975f8c44a..36e333e1217604449b1b6a6fdf00d287b53b56f2 100644
--- a/src/backend/utils/adt/numeric.c
+++ b/src/backend/utils/adt/numeric.c
@@ -5,7 +5,7 @@
  *
  *	1998 Jan Wieck
  *
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.26 2000/03/13 02:31:13 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.27 2000/04/12 17:15:50 momjian Exp $
  *
  * ----------
  */
@@ -59,8 +59,8 @@
  * *after* the decimal point.  Scales are always >= 0.)
  *
  * buf points at the physical start of the palloc'd digit buffer for the
- * NumericVar.  digits points at the first digit in actual use (the one
- * with the specified weight).  We normally leave an unused byte or two
+ * NumericVar.	digits points at the first digit in actual use (the one
+ * with the specified weight).	We normally leave an unused byte or two
  * (preset to zeroes) between buf and digits, so that there is room to store
  * a carry out of the top digit without special pushups.  We just need to
  * decrement digits (and increment weight) to make room for the carry digit.
@@ -77,11 +77,13 @@ typedef unsigned char NumericDigit;
 
 typedef struct NumericVar
 {
-	int			ndigits;		/* number of digits in digits[] - can be 0! */
+	int			ndigits;		/* number of digits in digits[] - can be
+								 * 0! */
 	int			weight;			/* weight of first digit */
 	int			rscale;			/* result scale */
 	int			dscale;			/* display scale */
-	int			sign;			/* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
+	int			sign;			/* NUMERIC_POS, NUMERIC_NEG, or
+								 * NUMERIC_NAN */
 	NumericDigit *buf;			/* start of palloc'd space for digits[] */
 	NumericDigit *digits;		/* decimal digits */
 } NumericVar;
@@ -122,13 +124,14 @@ static NumericVar const_nan =
 #ifdef NUMERIC_DEBUG
 static void dump_numeric(char *str, Numeric num);
 static void dump_var(char *str, NumericVar *var);
+
 #else
 #define dump_numeric(s,n)
 #define dump_var(s,v)
 #endif
 
 #define digitbuf_alloc(size)  ((NumericDigit *) palloc(size))
-#define digitbuf_free(buf)  \
+#define digitbuf_free(buf)	\
 	do { \
 		 if ((buf) != NULL) \
 			 pfree(buf); \
@@ -535,16 +538,16 @@ numeric_round(Numeric num, int32 scale)
 
 	if (i < arg.ndigits)
 	{
-		/* If i = 0, the value loses all digits, but could round up if its
-		 * first digit is more than 4.  If i < 0 the result must be 0.
+
+		/*
+		 * If i = 0, the value loses all digits, but could round up if its
+		 * first digit is more than 4.	If i < 0 the result must be 0.
 		 */
 		if (i < 0)
-		{
 			arg.ndigits = 0;
-		}
 		else
 		{
-			int		carry = (arg.digits[i] > 4) ? 1 : 0;
+			int			carry = (arg.digits[i] > 4) ? 1 : 0;
 
 			arg.ndigits = i;
 
@@ -557,7 +560,7 @@ numeric_round(Numeric num, int32 scale)
 
 			if (i < 0)
 			{
-				Assert(i == -1); /* better not have added more than 1 digit */
+				Assert(i == -1);/* better not have added more than 1 digit */
 				Assert(arg.digits > arg.buf);
 				arg.digits--;
 				arg.ndigits++;
@@ -728,10 +731,10 @@ numeric_cmp(Numeric num1, Numeric num2)
 	NumericVar	arg2;
 
 	if (num1 == NULL || num2 == NULL)
-		return (int32)0;
+		return (int32) 0;
 
 	if (NUMERIC_IS_NAN(num1) || NUMERIC_IS_NAN(num2))
-		return (int32)0;
+		return (int32) 0;
 
 	init_var(&arg1);
 	init_var(&arg2);
@@ -744,7 +747,7 @@ numeric_cmp(Numeric num1, Numeric num2)
 	free_var(&arg1);
 	free_var(&arg2);
 
-	return (int32)((result == 0) ? 0 : ((result < 0) ? -1 : 1));
+	return (int32) ((result == 0) ? 0 : ((result < 0) ? -1 : 1));
 }
 
 
@@ -1742,7 +1745,7 @@ numeric_int4(Numeric num)
 	init_var(&x);
 	set_var_from_num(num, &x);
 
-	str = get_str_from_var(&x, 0); /* dscale = 0 produces rounding */
+	str = get_str_from_var(&x, 0);		/* dscale = 0 produces rounding */
 
 	free_var(&x);
 
@@ -1793,7 +1796,7 @@ numeric_int8(Numeric num)
 	init_var(&x);
 	set_var_from_num(num, &x);
 
-	str = get_str_from_var(&x, 0); /* dscale = 0 produces rounding */
+	str = get_str_from_var(&x, 0);		/* dscale = 0 produces rounding */
 
 	free_var(&x);
 
@@ -1844,7 +1847,7 @@ numeric_int2(Numeric num)
 	init_var(&x);
 	set_var_from_num(num, &x);
 
-	str = get_str_from_var(&x, 0); /* dscale = 0 produces rounding */
+	str = get_str_from_var(&x, 0);		/* dscale = 0 produces rounding */
 
 	free_var(&x);
 
@@ -2130,7 +2133,7 @@ set_var_from_str(char *str, NumericVar *dest)
 		cp++;
 	}
 
-	if (! isdigit(*cp))
+	if (!isdigit(*cp))
 		elog(ERROR, "Bad numeric input format '%s'", str);
 
 	while (*cp)
@@ -2158,8 +2161,8 @@ set_var_from_str(char *str, NumericVar *dest)
 	/* Handle exponent, if any */
 	if (*cp == 'e' || *cp == 'E')
 	{
-		long	exponent;
-		char   *endptr;
+		long		exponent;
+		char	   *endptr;
 
 		cp++;
 		exponent = strtol(cp, &endptr, 10);
@@ -2210,7 +2213,8 @@ set_var_from_num(Numeric num, NumericVar *dest)
 	int			i;
 	int			n;
 
-	n = num->varlen - NUMERIC_HDRSZ; /* number of digit-pairs in packed fmt */
+	n = num->varlen - NUMERIC_HDRSZ;	/* number of digit-pairs in packed
+										 * fmt */
 
 	alloc_var(dest, n * 2);
 
@@ -2224,6 +2228,7 @@ set_var_from_num(Numeric num, NumericVar *dest)
 	for (i = 0; i < n; i++)
 	{
 		unsigned char digitpair = num->n_data[i];
+
 		*digit++ = (digitpair >> 4) & 0x0f;
 		*digit++ = digitpair & 0x0f;
 	}
@@ -2278,7 +2283,7 @@ get_str_from_var(NumericVar *var, int dscale)
 	i = dscale + var->weight + 1;
 	if (i >= 0 && var->ndigits > i)
 	{
-		int		carry = (var->digits[i] > 4) ? 1 : 0;
+		int			carry = (var->digits[i] > 4) ? 1 : 0;
 
 		var->ndigits = i;
 
@@ -2421,6 +2426,7 @@ make_result(NumericVar *var)
 	while (j < n)
 	{
 		unsigned char digitpair = digit[j++] << 4;
+
 		if (j < n)
 			digitpair |= digit[j++];
 		result->n_data[i++] = digitpair;
@@ -2459,7 +2465,7 @@ apply_typmod(NumericVar *var, int32 typmod)
 	i = scale + var->weight + 1;
 	if (i >= 0 && var->ndigits > i)
 	{
-		int		carry = (var->digits[i] > 4) ? 1 : 0;
+		int			carry = (var->digits[i] > 4) ? 1 : 0;
 
 		var->ndigits = i;
 
@@ -2494,7 +2500,7 @@ apply_typmod(NumericVar *var, int32 typmod)
 	if (var->weight >= maxweight)
 	{
 		/* Determine true weight; and check for all-zero result */
-		int		tweight = var->weight;
+		int			tweight = var->weight;
 
 		for (i = 0; i < var->ndigits; i++)
 		{
@@ -2502,10 +2508,10 @@ apply_typmod(NumericVar *var, int32 typmod)
 				break;
 			tweight--;
 		}
-		
+
 		if (tweight >= maxweight && i < var->ndigits)
 			elog(ERROR, "overflow on numeric "
-				 "ABS(value) >= 10^%d for field with precision %d scale %d",
+			  "ABS(value) >= 10^%d for field with precision %d scale %d",
 				 tweight, precision, scale);
 	}
 
@@ -2588,20 +2594,20 @@ add_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
 			switch (cmp_abs(var1, var2))
 			{
 				case 0: /* ----------
-												 * ABS(var1) == ABS(var2)
-												 * result = ZERO
-												 * ----------
-												 */
+																 * ABS(var1) == ABS(var2)
+																 * result = ZERO
+																 * ----------
+																 */
 					zero_var(result);
 					result->rscale = MAX(var1->rscale, var2->rscale);
 					result->dscale = MAX(var1->dscale, var2->dscale);
 					break;
 
 				case 1: /* ----------
-												 * ABS(var1) > ABS(var2)
-												 * result = +(ABS(var1) - ABS(var2))
-												 * ----------
-												 */
+																 * ABS(var1) > ABS(var2)
+																 * result = +(ABS(var1) - ABS(var2))
+																 * ----------
+																 */
 					sub_abs(var1, var2, result);
 					result->sign = NUMERIC_POS;
 					break;
@@ -2629,20 +2635,20 @@ add_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
 			switch (cmp_abs(var1, var2))
 			{
 				case 0: /* ----------
-												 * ABS(var1) == ABS(var2)
-												 * result = ZERO
-												 * ----------
-												 */
+																 * ABS(var1) == ABS(var2)
+																 * result = ZERO
+																 * ----------
+																 */
 					zero_var(result);
 					result->rscale = MAX(var1->rscale, var2->rscale);
 					result->dscale = MAX(var1->dscale, var2->dscale);
 					break;
 
 				case 1: /* ----------
-												 * ABS(var1) > ABS(var2)
-												 * result = -(ABS(var1) - ABS(var2))
-												 * ----------
-												 */
+																 * ABS(var1) > ABS(var2)
+																 * result = -(ABS(var1) - ABS(var2))
+																 * ----------
+																 */
 					sub_abs(var1, var2, result);
 					result->sign = NUMERIC_NEG;
 					break;
@@ -2707,20 +2713,20 @@ sub_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
 			switch (cmp_abs(var1, var2))
 			{
 				case 0: /* ----------
-												 * ABS(var1) == ABS(var2)
-												 * result = ZERO
-												 * ----------
-												 */
+																 * ABS(var1) == ABS(var2)
+																 * result = ZERO
+																 * ----------
+																 */
 					zero_var(result);
 					result->rscale = MAX(var1->rscale, var2->rscale);
 					result->dscale = MAX(var1->dscale, var2->dscale);
 					break;
 
 				case 1: /* ----------
-												 * ABS(var1) > ABS(var2)
-												 * result = +(ABS(var1) - ABS(var2))
-												 * ----------
-												 */
+																 * ABS(var1) > ABS(var2)
+																 * result = +(ABS(var1) - ABS(var2))
+																 * ----------
+																 */
 					sub_abs(var1, var2, result);
 					result->sign = NUMERIC_POS;
 					break;
@@ -2748,20 +2754,20 @@ sub_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
 			switch (cmp_abs(var1, var2))
 			{
 				case 0: /* ----------
-												 * ABS(var1) == ABS(var2)
-												 * result = ZERO
-												 * ----------
-												 */
+																 * ABS(var1) == ABS(var2)
+																 * result = ZERO
+																 * ----------
+																 */
 					zero_var(result);
 					result->rscale = MAX(var1->rscale, var2->rscale);
 					result->dscale = MAX(var1->dscale, var2->dscale);
 					break;
 
 				case 1: /* ----------
-												 * ABS(var1) > ABS(var2)
-												 * result = -(ABS(var1) - ABS(var2))
-												 * ----------
-												 */
+																 * ABS(var1) > ABS(var2)
+																 * result = -(ABS(var1) - ABS(var2))
+																 * ----------
+																 */
 					sub_abs(var1, var2, result);
 					result->sign = NUMERIC_NEG;
 					break;
@@ -3054,7 +3060,7 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
 	result->ndigits = ri + 1;
 	if (ri == res_ndigits + 1)
 	{
-		int		carry = (res_digits[ri] > 4) ? 1 : 0;
+		int			carry = (res_digits[ri] > 4) ? 1 : 0;
 
 		result->ndigits = ri;
 		res_digits[ri] = 0;
diff --git a/src/backend/utils/adt/numutils.c b/src/backend/utils/adt/numutils.c
index 4e6d9a6ac4a8c123ae54b25ea66a8fad59bb89ee..681a78baa85ae81238363768c13526423033095a 100644
--- a/src/backend/utils/adt/numutils.c
+++ b/src/backend/utils/adt/numutils.c
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.39 2000/01/26 05:57:14 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.40 2000/04/12 17:15:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -84,7 +84,7 @@ pg_atoi(char *s, int size, int c)
 				errno = ERANGE;
 				elog(ERROR, "pg_atoi: error reading \"%s\": %m", s);
 			}
-#endif         /* HAVE_LONG_INT_64 */
+#endif	 /* HAVE_LONG_INT_64 */
 			break;
 		case sizeof(int16):
 			if (l < SHRT_MIN)
diff --git a/src/backend/utils/adt/oid.c b/src/backend/utils/adt/oid.c
index b7d1e2c03d3482ff06657dc68104eb699393c3ba..96640af91e535472fbb54f7b141086952d115241 100644
--- a/src/backend/utils/adt/oid.c
+++ b/src/backend/utils/adt/oid.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.33 2000/01/26 05:57:14 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.34 2000/04/12 17:15:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -39,7 +39,7 @@ oidvectorin(char *oidString)
 
 	result = (Oid *) palloc(sizeof(Oid[INDEX_MAX_KEYS]));
 
-	for (slot=0; *oidString && slot < INDEX_MAX_KEYS; slot++)
+	for (slot = 0; *oidString && slot < INDEX_MAX_KEYS; slot++)
 	{
 		if (sscanf(oidString, "%u", &result[slot]) != 1)
 			break;
@@ -51,7 +51,7 @@ oidvectorin(char *oidString)
 	while (*oidString && isspace(*oidString))
 		oidString++;
 	if (*oidString)
-		elog(ERROR,"oidvector value has too many values");
+		elog(ERROR, "oidvector value has too many values");
 	while (slot < INDEX_MAX_KEYS)
 		result[slot++] = 0;
 
@@ -64,7 +64,8 @@ oidvectorin(char *oidString)
 char *
 oidvectorout(Oid *oidArray)
 {
-	int			num, maxnum;
+	int			num,
+				maxnum;
 	char	   *rp;
 	char	   *result;
 
@@ -77,12 +78,12 @@ oidvectorout(Oid *oidArray)
 	}
 
 	/* find last non-zero value in vector */
-	for (maxnum = INDEX_MAX_KEYS-1; maxnum >= 0; maxnum--)
+	for (maxnum = INDEX_MAX_KEYS - 1; maxnum >= 0; maxnum--)
 		if (oidArray[maxnum] != 0)
 			break;
 
 	/* assumes sign, 10 digits, ' ' */
-	rp = result = (char *) palloc((maxnum+1) * 12 + 1);
+	rp = result = (char *) palloc((maxnum + 1) * 12 + 1);
 	for (num = 0; num <= maxnum; num++)
 	{
 		if (num != 0)
diff --git a/src/backend/utils/adt/oracle_compat.c b/src/backend/utils/adt/oracle_compat.c
index 41e2563f3b0844095c09e83268470e0b7ed65efb..522e6c7bce4a0be12294fbf492966c28159a2878 100644
--- a/src/backend/utils/adt/oracle_compat.c
+++ b/src/backend/utils/adt/oracle_compat.c
@@ -1,7 +1,7 @@
 /*
  *	Edmund Mergl <E.Mergl@bawue.de>
  *
- *	$Id: oracle_compat.c,v 1.23 2000/04/07 13:39:41 thomas Exp $
+ *	$Id: oracle_compat.c,v 1.24 2000/04/12 17:15:51 momjian Exp $
  *
  */
 
@@ -466,10 +466,16 @@ rtrim(text *string, text *set)
 text *
 translate(text *string, text *from, text *to)
 {
-	text   *result;
-	char   *from_ptr, *to_ptr;
-	char   *source, *target;
-	int		m, fromlen, tolen, retlen, i;
+	text	   *result;
+	char	   *from_ptr,
+			   *to_ptr;
+	char	   *source,
+			   *target;
+	int			m,
+				fromlen,
+				tolen,
+				retlen,
+				i;
 
 	if (string == (text *) NULL ||
 		from == (text *) NULL ||
@@ -492,11 +498,11 @@ translate(text *string, text *from, text *to)
 
 	while (m-- > 0)
 	{
-		char	rep = *source++;
+		char		rep = *source++;
 
 		for (i = 0; i < fromlen; i++)
 		{
-            if (from_ptr[i] == rep)
+			if (from_ptr[i] == rep)
 				break;
 		}
 		if (i < fromlen)
@@ -521,6 +527,7 @@ translate(text *string, text *from, text *to)
 	}
 
 	VARSIZE(result) = retlen + VARHDRSZ;
+
 	/*
 	 * There may be some wasted space in the result if deletions occurred,
 	 * but it's not worth reallocating it; the function result probably
@@ -541,34 +548,35 @@ ascii(text *string)
 		return 0;
 
 	return ((int) *(VARDATA(string)));
-} /* ascii() */
+}	/* ascii() */
 
 
 text *
 ichar(int4 cvalue)
 {
-	text   *result;
+	text	   *result;
 
 	result = (text *) palloc(VARHDRSZ + 1);
 	VARSIZE(result) = VARHDRSZ + 1;
 	*VARDATA(result) = (char) cvalue;
 
 	return result;
-} /* ichar() */
+}	/* ichar() */
 
 
 text *
 repeat(text *string, int4 count)
 {
-	text   *result;
-	int		slen, tlen;
-	int		i;
-	char   *cp;
+	text	   *result;
+	int			slen,
+				tlen;
+	int			i;
+	char	   *cp;
 
 	if (count < 0)
 		count = 0;
 
-	slen = (VARSIZE(string)-VARHDRSZ);
+	slen = (VARSIZE(string) - VARHDRSZ);
 	tlen = (VARHDRSZ + (count * slen));
 
 	result = (text *) palloc(tlen);
@@ -582,5 +590,4 @@ repeat(text *string, int4 count)
 	}
 
 	return result;
-} /* repeat() */
-
+}	/* repeat() */
diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c
index 114cd08e259e81941c70efa3ed662ea4f3e4ff12..c7a7a149b2c1ebaa157769c80316f7fd0d6e4daf 100644
--- a/src/backend/utils/adt/pg_locale.c
+++ b/src/backend/utils/adt/pg_locale.c
@@ -2,22 +2,22 @@
 /* -----------------------------------------------------------------------
  * pg_locale.c
  *
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.3 2000/03/18 18:57:14 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.4 2000/04/12 17:15:51 momjian Exp $
  *
  *
- *   Portions Copyright (c) 1999-2000, PostgreSQL, Inc
+ *	 Portions Copyright (c) 1999-2000, PostgreSQL, Inc
  *
- *   The PostgreSQL locale utils.
+ *	 The PostgreSQL locale utils.
  *
  *	Karel Zak - Zakkr
  *
  * -----------------------------------------------------------------------
  */
- 
+
 #include <stdio.h>
- 
+
 #include "postgres.h"
- 
+
 #ifdef USE_LOCALE
 
 #include <locale.h>
@@ -27,72 +27,72 @@
 
 
 /*------
- * Return in PG_LocaleCategories current locale setting 
+ * Return in PG_LocaleCategories current locale setting
  *------
- */  
+ */
 PG_LocaleCategories *
-PGLC_current( PG_LocaleCategories *lc )
+PGLC_current(PG_LocaleCategories * lc)
 {
-	lc->lang	= getenv("LANG");		
-		
-lc->lc_ctype	= setlocale(LC_CTYPE,	  NULL);
-lc->lc_numeric	= setlocale(LC_NUMERIC,	  NULL);
-lc->lc_time	= setlocale(LC_TIME,	  NULL);
-lc->lc_collate	= setlocale(LC_COLLATE,	  NULL);
-lc->lc_monetary	= setlocale(LC_MONETARY,  NULL);
-lc->lc_messages	= setlocale(LC_MESSAGES,  NULL);
+	lc->lang = getenv("LANG");
+
+	lc->lc_ctype = setlocale(LC_CTYPE, NULL);
+	lc->lc_numeric = setlocale(LC_NUMERIC, NULL);
+	lc->lc_time = setlocale(LC_TIME, NULL);
+	lc->lc_collate = setlocale(LC_COLLATE, NULL);
+	lc->lc_monetary = setlocale(LC_MONETARY, NULL);
+	lc->lc_messages = setlocale(LC_MESSAGES, NULL);
 
 	return lc;
-}	
+}
 
 
-#ifdef DEBUG_LOCALE_UTILS 
+#ifdef DEBUG_LOCALE_UTILS
 
 /*------
  * Print a PG_LocaleCategories struct as DEBUG
  *------
  */
 PG_LocaleCategories *
-PGLC_debug_lc( PG_LocaleCategories *lc )
+PGLC_debug_lc(PG_LocaleCategories * lc)
 {
 	elog(DEBUG, "CURRENT LOCALE ENVIRONMENT:\n\nLANG:   \t%s\nLC_CTYPE:\t%s\nLC_NUMERIC:\t%s\nLC_TIME:\t%s\nLC_COLLATE:\t%s\nLC_MONETARY:\t%s\nLC_MESSAGES:\t%s\n",
-		lc->lang,	
-		lc->lc_ctype,	
-		lc->lc_numeric,	
-        	lc->lc_time,	
-        	lc->lc_collate,	
-        	lc->lc_monetary,	
-        	lc->lc_messages	
+		 lc->lang,
+		 lc->lc_ctype,
+		 lc->lc_numeric,
+		 lc->lc_time,
+		 lc->lc_collate,
+		 lc->lc_monetary,
+		 lc->lc_messages
 	);
 
-	return lc;	
+	return lc;
 }
 
 #endif
 
 /*------
- * Set locales via a PG_LocaleCategories struct 
+ * Set locales via a PG_LocaleCategories struct
  *------
  */
 PG_LocaleCategories *
-PGLC_setlocale( PG_LocaleCategories *lc )
+PGLC_setlocale(PG_LocaleCategories * lc)
 {
-	if (!setlocale(LC_CTYPE,	 lc->lc_ctype	))
-		elog(NOTICE, "pg_setlocale(): 'LC_CTYPE=%s' cannot be honored.", lc->lc_ctype); 
-			
-	if (!setlocale(LC_NUMERIC,	lc->lc_numeric	))
+	if (!setlocale(LC_CTYPE, lc->lc_ctype))
+		elog(NOTICE, "pg_setlocale(): 'LC_CTYPE=%s' cannot be honored.", lc->lc_ctype);
+
+	if (!setlocale(LC_NUMERIC, lc->lc_numeric))
 		elog(NOTICE, "pg_setlocale(): 'LC_NUMERIC=%s' cannot be honored.", lc->lc_numeric);
-			
-        if (!setlocale(LC_TIME,	 	lc->lc_time	))
-        	elog(NOTICE, "pg_setlocale(): 'LC_TIME=%s' cannot be honored.", lc->lc_time);
-        
-        if (!setlocale(LC_COLLATE,	lc->lc_collate	))
+
+	if (!setlocale(LC_TIME, lc->lc_time))
+		elog(NOTICE, "pg_setlocale(): 'LC_TIME=%s' cannot be honored.", lc->lc_time);
+
+	if (!setlocale(LC_COLLATE, lc->lc_collate))
 		elog(NOTICE, "pg_setlocale(): 'LC_COLLATE=%s' cannot be honored.", lc->lc_collate);
 
-        if (!setlocale(LC_MONETARY,   	lc->lc_monetary	))
-  		elog(NOTICE, "pg_setlocale(): 'LC_MONETARY=%s' cannot be honored.", lc->lc_monetary);
-  
-        if (!setlocale(LC_MESSAGES,   	lc->lc_messages	))
+	if (!setlocale(LC_MONETARY, lc->lc_monetary))
+		elog(NOTICE, "pg_setlocale(): 'LC_MONETARY=%s' cannot be honored.", lc->lc_monetary);
+
+	if (!setlocale(LC_MESSAGES, lc->lc_messages))
 		elog(NOTICE, "pg_setlocale(): 'LC_MESSAGE=%s' cannot be honored.", lc->lc_messages);
 
 	return lc;
@@ -101,28 +101,28 @@ PGLC_setlocale( PG_LocaleCategories *lc )
 /*------
  * Return the POSIX lconv struct (contains number/money formatting information)
  * with locale information for *all* categories.
- * => Returned lconv is *independent* on current locale catogories setting - in 
+ * => Returned lconv is *independent* on current locale catogories setting - in
  * contrast to standard localeconv().
  *
- * ! libc prepare memory space for lconv itself and all returned strings in 
- *   lconv are *static strings*.	      		  
+ * ! libc prepare memory space for lconv itself and all returned strings in
+ *	 lconv are *static strings*.
  *------
  */
 struct lconv *
 PGLC_localeconv(void)
 {
-	PG_LocaleCategories	lc;
-	struct lconv		*lconv;
+	PG_LocaleCategories lc;
+	struct lconv *lconv;
 
 	/* Save current locale setting to lc */
-	PGLC_current(&lc);	
-	
+	PGLC_current(&lc);
+
 	/* Set all locale category for current lang */
 	setlocale(LC_ALL, "");
-	
-	/* Get numeric formatting information */ 
-	lconv = localeconv();		
-	
+
+	/* Get numeric formatting information */
+	lconv = localeconv();
+
 	/* Set previous original locale */
 	PGLC_setlocale(&lc);
 
@@ -130,4 +130,4 @@ PGLC_localeconv(void)
 }
 
 
-#endif /* USE_LOCALE */
+#endif	 /* USE_LOCALE */
diff --git a/src/backend/utils/adt/pg_lzcompress.c b/src/backend/utils/adt/pg_lzcompress.c
index c35568e9598116b29c1c98c953065ee395e893fd..ddeb8b5a51004d93d8a9052a20ee1f86ad2586db 100644
--- a/src/backend/utils/adt/pg_lzcompress.c
+++ b/src/backend/utils/adt/pg_lzcompress.c
@@ -1,7 +1,7 @@
 /* ----------
  * pg_lzcompress.c -
  *
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.3 1999/11/25 01:28:04 wieck Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.4 2000/04/12 17:15:51 momjian Exp $
  *
  *		This is an implementation of LZ compression for PostgreSQL.
  *		It uses a simple history table and generates 2-3 byte tags
@@ -83,7 +83,7 @@
  *
  *			So the 16 bits of a 2 byte tag are coded as
  *
- *              7---T1--0  7---T2--0
+ *				7---T1--0  7---T2--0
  *				OOOO LLLL  OOOO OOOO
  *
  *			This limits the offset to 1-4095 (12 bits) and the length
@@ -144,9 +144,10 @@
  *		Linked list for the backward history lookup
  * ----------
  */
-typedef struct PGLZ_HistEntry {
-	struct PGLZ_HistEntry	   *next;
-	char					   *pos;
+typedef struct PGLZ_HistEntry
+{
+	struct PGLZ_HistEntry *next;
+	char	   *pos;
 } PGLZ_HistEntry;
 
 
@@ -155,35 +156,43 @@ typedef struct PGLZ_HistEntry {
  * ----------
  */
 static PGLZ_Strategy strategy_default_data = {
-	256,	/* Data chunks smaller 256 bytes are nott compressed			*/
-	6144,	/* Data chunks greater equal 6K force compression				*/
-			/* except compressed result is greater uncompressed data		*/
-	20,		/* Compression rates below 20% mean fallback to uncompressed	*/
-			/* storage except compression is forced by previous parameter	*/
-	128,	/* Stop history lookup if a match of 128 bytes is found			*/
-	10		/* Lower good match size by 10% at every lookup loop iteration.	*/
+	256,						/* Data chunks smaller 256 bytes are nott
+								 * compressed			 */
+	6144,						/* Data chunks greater equal 6K force
+								 * compression				 */
+	/* except compressed result is greater uncompressed data		*/
+	20,							/* Compression rates below 20% mean
+								 * fallback to uncompressed    */
+	/* storage except compression is forced by previous parameter	*/
+	128,						/* Stop history lookup if a match of 128
+								 * bytes is found		  */
+	10							/* Lower good match size by 10% at every
+								 * lookup loop iteration. */
 };
-PGLZ_Strategy	*PGLZ_strategy_default = &strategy_default_data;
+PGLZ_Strategy *PGLZ_strategy_default = &strategy_default_data;
 
 
 static PGLZ_Strategy strategy_allways_data = {
-	0,		/* Chunks of any size are compressed							*/
-	0,		/* 																*/
-	0,		/* We want to save at least one single byte						*/
-	128,	/* Stop history lookup if a match of 128 bytes is found			*/
-	6		/* Look harder for a good match.								*/
+	0,							/* Chunks of any size are compressed							*/
+	0,							/* */
+	0,							/* We want to save at least one single
+								 * byte						*/
+	128,						/* Stop history lookup if a match of 128
+								 * bytes is found		  */
+	6							/* Look harder for a good match.								*/
 };
-PGLZ_Strategy	*PGLZ_strategy_allways = &strategy_allways_data;
+PGLZ_Strategy *PGLZ_strategy_allways = &strategy_allways_data;
 
 
 static PGLZ_Strategy strategy_never_data = {
-	0,		/* 																*/
-	0,		/* 																*/
-	0,		/* 																*/
-	0,		/* Zero indicates "store uncompressed allways"					*/
-	0		/* 																*/
+	0,							/* */
+	0,							/* */
+	0,							/* */
+	0,							/* Zero indicates "store uncompressed
+								 * allways"                  */
+	0							/* */
 };
-PGLZ_Strategy	*PGLZ_strategy_never = &strategy_never_data;
+PGLZ_Strategy *PGLZ_strategy_never = &strategy_never_data;
 
 
 
@@ -197,7 +206,7 @@ PGLZ_Strategy	*PGLZ_strategy_never = &strategy_never_data;
 #if 1
 #define pglz_hist_idx(_s,_e) (												\
 			(((_e) - (_s)) < 4) ? 0 :										\
-			((((_s)[0] << 9) ^ ((_s)[1] << 6) ^ 							\
+			((((_s)[0] << 9) ^ ((_s)[1] << 6) ^								\
 			((_s)[2] << 3) ^ (_s)[3]) & (PGLZ_HISTORY_MASK))				\
 		)
 #else
@@ -217,7 +226,7 @@ PGLZ_Strategy	*PGLZ_strategy_never = &strategy_never_data;
 #define pglz_hist_add(_hs,_hn,_s,_e) {										\
 			int __hindex = pglz_hist_idx((_s),(_e));						\
 			(_hn)->next = (_hs)[__hindex];									\
-			(_hn)->pos  = (_s);												\
+			(_hn)->pos	= (_s);												\
 			(_hs)[__hindex] = (_hn)++;										\
 		}
 
@@ -288,16 +297,16 @@ PGLZ_Strategy	*PGLZ_strategy_never = &strategy_never_data;
  * ----------
  */
 static inline int
-pglz_find_match (PGLZ_HistEntry **hstart, char *input, char *end, 
-						int *lenp, int *offp, int good_match, int good_drop)
+pglz_find_match(PGLZ_HistEntry **hstart, char *input, char *end,
+				int *lenp, int *offp, int good_match, int good_drop)
 {
-	PGLZ_HistEntry	   *hent;
-	int32				len = 0;
-	int32				off = 0;
-	int32				thislen;
-	int32				thisoff;
-	char			   *ip;
-	char			   *hp;
+	PGLZ_HistEntry *hent;
+	int32		len = 0;
+	int32		off = 0;
+	int32		thislen;
+	int32		thisoff;
+	char	   *ip;
+	char	   *hp;
 
 	/* ----------
 	 * Traverse the linked history list until a good enough
@@ -311,7 +320,7 @@ pglz_find_match (PGLZ_HistEntry **hstart, char *input, char *end,
 		 * Be happy with lesser good matches the more entries we visited.
 		 * ----------
 		 */
-		good_match -= (good_match * good_drop) /100;
+		good_match -= (good_match * good_drop) / 100;
 
 		/* ----------
 		 * Stop if the offset does not fit into our tag anymore.
@@ -340,9 +349,9 @@ pglz_find_match (PGLZ_HistEntry **hstart, char *input, char *end,
 			thislen = len;
 			ip += len;
 			hp += len;
-		} else {
-			thislen = 0;
 		}
+		else
+			thislen = 0;
 		while (ip < end && *ip == *hp && thislen < PGLZ_MAX_MATCH)
 		{
 			thislen++;
@@ -390,29 +399,29 @@ pglz_find_match (PGLZ_HistEntry **hstart, char *input, char *end,
  * ----------
  */
 int
-pglz_compress (char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strategy)
+pglz_compress(char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strategy)
 {
-	PGLZ_HistEntry	   *hist_start[PGLZ_HISTORY_SIZE];
-	PGLZ_HistEntry	   *hist_alloc;
-	PGLZ_HistEntry	   hist_prealloc[PGLZ_HISTORY_PREALLOC];
-	PGLZ_HistEntry	   *hist_next;
-
-	unsigned char	   *bp = ((unsigned char *)dest) + sizeof(PGLZ_Header);
-	unsigned char	   *bstart = bp;
-	char			   *dp = source;
-	char			   *dend = source + slen;
-	unsigned char		ctrl_dummy = 0;
-	unsigned char	   *ctrlp = &ctrl_dummy;
-	unsigned char		ctrlb = 0;
-	unsigned char		ctrl = 0;
-	int32				match_len;
-	int32				match_off;
-	int32				good_match;
-	int32				good_drop;
-	int32				do_compress = 1;
-	int32				result_size = -1;
-	int32				result_max;
-	int32				need_rate;
+	PGLZ_HistEntry *hist_start[PGLZ_HISTORY_SIZE];
+	PGLZ_HistEntry *hist_alloc;
+	PGLZ_HistEntry hist_prealloc[PGLZ_HISTORY_PREALLOC];
+	PGLZ_HistEntry *hist_next;
+
+	unsigned char *bp = ((unsigned char *) dest) + sizeof(PGLZ_Header);
+	unsigned char *bstart = bp;
+	char	   *dp = source;
+	char	   *dend = source + slen;
+	unsigned char ctrl_dummy = 0;
+	unsigned char *ctrlp = &ctrl_dummy;
+	unsigned char ctrlb = 0;
+	unsigned char ctrl = 0;
+	int32		match_len;
+	int32		match_off;
+	int32		good_match;
+	int32		good_drop;
+	int32		do_compress = 1;
+	int32		result_size = -1;
+	int32		result_max;
+	int32		need_rate;
 
 	/* ----------
 	 * Our fallback strategy is the default.
@@ -436,7 +445,9 @@ pglz_compress (char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strateg
 	{
 		memcpy(bstart, source, slen);
 		return (dest->varsize = slen + sizeof(PGLZ_Header));
-	} else {
+	}
+	else
+	{
 		if (slen < strategy->min_input_size)
 		{
 			memcpy(bstart, source, slen);
@@ -464,12 +475,12 @@ pglz_compress (char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strateg
 	 * table on the stack frame.
 	 * ----------
 	 */
-	memset((void *)hist_start, 0, sizeof(hist_start));
+	memset((void *) hist_start, 0, sizeof(hist_start));
 	if (slen + 1 <= PGLZ_HISTORY_PREALLOC)
 		hist_alloc = hist_prealloc;
 	else
 		hist_alloc = (PGLZ_HistEntry *)
-							palloc(sizeof(PGLZ_HistEntry) * (slen + 1));
+			palloc(sizeof(PGLZ_HistEntry) * (slen + 1));
 	hist_next = hist_alloc;
 
 	/* ----------
@@ -481,9 +492,9 @@ pglz_compress (char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strateg
 	 * ----------
 	 */
 	if (slen >= strategy->force_input_size)
-	{
 		result_max = slen;
-	} else {
+	else
+	{
 		need_rate = strategy->min_comp_rate;
 		if (need_rate < 0)
 			need_rate = 0;
@@ -513,8 +524,8 @@ pglz_compress (char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strateg
 		 * Try to find a match in the history
 		 * ----------
 		 */
-		if (pglz_find_match(hist_start, dp, dend, &match_len, 
-										&match_off, good_match, good_drop))
+		if (pglz_find_match(hist_start, dp, dend, &match_len,
+							&match_off, good_match, good_drop))
 		{
 			/* ----------
 			 * Create the tag and add history entries for
@@ -522,21 +533,23 @@ pglz_compress (char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strateg
 			 * ----------
 			 */
 			pglz_out_tag(ctrlp, ctrlb, ctrl, bp, match_len, match_off);
-			while(match_len--)
+			while (match_len--)
 			{
 				pglz_hist_add(hist_start, hist_next, dp, dend);
-				dp++;	/* Do not do this ++ in the line above!		*/
-						/* The macro would do it four times - Jan.	*/
+				dp++;			/* Do not do this ++ in the line above!		*/
+				/* The macro would do it four times - Jan.	*/
 			}
-		} else {
+		}
+		else
+		{
 			/* ----------
 			 * No match found. Copy one literal byte.
 			 * ----------
 			 */
 			pglz_out_literal(ctrlp, ctrlb, ctrl, bp, *dp);
 			pglz_hist_add(hist_start, hist_next, dp, dend);
-			dp++;	/* Do not do this ++ in the line above!		*/
-					/* The macro would do it four times - Jan.	*/
+			dp++;				/* Do not do this ++ in the line above!		*/
+			/* The macro would do it four times - Jan.	*/
 		}
 	}
 
@@ -545,7 +558,7 @@ pglz_compress (char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strateg
 	 * ----------
 	 */
 	if (hist_alloc != hist_prealloc)
-		pfree((void *)hist_alloc);
+		pfree((void *) hist_alloc);
 
 	/* ----------
 	 * If we are still in compressing mode, write out the last
@@ -558,9 +571,8 @@ pglz_compress (char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strateg
 		*ctrlp = ctrlb;
 
 		result_size = bp - bstart;
-		if (result_size >= result_max) {
+		if (result_size >= result_max)
 			do_compress = 0;
-		}
 	}
 
 	/* ----------
@@ -571,10 +583,10 @@ pglz_compress (char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strateg
 	 * ----------
 	 */
 	if (do_compress)
-	{
 		return (dest->varsize = result_size + sizeof(PGLZ_Header));
-	} else {
-		memcpy(((char *)dest) + sizeof(PGLZ_Header), source, slen);
+	else
+	{
+		memcpy(((char *) dest) + sizeof(PGLZ_Header), source, slen);
 		return (dest->varsize = slen + sizeof(PGLZ_Header));
 	}
 }
@@ -587,19 +599,19 @@ pglz_compress (char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strateg
  * ----------
  */
 int
-pglz_decompress (PGLZ_Header *source, char *dest)
+pglz_decompress(PGLZ_Header *source, char *dest)
 {
-	unsigned char	   *dp;
-	unsigned char	   *dend;
-	unsigned char	   *bp;
-	unsigned char		ctrl;
-	int32				ctrlc;
-	int32				len;
-	int32				off;
-
-	dp		= ((unsigned char *)source) + sizeof(PGLZ_Header);
-	dend	= ((unsigned char *)source) + source->varsize;
-	bp		= (unsigned char *)dest;
+	unsigned char *dp;
+	unsigned char *dend;
+	unsigned char *bp;
+	unsigned char ctrl;
+	int32		ctrlc;
+	int32		len;
+	int32		off;
+
+	dp = ((unsigned char *) source) + sizeof(PGLZ_Header);
+	dend = ((unsigned char *) source) + source->varsize;
+	bp = (unsigned char *) dest;
 
 	if (source->varsize == source->rawsize + sizeof(PGLZ_Header))
 	{
@@ -630,9 +642,7 @@ pglz_decompress (PGLZ_Header *source, char *dest)
 				off = ((dp[0] & 0xf0) << 4) | dp[1];
 				dp += 2;
 				if (len == 18)
-				{
 					len += *dp++;
-				}
 
 				/* ----------
 				 * Now we copy the bytes specified by the tag from
@@ -646,7 +656,9 @@ pglz_decompress (PGLZ_Header *source, char *dest)
 					*bp = bp[-off];
 					bp++;
 				}
-			} else {
+			}
+			else
+			{
 				/* ----------
 				 * An unset control bit means LITERAL BYTE. So we
 				 * just copy one from INPUT to OUTPUT.
@@ -667,7 +679,7 @@ pglz_decompress (PGLZ_Header *source, char *dest)
 	 * That's it.
 	 * ----------
 	 */
-	return (char *)bp - dest;
+	return (char *) bp - dest;
 }
 
 
@@ -681,7 +693,7 @@ pglz_decompress (PGLZ_Header *source, char *dest)
 int
 pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate)
 {
-	unsigned char		retval;
+	unsigned char retval;
 
 	if (dstate->tocopy > 0)
 	{
@@ -703,9 +715,7 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate)
 		 * ----------
 		 */
 		if (dstate->cp_in == dstate->cp_end)
-		{
 			return EOF;
-		}
 
 		/* ----------
 		 * This decompression method saves time only, if we stop near
@@ -721,14 +731,14 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate)
 		 */
 		if (dstate->cp_out - dstate->temp_buf >= 256)
 		{
-			unsigned char	   *cp_in		= dstate->cp_in;
-			unsigned char	   *cp_out		= dstate->cp_out;
-			unsigned char	   *cp_end		= dstate->cp_end;
-			unsigned char	   *cp_copy;
-			unsigned char		ctrl;
-			int					off;
-			int					len;
-			int					i;
+			unsigned char *cp_in = dstate->cp_in;
+			unsigned char *cp_out = dstate->cp_out;
+			unsigned char *cp_end = dstate->cp_end;
+			unsigned char *cp_copy;
+			unsigned char ctrl;
+			int			off;
+			int			len;
+			int			i;
 
 			while (cp_in < cp_end)
 			{
@@ -748,27 +758,27 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate)
 							len += *cp_in++;
 
 						cp_copy = cp_out - off;
-						while(len--)
+						while (len--)
 							*cp_out++ = *cp_copy++;
-					} else {
-						*cp_out++ = *cp_in++;
 					}
+					else
+						*cp_out++ = *cp_in++;
 					ctrl >>= 1;
 				}
 			}
 
-			dstate->cp_in		= dstate->cp_out;
-			dstate->cp_end		= cp_out;
-			dstate->next_char	= pglz_get_next_decomp_char_from_plain;
+			dstate->cp_in = dstate->cp_out;
+			dstate->cp_end = cp_out;
+			dstate->next_char = pglz_get_next_decomp_char_from_plain;
 
-			return (int)(*(dstate->cp_in++));
+			return (int) (*(dstate->cp_in++));
 		}
 
 		/* ----------
 		 * Not yet, get next control byte into decomp state.
 		 * ----------
 		 */
-		dstate->ctrl = (unsigned char)(*(dstate->cp_in++));
+		dstate->ctrl = (unsigned char) (*(dstate->cp_in++));
 		dstate->ctrl_count = 8;
 	}
 
@@ -777,9 +787,7 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate)
 	 * ----------
 	 */
 	if (dstate->cp_in == dstate->cp_end)
-	{
 		return EOF;
-	}
 
 	/* ----------
 	 * Handle next control bit.
@@ -793,27 +801,29 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate)
 		 * and do the copy for the first byte as above.
 		 * ----------
 		 */
-		int		off;
+		int			off;
 
-		dstate->tocopy	= (dstate->cp_in[0] & 0x0f) + 3;
-		off				= ((dstate->cp_in[0] & 0xf0) << 4) | dstate->cp_in[1];
-		dstate->cp_in	+= 2;
+		dstate->tocopy = (dstate->cp_in[0] & 0x0f) + 3;
+		off = ((dstate->cp_in[0] & 0xf0) << 4) | dstate->cp_in[1];
+		dstate->cp_in += 2;
 		if (dstate->tocopy == 18)
 			dstate->tocopy += *(dstate->cp_in++);
 		dstate->cp_copy = dstate->cp_out - off;
 
 		dstate->tocopy--;
 		retval = (*(dstate->cp_out++) = *(dstate->cp_copy++));
-	} else {
+	}
+	else
+	{
 		/* ----------
 		 * Bit is unset, so literal byte follows.
 		 * ----------
 		 */
-		retval = (int)(*(dstate->cp_out++) = *(dstate->cp_in++));
+		retval = (int) (*(dstate->cp_out++) = *(dstate->cp_in++));
 	}
 	dstate->ctrl >>= 1;
 
-	return (int)retval;
+	return (int) retval;
 }
 
 
@@ -831,7 +841,5 @@ pglz_get_next_decomp_char_from_plain(PGLZ_DecompState *dstate)
 	if (dstate->cp_in >= dstate->cp_end)
 		return EOF;
 
-	return (int)(*(dstate->cp_in++));
+	return (int) (*(dstate->cp_in++));
 }
-
-
diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c
index 7f4bd651ace1c79acee519b6d75050e4f5915f59..4060a8466552c28b4b45541fb7764e5fdde0db9e 100644
--- a/src/backend/utils/adt/regproc.c
+++ b/src/backend/utils/adt/regproc.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.53 2000/02/27 03:30:27 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.54 2000/04/12 17:15:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -264,7 +264,7 @@ oidvectortypes(Oid *oidArray)
 	for (num = 0; num < FUNC_MAX_ARGS; num++)
 	{
 		if (oidArray[num] != InvalidOid)
-			numargs = num+1;
+			numargs = num + 1;
 	}
 
 	result = (text *) palloc((NAMEDATALEN + 1) * numargs + VARHDRSZ + 1);
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c
index b6f9b5eead8c92a9910b29c73b7afefc8a325126..79010b53f75bc0b2107112809c4dc94758b5427e 100644
--- a/src/backend/utils/adt/ri_triggers.c
+++ b/src/backend/utils/adt/ri_triggers.c
@@ -6,7 +6,7 @@
  *
  *	1999 Jan Wieck
  *
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.13 2000/02/07 17:50:38 wieck Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.14 2000/04/12 17:15:51 momjian Exp $
  *
  * ----------
  */
@@ -79,14 +79,15 @@
  *	The key identifying a prepared SPI plan in our private hashtable
  * ----------
  */
-typedef struct RI_QueryKey {
-	int32				constr_type;
-	Oid					constr_id;
-	int32				constr_queryno;
-	Oid					fk_relid;
-	Oid					pk_relid;
-	int32				nkeypairs;
-	int16				keypair[RI_MAX_NUMKEYS][2];
+typedef struct RI_QueryKey
+{
+	int32		constr_type;
+	Oid			constr_id;
+	int32		constr_queryno;
+	Oid			fk_relid;
+	Oid			pk_relid;
+	int32		nkeypairs;
+	int16		keypair[RI_MAX_NUMKEYS][2];
 } RI_QueryKey;
 
 
@@ -94,16 +95,18 @@ typedef struct RI_QueryKey {
  * RI_QueryHashEntry
  * ----------
  */
-typedef struct RI_QueryHashEntry {
-	RI_QueryKey			key;
-	void			   *plan;
+typedef struct RI_QueryHashEntry
+{
+	RI_QueryKey key;
+	void	   *plan;
 } RI_QueryHashEntry;
 
 
-typedef struct RI_OpreqHashEntry {
-	Oid					typeid;
-	Oid					oprfnid;
-	FmgrInfo			oprfmgrinfo;
+typedef struct RI_OpreqHashEntry
+{
+	Oid			typeid;
+	Oid			oprfnid;
+	FmgrInfo	oprfmgrinfo;
 } RI_OpreqHashEntry;
 
 
@@ -112,27 +115,27 @@ typedef struct RI_OpreqHashEntry {
  * Local data
  * ----------
  */
-static HTAB			   *ri_query_cache = (HTAB *)NULL;
-static HTAB			   *ri_opreq_cache = (HTAB *)NULL;
+static HTAB *ri_query_cache = (HTAB *) NULL;
+static HTAB *ri_opreq_cache = (HTAB *) NULL;
 
 
 /* ----------
  * Local function prototypes
  * ----------
  */
-static int ri_DetermineMatchType(char *str);
-static int ri_NullCheck(Relation rel, HeapTuple tup, 
-							RI_QueryKey *key, int pairidx);
+static int	ri_DetermineMatchType(char *str);
+static int ri_NullCheck(Relation rel, HeapTuple tup,
+			 RI_QueryKey *key, int pairidx);
 static void ri_BuildQueryKeyFull(RI_QueryKey *key, Oid constr_id,
-							int32 constr_queryno,
-							Relation fk_rel, Relation pk_rel,
-							int argc, char **argv);
-static bool ri_KeysEqual(Relation rel, HeapTuple oldtup, HeapTuple newtup, 
-							RI_QueryKey *key, int pairidx);
-static bool ri_AllKeysUnequal(Relation rel, HeapTuple oldtup, HeapTuple newtup, 
-							RI_QueryKey *key, int pairidx);
+					 int32 constr_queryno,
+					 Relation fk_rel, Relation pk_rel,
+					 int argc, char **argv);
+static bool ri_KeysEqual(Relation rel, HeapTuple oldtup, HeapTuple newtup,
+			 RI_QueryKey *key, int pairidx);
+static bool ri_AllKeysUnequal(Relation rel, HeapTuple oldtup, HeapTuple newtup,
+				  RI_QueryKey *key, int pairidx);
 static bool ri_OneKeyEqual(Relation rel, int column, HeapTuple oldtup,
-							HeapTuple newtup, RI_QueryKey *key, int pairidx);
+			   HeapTuple newtup, RI_QueryKey *key, int pairidx);
 static bool ri_AttributesEqual(Oid typeid, Datum oldvalue, Datum newvalue);
 
 static void ri_InitHashTables(void);
@@ -148,24 +151,25 @@ static void ri_HashPreparedPlan(RI_QueryKey *key, void *plan);
  * ----------
  */
 static HeapTuple
-RI_FKey_check (FmgrInfo *proinfo)
+RI_FKey_check(FmgrInfo *proinfo)
 {
-	TriggerData		   *trigdata;
-	int					tgnargs;
-	char			  **tgargs;
-	Relation			fk_rel;
-	Relation			pk_rel;
-	HeapTuple			new_row;
-	HeapTuple			old_row;
-	RI_QueryKey			qkey;
-	void			   *qplan;
-	Datum				check_values[RI_MAX_NUMKEYS];
-	char				check_nulls[RI_MAX_NUMKEYS + 1];
-	bool				isnull;
-	int					i;
-	int					match_type;
+	TriggerData *trigdata;
+	int			tgnargs;
+	char	  **tgargs;
+	Relation	fk_rel;
+	Relation	pk_rel;
+	HeapTuple	new_row;
+	HeapTuple	old_row;
+	RI_QueryKey qkey;
+	void	   *qplan;
+	Datum		check_values[RI_MAX_NUMKEYS];
+	char		check_nulls[RI_MAX_NUMKEYS + 1];
+	bool		isnull;
+	int			i;
+	int			match_type;
+
 	trigdata = CurrentTriggerData;
-	CurrentTriggerData	= NULL;
+	CurrentTriggerData = NULL;
 	ReferentialIntegritySnapshotOverride = true;
 
 	/* ----------
@@ -174,37 +178,39 @@ RI_FKey_check (FmgrInfo *proinfo)
 	 */
 	if (trigdata == NULL)
 		elog(ERROR, "RI_FKey_check() not fired by trigger manager");
-	if (!TRIGGER_FIRED_AFTER(trigdata->tg_event) || 
-				!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
+	if (!TRIGGER_FIRED_AFTER(trigdata->tg_event) ||
+		!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
 		elog(ERROR, "RI_FKey_check() must be fired AFTER ROW");
 	if (!TRIGGER_FIRED_BY_INSERT(trigdata->tg_event) &&
-				!TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
+		!TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
 		elog(ERROR, "RI_FKey_check() must be fired for INSERT or UPDATE");
 
 	/* ----------
-	 * Check for the correct # of call arguments 
+	 * Check for the correct # of call arguments
 	 * ----------
 	 */
 	tgnargs = trigdata->tg_trigger->tgnargs;
-	tgargs  = trigdata->tg_trigger->tgargs;
+	tgargs = trigdata->tg_trigger->tgargs;
 	if (tgnargs < 4 || (tgnargs % 2) != 0)
 		elog(ERROR, "wrong # of arguments in call to RI_FKey_check()");
 	if (tgnargs > RI_MAX_ARGUMENTS)
 		elog(ERROR, "too many keys (%d max) in call to RI_FKey_check()",
-						RI_MAX_NUMKEYS);
+			 RI_MAX_NUMKEYS);
 
 	/* ----------
 	 * Get the relation descriptors of the FK and PK tables and
 	 * the new tuple.
 	 * ----------
 	 */
-	fk_rel  = trigdata->tg_relation;
-	pk_rel	= heap_openr(tgargs[RI_PK_RELNAME_ARGNO], NoLock);
+	fk_rel = trigdata->tg_relation;
+	pk_rel = heap_openr(tgargs[RI_PK_RELNAME_ARGNO], NoLock);
 	if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
 	{
 		old_row = trigdata->tg_trigtuple;
 		new_row = trigdata->tg_newtuple;
-	} else {
+	}
+	else
+	{
 		old_row = NULL;
 		new_row = trigdata->tg_trigtuple;
 	}
@@ -220,11 +226,12 @@ RI_FKey_check (FmgrInfo *proinfo)
 	 *		future enhancements.
 	 * ----------
 	 */
-	if (tgnargs == 4) {
+	if (tgnargs == 4)
+	{
 		ri_BuildQueryKeyFull(&qkey, trigdata->tg_trigger->tgoid,
-								RI_PLAN_CHECK_LOOKUPPK_NOCOLS,
-								fk_rel, pk_rel,
-								tgnargs, tgargs);
+							 RI_PLAN_CHECK_LOOKUPPK_NOCOLS,
+							 fk_rel, pk_rel,
+							 tgnargs, tgargs);
 
 		if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
 		{
@@ -235,9 +242,9 @@ RI_FKey_check (FmgrInfo *proinfo)
 			 *	SELECT oid FROM <pktable>
 			 * ----------
 			 */
-			sprintf(querystr, "SELECT oid FROM \"%s\" FOR UPDATE OF \"%s\"", 
-								tgargs[RI_PK_RELNAME_ARGNO],
-								tgargs[RI_PK_RELNAME_ARGNO]);
+			sprintf(querystr, "SELECT oid FROM \"%s\" FOR UPDATE OF \"%s\"",
+					tgargs[RI_PK_RELNAME_ARGNO],
+					tgargs[RI_PK_RELNAME_ARGNO]);
 
 			/* ----------
 			 * Prepare, save and remember the new plan.
@@ -258,12 +265,12 @@ RI_FKey_check (FmgrInfo *proinfo)
 
 		if (SPI_execp(qplan, check_values, check_nulls, 1) != SPI_OK_SELECT)
 			elog(ERROR, "SPI_execp() failed in RI_FKey_check()");
-		
+
 		if (SPI_processed == 0)
 			elog(ERROR, "%s referential integrity violation - "
-						"no rows found in %s",
-					tgargs[RI_CONSTRAINT_NAME_ARGNO],
-					tgargs[RI_PK_RELNAME_ARGNO]);
+				 "no rows found in %s",
+				 tgargs[RI_CONSTRAINT_NAME_ARGNO],
+				 tgargs[RI_PK_RELNAME_ARGNO]);
 
 		if (SPI_finish() != SPI_OK_FINISH)
 			elog(NOTICE, "SPI_finish() failed in RI_FKey_check()");
@@ -281,8 +288,8 @@ RI_FKey_check (FmgrInfo *proinfo)
 	}
 
 	ri_BuildQueryKeyFull(&qkey, trigdata->tg_trigger->tgoid,
-							RI_PLAN_CHECK_LOOKUPPK, fk_rel, pk_rel,
-							tgnargs, tgargs);
+						 RI_PLAN_CHECK_LOOKUPPK, fk_rel, pk_rel,
+						 tgnargs, tgargs);
 
 	switch (ri_NullCheck(fk_rel, new_row, &qkey, RI_KEYPAIR_FK_IDX))
 	{
@@ -290,32 +297,32 @@ RI_FKey_check (FmgrInfo *proinfo)
 			/* ----------
 			 * No check - if NULLs are allowed at all is
 			 * already checked by NOT NULL constraint.
-             *
-             * This is true for MATCH FULL, MATCH PARTIAL, and
-             * MATCH <unspecified>
+			 *
+			 * This is true for MATCH FULL, MATCH PARTIAL, and
+			 * MATCH <unspecified>
 			 * ----------
 			 */
 			heap_close(pk_rel, NoLock);
 			return NULL;
-					
+
 		case RI_KEYS_SOME_NULL:
 			/* ----------
 			 * This is the only case that differs between the
-             * three kinds of MATCH.
+			 * three kinds of MATCH.
 			 * ----------
 			 */
 			switch (match_type)
 			{
 				case RI_MATCH_TYPE_FULL:
 					/* ----------
-				 	 * Not allowed - MATCH FULL says either all or none
+					 * Not allowed - MATCH FULL says either all or none
 					 * of the attributes can be NULLs
 					 * ----------
 					 */
 					elog(ERROR, "%s referential integrity violation - "
-							"MATCH FULL doesn't allow mixing of NULL "
-							"and NON-NULL key values",
-							tgargs[RI_CONSTRAINT_NAME_ARGNO]);
+						 "MATCH FULL doesn't allow mixing of NULL "
+						 "and NON-NULL key values",
+						 tgargs[RI_CONSTRAINT_NAME_ARGNO]);
 					heap_close(pk_rel, NoLock);
 					return NULL;
 
@@ -332,8 +339,8 @@ RI_FKey_check (FmgrInfo *proinfo)
 					/* ----------
 					 * MATCH PARTIAL - all non-null columns must match.
 					 * (not implemented, can be done by modifying the query
-                 	 * below to only include non-null columns, or by
-                     * writing a special version here)
+					 * below to only include non-null columns, or by
+					 * writing a special version here)
 					 * ----------
 					 */
 					elog(ERROR, "MATCH PARTIAL not yet implemented");
@@ -344,7 +351,7 @@ RI_FKey_check (FmgrInfo *proinfo)
 		case RI_KEYS_NONE_NULL:
 			/* ----------
 			 * Have a full qualified key - continue below for all three
-             * kinds of MATCH.
+			 * kinds of MATCH.
 			 * ----------
 			 */
 			break;
@@ -372,7 +379,7 @@ RI_FKey_check (FmgrInfo *proinfo)
 	{
 		char		buf[256];
 		char		querystr[8192];
-		char		*querysep;
+		char	   *querysep;
 		Oid			queryoids[RI_MAX_NUMKEYS];
 
 		/* ----------
@@ -384,20 +391,20 @@ RI_FKey_check (FmgrInfo *proinfo)
 		 * how to compare these two types by '='.
 		 * ----------
 		 */
-		sprintf(querystr, "SELECT oid FROM \"%s\"", 
-							tgargs[RI_PK_RELNAME_ARGNO]);
+		sprintf(querystr, "SELECT oid FROM \"%s\"",
+				tgargs[RI_PK_RELNAME_ARGNO]);
 		querysep = "WHERE";
 		for (i = 0; i < qkey.nkeypairs; i++)
 		{
-			sprintf(buf, " %s \"%s\" = $%d", querysep, 
-								tgargs[5 + i * 2], i + 1);
+			sprintf(buf, " %s \"%s\" = $%d", querysep,
+					tgargs[5 + i * 2], i + 1);
 			strcat(querystr, buf);
 			querysep = "AND";
 			queryoids[i] = SPI_gettypeid(fk_rel->rd_att,
-							qkey.keypair[i][RI_KEYPAIR_FK_IDX]);
+									 qkey.keypair[i][RI_KEYPAIR_FK_IDX]);
 		}
 		sprintf(buf, " FOR UPDATE OF \"%s\"",
-							tgargs[RI_PK_RELNAME_ARGNO]);
+				tgargs[RI_PK_RELNAME_ARGNO]);
 		strcat(querystr, buf);
 
 		/* ----------
@@ -418,17 +425,17 @@ RI_FKey_check (FmgrInfo *proinfo)
 	{
 		/* ----------
 		 * We can implement MATCH PARTIAL by excluding this column from
-         * the query if it is null.  Simple!  Unfortunately, the
-         * referential actions aren't so I've not bothered to do so
-         * for the moment.
+		 * the query if it is null.  Simple!  Unfortunately, the
+		 * referential actions aren't so I've not bothered to do so
+		 * for the moment.
 		 * ----------
 		 */
-       
+
 		check_values[i] = SPI_getbinval(new_row,
-							fk_rel->rd_att,
-							qkey.keypair[i][RI_KEYPAIR_FK_IDX],
-							&isnull);
-		if (isnull) 
+										fk_rel->rd_att,
+									  qkey.keypair[i][RI_KEYPAIR_FK_IDX],
+										&isnull);
+		if (isnull)
 			check_nulls[i] = 'n';
 		else
 			check_nulls[i] = ' ';
@@ -441,13 +448,13 @@ RI_FKey_check (FmgrInfo *proinfo)
 	 */
 	if (SPI_execp(qplan, check_values, check_nulls, 1) != SPI_OK_SELECT)
 		elog(ERROR, "SPI_execp() failed in RI_FKey_check()");
-	
+
 	if (SPI_processed == 0)
 		elog(ERROR, "%s referential integrity violation - "
-					"key referenced from %s not found in %s",
-					tgargs[RI_CONSTRAINT_NAME_ARGNO],
-					tgargs[RI_FK_RELNAME_ARGNO],
-					tgargs[RI_PK_RELNAME_ARGNO]);
+			 "key referenced from %s not found in %s",
+			 tgargs[RI_CONSTRAINT_NAME_ARGNO],
+			 tgargs[RI_FK_RELNAME_ARGNO],
+			 tgargs[RI_PK_RELNAME_ARGNO]);
 
 	if (SPI_finish() != SPI_OK_FINISH)
 		elog(NOTICE, "SPI_finish() failed in RI_FKey_check()");
@@ -470,7 +477,7 @@ RI_FKey_check (FmgrInfo *proinfo)
  * ----------
  */
 HeapTuple
-RI_FKey_check_ins (FmgrInfo *proinfo)
+RI_FKey_check_ins(FmgrInfo *proinfo)
 {
 	return RI_FKey_check(proinfo);
 }
@@ -483,7 +490,7 @@ RI_FKey_check_ins (FmgrInfo *proinfo)
  * ----------
  */
 HeapTuple
-RI_FKey_check_upd (FmgrInfo *proinfo)
+RI_FKey_check_upd(FmgrInfo *proinfo)
 {
 	return RI_FKey_check(proinfo);
 }
@@ -493,28 +500,28 @@ RI_FKey_check_upd (FmgrInfo *proinfo)
  * RI_FKey_noaction_del -
  *
  *	Give an error and roll back the current transaction if the
- *  delete has resulted in a violation of the given referential
- *  integrity constraint.
+ *	delete has resulted in a violation of the given referential
+ *	integrity constraint.
  * ----------
  */
 HeapTuple
-RI_FKey_noaction_del (FmgrInfo *proinfo)
+RI_FKey_noaction_del(FmgrInfo *proinfo)
 {
-	TriggerData		   *trigdata;
-	int					tgnargs;
-	char			  **tgargs;
-	Relation			fk_rel;
-	Relation			pk_rel;
-	HeapTuple			old_row;
-	RI_QueryKey			qkey;
-	void			   *qplan;
-	Datum				del_values[RI_MAX_NUMKEYS];
-	char				del_nulls[RI_MAX_NUMKEYS + 1];
-	bool				isnull;
-	int					i;
+	TriggerData *trigdata;
+	int			tgnargs;
+	char	  **tgargs;
+	Relation	fk_rel;
+	Relation	pk_rel;
+	HeapTuple	old_row;
+	RI_QueryKey qkey;
+	void	   *qplan;
+	Datum		del_values[RI_MAX_NUMKEYS];
+	char		del_nulls[RI_MAX_NUMKEYS + 1];
+	bool		isnull;
+	int			i;
 
 	trigdata = CurrentTriggerData;
-	CurrentTriggerData	= NULL;
+	CurrentTriggerData = NULL;
 	ReferentialIntegritySnapshotOverride = true;
 
 	/* ----------
@@ -523,23 +530,23 @@ RI_FKey_noaction_del (FmgrInfo *proinfo)
 	 */
 	if (trigdata == NULL)
 		elog(ERROR, "RI_FKey_noaction_del() not fired by trigger manager");
-	if (!TRIGGER_FIRED_AFTER(trigdata->tg_event) || 
-				!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
+	if (!TRIGGER_FIRED_AFTER(trigdata->tg_event) ||
+		!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
 		elog(ERROR, "RI_FKey_noaction_del() must be fired AFTER ROW");
 	if (!TRIGGER_FIRED_BY_DELETE(trigdata->tg_event))
 		elog(ERROR, "RI_FKey_noaction_del() must be fired for DELETE");
 
 	/* ----------
-	 * Check for the correct # of call arguments 
+	 * Check for the correct # of call arguments
 	 * ----------
 	 */
 	tgnargs = trigdata->tg_trigger->tgnargs;
-	tgargs  = trigdata->tg_trigger->tgargs;
+	tgargs = trigdata->tg_trigger->tgargs;
 	if (tgnargs < 4 || (tgnargs % 2) != 0)
 		elog(ERROR, "wrong # of arguments in call to RI_FKey_noaction_del()");
 	if (tgnargs > RI_MAX_ARGUMENTS)
 		elog(ERROR, "too many keys (%d max) in call to RI_FKey_noaction_del()",
-						RI_MAX_NUMKEYS);
+			 RI_MAX_NUMKEYS);
 
 	/* ----------
 	 * Nothing to do if no column names to compare given
@@ -553,25 +560,25 @@ RI_FKey_noaction_del (FmgrInfo *proinfo)
 	 * the old tuple.
 	 * ----------
 	 */
-	fk_rel	= heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
-	pk_rel  = trigdata->tg_relation;
+	fk_rel = heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
+	pk_rel = trigdata->tg_relation;
 	old_row = trigdata->tg_trigtuple;
 
 	switch (ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO]))
 	{
-		/* ----------
-		 * SQL3 11.9 <referential constraint definition>
-		 *	Gereral rules 6) a) iv):
-		 * 		MATCH <unspecified> or MATCH FULL
-		 *			... ON DELETE CASCADE
-		 * ----------
-		 */
+			/* ----------
+			 * SQL3 11.9 <referential constraint definition>
+			 *	Gereral rules 6) a) iv):
+			 *		MATCH <unspecified> or MATCH FULL
+			 *			... ON DELETE CASCADE
+			 * ----------
+			 */
 		case RI_MATCH_TYPE_UNSPECIFIED:
 		case RI_MATCH_TYPE_FULL:
 			ri_BuildQueryKeyFull(&qkey, trigdata->tg_trigger->tgoid,
-									RI_PLAN_NOACTION_DEL_CHECKREF,
-									fk_rel, pk_rel,
-									tgnargs, tgargs);
+								 RI_PLAN_NOACTION_DEL_CHECKREF,
+								 fk_rel, pk_rel,
+								 tgnargs, tgargs);
 
 			switch (ri_NullCheck(pk_rel, old_row, &qkey, RI_KEYPAIR_PK_IDX))
 			{
@@ -584,7 +591,7 @@ RI_FKey_noaction_del (FmgrInfo *proinfo)
 					 */
 					heap_close(fk_rel, NoLock);
 					return NULL;
-					
+
 				case RI_KEYS_NONE_NULL:
 					/* ----------
 					 * Have a full qualified key - continue below
@@ -606,7 +613,7 @@ RI_FKey_noaction_del (FmgrInfo *proinfo)
 			{
 				char		buf[256];
 				char		querystr[8192];
-				char		*querysep;
+				char	   *querysep;
 				Oid			queryoids[RI_MAX_NUMKEYS];
 
 				/* ----------
@@ -618,20 +625,20 @@ RI_FKey_noaction_del (FmgrInfo *proinfo)
 				 * how to compare these two types by '='.
 				 * ----------
 				 */
-				sprintf(querystr, "SELECT oid FROM \"%s\"", 
-									tgargs[RI_FK_RELNAME_ARGNO]);
+				sprintf(querystr, "SELECT oid FROM \"%s\"",
+						tgargs[RI_FK_RELNAME_ARGNO]);
 				querysep = "WHERE";
 				for (i = 0; i < qkey.nkeypairs; i++)
 				{
-					sprintf(buf, " %s \"%s\" = $%d", querysep, 
-										tgargs[4 + i * 2], i + 1);
+					sprintf(buf, " %s \"%s\" = $%d", querysep,
+							tgargs[4 + i * 2], i + 1);
 					strcat(querystr, buf);
 					querysep = "AND";
 					queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
-									qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
+									 qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
 				}
-				sprintf(buf, " FOR UPDATE OF \"%s\"", 
-									tgargs[RI_FK_RELNAME_ARGNO]);
+				sprintf(buf, " FOR UPDATE OF \"%s\"",
+						tgargs[RI_FK_RELNAME_ARGNO]);
 				strcat(querystr, buf);
 
 				/* ----------
@@ -651,10 +658,10 @@ RI_FKey_noaction_del (FmgrInfo *proinfo)
 			for (i = 0; i < qkey.nkeypairs; i++)
 			{
 				del_values[i] = SPI_getbinval(old_row,
-									pk_rel->rd_att,
-									qkey.keypair[i][RI_KEYPAIR_PK_IDX],
-									&isnull);
-				if (isnull) 
+											  pk_rel->rd_att,
+									  qkey.keypair[i][RI_KEYPAIR_PK_IDX],
+											  &isnull);
+				if (isnull)
 					del_nulls[i] = 'n';
 				else
 					del_nulls[i] = ' ';
@@ -667,23 +674,23 @@ RI_FKey_noaction_del (FmgrInfo *proinfo)
 			 */
 			if (SPI_execp(qplan, del_values, del_nulls, 1) != SPI_OK_SELECT)
 				elog(ERROR, "SPI_execp() failed in RI_FKey_noaction_del()");
-			
+
 			if (SPI_processed > 0)
 				elog(ERROR, "%s referential integrity violation - "
-							"key in %s still referenced from %s",
-						tgargs[RI_CONSTRAINT_NAME_ARGNO],
-						tgargs[RI_PK_RELNAME_ARGNO],
-						tgargs[RI_FK_RELNAME_ARGNO]);
+					 "key in %s still referenced from %s",
+					 tgargs[RI_CONSTRAINT_NAME_ARGNO],
+					 tgargs[RI_PK_RELNAME_ARGNO],
+					 tgargs[RI_FK_RELNAME_ARGNO]);
 
 			if (SPI_finish() != SPI_OK_FINISH)
 				elog(NOTICE, "SPI_finish() failed in RI_FKey_noaction_del()");
 
 			return NULL;
 
-		/* ----------
-		 * Handle MATCH PARTIAL restrict delete.
-		 * ----------
-		 */
+			/* ----------
+			 * Handle MATCH PARTIAL restrict delete.
+			 * ----------
+			 */
 		case RI_MATCH_TYPE_PARTIAL:
 			elog(ERROR, "MATCH PARTIAL not yet supported");
 			return NULL;
@@ -702,29 +709,29 @@ RI_FKey_noaction_del (FmgrInfo *proinfo)
  * RI_FKey_noaction_upd -
  *
  *	Give an error and roll back the current transaction if the
- *  update has resulted in a violation of the given referential
- *  integrity constraint.
+ *	update has resulted in a violation of the given referential
+ *	integrity constraint.
  * ----------
  */
 HeapTuple
-RI_FKey_noaction_upd (FmgrInfo *proinfo)
+RI_FKey_noaction_upd(FmgrInfo *proinfo)
 {
-	TriggerData		   *trigdata;
-	int					tgnargs;
-	char			  **tgargs;
-	Relation			fk_rel;
-	Relation			pk_rel;
-	HeapTuple			new_row;
-	HeapTuple			old_row;
-	RI_QueryKey			qkey;
-	void			   *qplan;
-	Datum				upd_values[RI_MAX_NUMKEYS];
-	char				upd_nulls[RI_MAX_NUMKEYS + 1];
-	bool				isnull;
-	int					i;
+	TriggerData *trigdata;
+	int			tgnargs;
+	char	  **tgargs;
+	Relation	fk_rel;
+	Relation	pk_rel;
+	HeapTuple	new_row;
+	HeapTuple	old_row;
+	RI_QueryKey qkey;
+	void	   *qplan;
+	Datum		upd_values[RI_MAX_NUMKEYS];
+	char		upd_nulls[RI_MAX_NUMKEYS + 1];
+	bool		isnull;
+	int			i;
 
 	trigdata = CurrentTriggerData;
-	CurrentTriggerData	= NULL;
+	CurrentTriggerData = NULL;
 	ReferentialIntegritySnapshotOverride = true;
 
 	/* ----------
@@ -733,23 +740,23 @@ RI_FKey_noaction_upd (FmgrInfo *proinfo)
 	 */
 	if (trigdata == NULL)
 		elog(ERROR, "RI_FKey_noaction_upd() not fired by trigger manager");
-	if (!TRIGGER_FIRED_AFTER(trigdata->tg_event) || 
-				!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
+	if (!TRIGGER_FIRED_AFTER(trigdata->tg_event) ||
+		!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
 		elog(ERROR, "RI_FKey_noaction_upd() must be fired AFTER ROW");
 	if (!TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
 		elog(ERROR, "RI_FKey_noaction_upd() must be fired for UPDATE");
 
 	/* ----------
-	 * Check for the correct # of call arguments 
+	 * Check for the correct # of call arguments
 	 * ----------
 	 */
 	tgnargs = trigdata->tg_trigger->tgnargs;
-	tgargs  = trigdata->tg_trigger->tgargs;
+	tgargs = trigdata->tg_trigger->tgargs;
 	if (tgnargs < 4 || (tgnargs % 2) != 0)
 		elog(ERROR, "wrong # of arguments in call to RI_FKey_noaction_upd()");
 	if (tgnargs > RI_MAX_ARGUMENTS)
 		elog(ERROR, "too many keys (%d max) in call to RI_FKey_noaction_upd()",
-						RI_MAX_NUMKEYS);
+			 RI_MAX_NUMKEYS);
 
 	/* ----------
 	 * Nothing to do if no column names to compare given
@@ -763,26 +770,26 @@ RI_FKey_noaction_upd (FmgrInfo *proinfo)
 	 * the new and old tuple.
 	 * ----------
 	 */
-	fk_rel	= heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
-	pk_rel  = trigdata->tg_relation;
+	fk_rel = heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
+	pk_rel = trigdata->tg_relation;
 	new_row = trigdata->tg_newtuple;
 	old_row = trigdata->tg_trigtuple;
 
 	switch (ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO]))
 	{
-		/* ----------
-		 * SQL3 11.9 <referential constraint definition>
-		 *	Gereral rules 6) a) iv):
-		 * 		MATCH <unspecified> or MATCH FULL
-		 *			... ON DELETE CASCADE
-		 * ----------
-		 */
+			/* ----------
+			 * SQL3 11.9 <referential constraint definition>
+			 *	Gereral rules 6) a) iv):
+			 *		MATCH <unspecified> or MATCH FULL
+			 *			... ON DELETE CASCADE
+			 * ----------
+			 */
 		case RI_MATCH_TYPE_UNSPECIFIED:
 		case RI_MATCH_TYPE_FULL:
 			ri_BuildQueryKeyFull(&qkey, trigdata->tg_trigger->tgoid,
-									RI_PLAN_NOACTION_UPD_CHECKREF,
-									fk_rel, pk_rel,
-									tgnargs, tgargs);
+								 RI_PLAN_NOACTION_UPD_CHECKREF,
+								 fk_rel, pk_rel,
+								 tgnargs, tgargs);
 
 			switch (ri_NullCheck(pk_rel, old_row, &qkey, RI_KEYPAIR_PK_IDX))
 			{
@@ -795,7 +802,7 @@ RI_FKey_noaction_upd (FmgrInfo *proinfo)
 					 */
 					heap_close(fk_rel, NoLock);
 					return NULL;
-					
+
 				case RI_KEYS_NONE_NULL:
 					/* ----------
 					 * Have a full qualified key - continue below
@@ -810,7 +817,7 @@ RI_FKey_noaction_upd (FmgrInfo *proinfo)
 			 * ----------
 			 */
 			if (ri_KeysEqual(pk_rel, old_row, new_row, &qkey,
-													RI_KEYPAIR_PK_IDX))
+							 RI_KEYPAIR_PK_IDX))
 				return NULL;
 
 			if (SPI_connect() != SPI_OK_CONNECT)
@@ -825,7 +832,7 @@ RI_FKey_noaction_upd (FmgrInfo *proinfo)
 			{
 				char		buf[256];
 				char		querystr[8192];
-				char		*querysep;
+				char	   *querysep;
 				Oid			queryoids[RI_MAX_NUMKEYS];
 
 				/* ----------
@@ -837,20 +844,20 @@ RI_FKey_noaction_upd (FmgrInfo *proinfo)
 				 * how to compare these two types by '='.
 				 * ----------
 				 */
-				sprintf(querystr, "SELECT oid FROM \"%s\"", 
-									tgargs[RI_FK_RELNAME_ARGNO]);
+				sprintf(querystr, "SELECT oid FROM \"%s\"",
+						tgargs[RI_FK_RELNAME_ARGNO]);
 				querysep = "WHERE";
 				for (i = 0; i < qkey.nkeypairs; i++)
 				{
-					sprintf(buf, " %s \"%s\" = $%d", querysep, 
-										tgargs[4 + i * 2], i + 1);
+					sprintf(buf, " %s \"%s\" = $%d", querysep,
+							tgargs[4 + i * 2], i + 1);
 					strcat(querystr, buf);
 					querysep = "AND";
 					queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
-									qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
+									 qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
 				}
-				sprintf(buf, " FOR UPDATE OF \"%s\"", 
-									tgargs[RI_FK_RELNAME_ARGNO]);
+				sprintf(buf, " FOR UPDATE OF \"%s\"",
+						tgargs[RI_FK_RELNAME_ARGNO]);
 				strcat(querystr, buf);
 
 				/* ----------
@@ -870,10 +877,10 @@ RI_FKey_noaction_upd (FmgrInfo *proinfo)
 			for (i = 0; i < qkey.nkeypairs; i++)
 			{
 				upd_values[i] = SPI_getbinval(old_row,
-									pk_rel->rd_att,
-									qkey.keypair[i][RI_KEYPAIR_PK_IDX],
-									&isnull);
-				if (isnull) 
+											  pk_rel->rd_att,
+									  qkey.keypair[i][RI_KEYPAIR_PK_IDX],
+											  &isnull);
+				if (isnull)
 					upd_nulls[i] = 'n';
 				else
 					upd_nulls[i] = ' ';
@@ -886,23 +893,23 @@ RI_FKey_noaction_upd (FmgrInfo *proinfo)
 			 */
 			if (SPI_execp(qplan, upd_values, upd_nulls, 1) != SPI_OK_SELECT)
 				elog(ERROR, "SPI_execp() failed in RI_FKey_noaction_upd()");
-			
+
 			if (SPI_processed > 0)
 				elog(ERROR, "%s referential integrity violation - "
-							"key in %s still referenced from %s",
-						tgargs[RI_CONSTRAINT_NAME_ARGNO],
-						tgargs[RI_PK_RELNAME_ARGNO],
-						tgargs[RI_FK_RELNAME_ARGNO]);
+					 "key in %s still referenced from %s",
+					 tgargs[RI_CONSTRAINT_NAME_ARGNO],
+					 tgargs[RI_PK_RELNAME_ARGNO],
+					 tgargs[RI_FK_RELNAME_ARGNO]);
 
 			if (SPI_finish() != SPI_OK_FINISH)
 				elog(NOTICE, "SPI_finish() failed in RI_FKey_noaction_upd()");
 
 			return NULL;
 
-		/* ----------
-		 * Handle MATCH PARTIAL noaction update.
-		 * ----------
-		 */
+			/* ----------
+			 * Handle MATCH PARTIAL noaction update.
+			 * ----------
+			 */
 		case RI_MATCH_TYPE_PARTIAL:
 			elog(ERROR, "MATCH PARTIAL not yet supported");
 			return NULL;
@@ -924,23 +931,23 @@ RI_FKey_noaction_upd (FmgrInfo *proinfo)
  * ----------
  */
 HeapTuple
-RI_FKey_cascade_del (FmgrInfo *proinfo)
+RI_FKey_cascade_del(FmgrInfo *proinfo)
 {
-	TriggerData		   *trigdata;
-	int					tgnargs;
-	char			  **tgargs;
-	Relation			fk_rel;
-	Relation			pk_rel;
-	HeapTuple			old_row;
-	RI_QueryKey			qkey;
-	void			   *qplan;
-	Datum				del_values[RI_MAX_NUMKEYS];
-	char				del_nulls[RI_MAX_NUMKEYS + 1];
-	bool				isnull;
-	int					i;
+	TriggerData *trigdata;
+	int			tgnargs;
+	char	  **tgargs;
+	Relation	fk_rel;
+	Relation	pk_rel;
+	HeapTuple	old_row;
+	RI_QueryKey qkey;
+	void	   *qplan;
+	Datum		del_values[RI_MAX_NUMKEYS];
+	char		del_nulls[RI_MAX_NUMKEYS + 1];
+	bool		isnull;
+	int			i;
 
 	trigdata = CurrentTriggerData;
-	CurrentTriggerData	= NULL;
+	CurrentTriggerData = NULL;
 	ReferentialIntegritySnapshotOverride = true;
 
 	/* ----------
@@ -949,23 +956,23 @@ RI_FKey_cascade_del (FmgrInfo *proinfo)
 	 */
 	if (trigdata == NULL)
 		elog(ERROR, "RI_FKey_cascade_del() not fired by trigger manager");
-	if (!TRIGGER_FIRED_AFTER(trigdata->tg_event) || 
-				!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
+	if (!TRIGGER_FIRED_AFTER(trigdata->tg_event) ||
+		!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
 		elog(ERROR, "RI_FKey_cascade_del() must be fired AFTER ROW");
 	if (!TRIGGER_FIRED_BY_DELETE(trigdata->tg_event))
 		elog(ERROR, "RI_FKey_cascade_del() must be fired for DELETE");
 
 	/* ----------
-	 * Check for the correct # of call arguments 
+	 * Check for the correct # of call arguments
 	 * ----------
 	 */
 	tgnargs = trigdata->tg_trigger->tgnargs;
-	tgargs  = trigdata->tg_trigger->tgargs;
+	tgargs = trigdata->tg_trigger->tgargs;
 	if (tgnargs < 4 || (tgnargs % 2) != 0)
 		elog(ERROR, "wrong # of arguments in call to RI_FKey_cascade_del()");
 	if (tgnargs > RI_MAX_ARGUMENTS)
 		elog(ERROR, "too many keys (%d max) in call to RI_FKey_cascade_del()",
-						RI_MAX_NUMKEYS);
+			 RI_MAX_NUMKEYS);
 
 	/* ----------
 	 * Nothing to do if no column names to compare given
@@ -979,25 +986,25 @@ RI_FKey_cascade_del (FmgrInfo *proinfo)
 	 * the old tuple.
 	 * ----------
 	 */
-	fk_rel	= heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
-	pk_rel  = trigdata->tg_relation;
+	fk_rel = heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
+	pk_rel = trigdata->tg_relation;
 	old_row = trigdata->tg_trigtuple;
 
 	switch (ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO]))
 	{
-		/* ----------
-		 * SQL3 11.9 <referential constraint definition>
-		 *	Gereral rules 6) a) i):
-		 * 		MATCH <unspecified> or MATCH FULL
-		 *			... ON DELETE CASCADE
-		 * ----------
-		 */
+			/* ----------
+			 * SQL3 11.9 <referential constraint definition>
+			 *	Gereral rules 6) a) i):
+			 *		MATCH <unspecified> or MATCH FULL
+			 *			... ON DELETE CASCADE
+			 * ----------
+			 */
 		case RI_MATCH_TYPE_UNSPECIFIED:
 		case RI_MATCH_TYPE_FULL:
 			ri_BuildQueryKeyFull(&qkey, trigdata->tg_trigger->tgoid,
-									RI_PLAN_CASCADE_DEL_DODELETE,
-									fk_rel, pk_rel,
-									tgnargs, tgargs);
+								 RI_PLAN_CASCADE_DEL_DODELETE,
+								 fk_rel, pk_rel,
+								 tgnargs, tgargs);
 
 			switch (ri_NullCheck(pk_rel, old_row, &qkey, RI_KEYPAIR_PK_IDX))
 			{
@@ -1010,7 +1017,7 @@ RI_FKey_cascade_del (FmgrInfo *proinfo)
 					 */
 					heap_close(fk_rel, NoLock);
 					return NULL;
-					
+
 				case RI_KEYS_NONE_NULL:
 					/* ----------
 					 * Have a full qualified key - continue below
@@ -1031,7 +1038,7 @@ RI_FKey_cascade_del (FmgrInfo *proinfo)
 			{
 				char		buf[256];
 				char		querystr[8192];
-				char		*querysep;
+				char	   *querysep;
 				Oid			queryoids[RI_MAX_NUMKEYS];
 
 				/* ----------
@@ -1043,17 +1050,17 @@ RI_FKey_cascade_del (FmgrInfo *proinfo)
 				 * how to compare these two types by '='.
 				 * ----------
 				 */
-				sprintf(querystr, "DELETE FROM \"%s\"", 
-									tgargs[RI_FK_RELNAME_ARGNO]);
+				sprintf(querystr, "DELETE FROM \"%s\"",
+						tgargs[RI_FK_RELNAME_ARGNO]);
 				querysep = "WHERE";
 				for (i = 0; i < qkey.nkeypairs; i++)
 				{
-					sprintf(buf, " %s \"%s\" = $%d", querysep, 
-										tgargs[4 + i * 2], i + 1);
+					sprintf(buf, " %s \"%s\" = $%d", querysep,
+							tgargs[4 + i * 2], i + 1);
 					strcat(querystr, buf);
 					querysep = "AND";
 					queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
-									qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
+									 qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
 				}
 
 				/* ----------
@@ -1073,10 +1080,10 @@ RI_FKey_cascade_del (FmgrInfo *proinfo)
 			for (i = 0; i < qkey.nkeypairs; i++)
 			{
 				del_values[i] = SPI_getbinval(old_row,
-									pk_rel->rd_att,
-									qkey.keypair[i][RI_KEYPAIR_PK_IDX],
-									&isnull);
-				if (isnull) 
+											  pk_rel->rd_att,
+									  qkey.keypair[i][RI_KEYPAIR_PK_IDX],
+											  &isnull);
+				if (isnull)
 					del_nulls[i] = 'n';
 				else
 					del_nulls[i] = ' ';
@@ -1089,16 +1096,16 @@ RI_FKey_cascade_del (FmgrInfo *proinfo)
 			 */
 			if (SPI_execp(qplan, del_values, del_nulls, 0) != SPI_OK_DELETE)
 				elog(ERROR, "SPI_execp() failed in RI_FKey_cascade_del()");
-			
+
 			if (SPI_finish() != SPI_OK_FINISH)
 				elog(NOTICE, "SPI_finish() failed in RI_FKey_cascade_del()");
 
 			return NULL;
 
-		/* ----------
-		 * Handle MATCH PARTIAL cascaded delete.
-		 * ----------
-		 */
+			/* ----------
+			 * Handle MATCH PARTIAL cascaded delete.
+			 * ----------
+			 */
 		case RI_MATCH_TYPE_PARTIAL:
 			elog(ERROR, "MATCH PARTIAL not yet supported");
 			return NULL;
@@ -1120,25 +1127,25 @@ RI_FKey_cascade_del (FmgrInfo *proinfo)
  * ----------
  */
 HeapTuple
-RI_FKey_cascade_upd (FmgrInfo *proinfo)
+RI_FKey_cascade_upd(FmgrInfo *proinfo)
 {
-	TriggerData		   *trigdata;
-	int					tgnargs;
-	char			  **tgargs;
-	Relation			fk_rel;
-	Relation			pk_rel;
-	HeapTuple			new_row;
-	HeapTuple			old_row;
-	RI_QueryKey			qkey;
-	void			   *qplan;
-	Datum				upd_values[RI_MAX_NUMKEYS * 2];
-	char				upd_nulls[RI_MAX_NUMKEYS * 2 + 1];
-	bool				isnull;
-	int					i;
-	int					j;
+	TriggerData *trigdata;
+	int			tgnargs;
+	char	  **tgargs;
+	Relation	fk_rel;
+	Relation	pk_rel;
+	HeapTuple	new_row;
+	HeapTuple	old_row;
+	RI_QueryKey qkey;
+	void	   *qplan;
+	Datum		upd_values[RI_MAX_NUMKEYS * 2];
+	char		upd_nulls[RI_MAX_NUMKEYS * 2 + 1];
+	bool		isnull;
+	int			i;
+	int			j;
 
 	trigdata = CurrentTriggerData;
-	CurrentTriggerData	= NULL;
+	CurrentTriggerData = NULL;
 	ReferentialIntegritySnapshotOverride = true;
 
 	/* ----------
@@ -1147,23 +1154,23 @@ RI_FKey_cascade_upd (FmgrInfo *proinfo)
 	 */
 	if (trigdata == NULL)
 		elog(ERROR, "RI_FKey_cascade_upd() not fired by trigger manager");
-	if (!TRIGGER_FIRED_AFTER(trigdata->tg_event) || 
-				!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
+	if (!TRIGGER_FIRED_AFTER(trigdata->tg_event) ||
+		!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
 		elog(ERROR, "RI_FKey_cascade_upd() must be fired AFTER ROW");
 	if (!TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
 		elog(ERROR, "RI_FKey_cascade_upd() must be fired for UPDATE");
 
 	/* ----------
-	 * Check for the correct # of call arguments 
+	 * Check for the correct # of call arguments
 	 * ----------
 	 */
 	tgnargs = trigdata->tg_trigger->tgnargs;
-	tgargs  = trigdata->tg_trigger->tgargs;
+	tgargs = trigdata->tg_trigger->tgargs;
 	if (tgnargs < 4 || (tgnargs % 2) != 0)
 		elog(ERROR, "wrong # of arguments in call to RI_FKey_cascade_upd()");
 	if (tgnargs > RI_MAX_ARGUMENTS)
 		elog(ERROR, "too many keys (%d max) in call to RI_FKey_cascade_upd()",
-						RI_MAX_NUMKEYS);
+			 RI_MAX_NUMKEYS);
 
 	/* ----------
 	 * Nothing to do if no column names to compare given
@@ -1177,26 +1184,26 @@ RI_FKey_cascade_upd (FmgrInfo *proinfo)
 	 * the new and old tuple.
 	 * ----------
 	 */
-	fk_rel	= heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
-	pk_rel  = trigdata->tg_relation;
+	fk_rel = heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
+	pk_rel = trigdata->tg_relation;
 	new_row = trigdata->tg_newtuple;
 	old_row = trigdata->tg_trigtuple;
 
 	switch (ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO]))
 	{
-		/* ----------
-		 * SQL3 11.9 <referential constraint definition>
-		 *	Gereral rules 7) a) i):
-		 * 		MATCH <unspecified> or MATCH FULL
-		 *			... ON UPDATE CASCADE
-		 * ----------
-		 */
+			/* ----------
+			 * SQL3 11.9 <referential constraint definition>
+			 *	Gereral rules 7) a) i):
+			 *		MATCH <unspecified> or MATCH FULL
+			 *			... ON UPDATE CASCADE
+			 * ----------
+			 */
 		case RI_MATCH_TYPE_UNSPECIFIED:
 		case RI_MATCH_TYPE_FULL:
 			ri_BuildQueryKeyFull(&qkey, trigdata->tg_trigger->tgoid,
-									RI_PLAN_CASCADE_UPD_DOUPDATE,
-									fk_rel, pk_rel,
-									tgnargs, tgargs);
+								 RI_PLAN_CASCADE_UPD_DOUPDATE,
+								 fk_rel, pk_rel,
+								 tgnargs, tgargs);
 
 			switch (ri_NullCheck(pk_rel, old_row, &qkey, RI_KEYPAIR_PK_IDX))
 			{
@@ -1209,7 +1216,7 @@ RI_FKey_cascade_upd (FmgrInfo *proinfo)
 					 */
 					heap_close(fk_rel, NoLock);
 					return NULL;
-					
+
 				case RI_KEYS_NONE_NULL:
 					/* ----------
 					 * Have a full qualified key - continue below
@@ -1224,7 +1231,7 @@ RI_FKey_cascade_upd (FmgrInfo *proinfo)
 			 * ----------
 			 */
 			if (ri_KeysEqual(pk_rel, old_row, new_row, &qkey,
-													RI_KEYPAIR_PK_IDX))
+							 RI_KEYPAIR_PK_IDX))
 				return NULL;
 
 			if (SPI_connect() != SPI_OK_CONNECT)
@@ -1240,8 +1247,8 @@ RI_FKey_cascade_upd (FmgrInfo *proinfo)
 				char		buf[256];
 				char		querystr[8192];
 				char		qualstr[8192];
-				char		*querysep;
-				char		*qualsep;
+				char	   *querysep;
+				char	   *qualsep;
 				Oid			queryoids[RI_MAX_NUMKEYS * 2];
 
 				/* ----------
@@ -1254,23 +1261,23 @@ RI_FKey_cascade_upd (FmgrInfo *proinfo)
 				 * how to compare these two types by '='.
 				 * ----------
 				 */
-				sprintf(querystr, "UPDATE \"%s\" SET", 
-									tgargs[RI_FK_RELNAME_ARGNO]);
+				sprintf(querystr, "UPDATE \"%s\" SET",
+						tgargs[RI_FK_RELNAME_ARGNO]);
 				qualstr[0] = '\0';
 				querysep = "";
 				qualsep = "WHERE";
 				for (i = 0, j = qkey.nkeypairs; i < qkey.nkeypairs; i++, j++)
 				{
-					sprintf(buf, "%s \"%s\" = $%d", querysep, 
-										tgargs[4 + i * 2], i + 1);
+					sprintf(buf, "%s \"%s\" = $%d", querysep,
+							tgargs[4 + i * 2], i + 1);
 					strcat(querystr, buf);
 					sprintf(buf, " %s \"%s\" = $%d", qualsep,
-										tgargs[4 + i * 2], j + 1);
+							tgargs[4 + i * 2], j + 1);
 					strcat(qualstr, buf);
 					querysep = ",";
 					qualsep = "AND";
 					queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
-									qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
+									 qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
 					queryoids[j] = queryoids[i];
 				}
 				strcat(querystr, qualstr);
@@ -1292,19 +1299,19 @@ RI_FKey_cascade_upd (FmgrInfo *proinfo)
 			for (i = 0, j = qkey.nkeypairs; i < qkey.nkeypairs; i++, j++)
 			{
 				upd_values[i] = SPI_getbinval(new_row,
-									pk_rel->rd_att,
-									qkey.keypair[i][RI_KEYPAIR_PK_IDX],
-									&isnull);
-				if (isnull) 
+											  pk_rel->rd_att,
+									  qkey.keypair[i][RI_KEYPAIR_PK_IDX],
+											  &isnull);
+				if (isnull)
 					upd_nulls[i] = 'n';
 				else
 					upd_nulls[i] = ' ';
 
 				upd_values[j] = SPI_getbinval(old_row,
-									pk_rel->rd_att,
-									qkey.keypair[i][RI_KEYPAIR_PK_IDX],
-									&isnull);
-				if (isnull) 
+											  pk_rel->rd_att,
+									  qkey.keypair[i][RI_KEYPAIR_PK_IDX],
+											  &isnull);
+				if (isnull)
 					upd_nulls[j] = 'n';
 				else
 					upd_nulls[j] = ' ';
@@ -1317,16 +1324,16 @@ RI_FKey_cascade_upd (FmgrInfo *proinfo)
 			 */
 			if (SPI_execp(qplan, upd_values, upd_nulls, 0) != SPI_OK_UPDATE)
 				elog(ERROR, "SPI_execp() failed in RI_FKey_cascade_upd()");
-			
+
 			if (SPI_finish() != SPI_OK_FINISH)
 				elog(NOTICE, "SPI_finish() failed in RI_FKey_cascade_upd()");
 
 			return NULL;
 
-		/* ----------
-		 * Handle MATCH PARTIAL cascade update.
-		 * ----------
-		 */
+			/* ----------
+			 * Handle MATCH PARTIAL cascade update.
+			 * ----------
+			 */
 		case RI_MATCH_TYPE_PARTIAL:
 			elog(ERROR, "MATCH PARTIAL not yet supported");
 			return NULL;
@@ -1346,32 +1353,32 @@ RI_FKey_cascade_upd (FmgrInfo *proinfo)
  *
  *	Restrict delete from PK table to rows unreferenced by foreign key.
  *
- *  SQL3 intends that this referential action occur BEFORE the
- *  update is performed, rather than after.  This appears to be
- *  the only difference between "NO ACTION" and "RESTRICT".
+ *	SQL3 intends that this referential action occur BEFORE the
+ *	update is performed, rather than after.  This appears to be
+ *	the only difference between "NO ACTION" and "RESTRICT".
  *
- *  For now, however, we treat "RESTRICT" and "NO ACTION" as 
- *  equivalent.
+ *	For now, however, we treat "RESTRICT" and "NO ACTION" as
+ *	equivalent.
  * ----------
  */
 HeapTuple
-RI_FKey_restrict_del (FmgrInfo *proinfo)
+RI_FKey_restrict_del(FmgrInfo *proinfo)
 {
-	TriggerData		   *trigdata;
-	int					tgnargs;
-	char			  **tgargs;
-	Relation			fk_rel;
-	Relation			pk_rel;
-	HeapTuple			old_row;
-	RI_QueryKey			qkey;
-	void			   *qplan;
-	Datum				del_values[RI_MAX_NUMKEYS];
-	char				del_nulls[RI_MAX_NUMKEYS + 1];
-	bool				isnull;
-	int					i;
+	TriggerData *trigdata;
+	int			tgnargs;
+	char	  **tgargs;
+	Relation	fk_rel;
+	Relation	pk_rel;
+	HeapTuple	old_row;
+	RI_QueryKey qkey;
+	void	   *qplan;
+	Datum		del_values[RI_MAX_NUMKEYS];
+	char		del_nulls[RI_MAX_NUMKEYS + 1];
+	bool		isnull;
+	int			i;
 
 	trigdata = CurrentTriggerData;
-	CurrentTriggerData	= NULL;
+	CurrentTriggerData = NULL;
 	ReferentialIntegritySnapshotOverride = true;
 
 	/* ----------
@@ -1380,23 +1387,23 @@ RI_FKey_restrict_del (FmgrInfo *proinfo)
 	 */
 	if (trigdata == NULL)
 		elog(ERROR, "RI_FKey_restrict_del() not fired by trigger manager");
-	if (!TRIGGER_FIRED_AFTER(trigdata->tg_event) || 
-				!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
+	if (!TRIGGER_FIRED_AFTER(trigdata->tg_event) ||
+		!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
 		elog(ERROR, "RI_FKey_restrict_del() must be fired AFTER ROW");
 	if (!TRIGGER_FIRED_BY_DELETE(trigdata->tg_event))
 		elog(ERROR, "RI_FKey_restrict_del() must be fired for DELETE");
 
 	/* ----------
-	 * Check for the correct # of call arguments 
+	 * Check for the correct # of call arguments
 	 * ----------
 	 */
 	tgnargs = trigdata->tg_trigger->tgnargs;
-	tgargs  = trigdata->tg_trigger->tgargs;
+	tgargs = trigdata->tg_trigger->tgargs;
 	if (tgnargs < 4 || (tgnargs % 2) != 0)
 		elog(ERROR, "wrong # of arguments in call to RI_FKey_restrict_del()");
 	if (tgnargs > RI_MAX_ARGUMENTS)
 		elog(ERROR, "too many keys (%d max) in call to RI_FKey_restrict_del()",
-						RI_MAX_NUMKEYS);
+			 RI_MAX_NUMKEYS);
 
 	/* ----------
 	 * Nothing to do if no column names to compare given
@@ -1410,25 +1417,25 @@ RI_FKey_restrict_del (FmgrInfo *proinfo)
 	 * the old tuple.
 	 * ----------
 	 */
-	fk_rel	= heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
-	pk_rel  = trigdata->tg_relation;
+	fk_rel = heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
+	pk_rel = trigdata->tg_relation;
 	old_row = trigdata->tg_trigtuple;
 
 	switch (ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO]))
 	{
-		/* ----------
-		 * SQL3 11.9 <referential constraint definition>
-		 *	Gereral rules 6) a) iv):
-		 * 		MATCH <unspecified> or MATCH FULL
-		 *			... ON DELETE CASCADE
-		 * ----------
-		 */
+			/* ----------
+			 * SQL3 11.9 <referential constraint definition>
+			 *	Gereral rules 6) a) iv):
+			 *		MATCH <unspecified> or MATCH FULL
+			 *			... ON DELETE CASCADE
+			 * ----------
+			 */
 		case RI_MATCH_TYPE_UNSPECIFIED:
 		case RI_MATCH_TYPE_FULL:
 			ri_BuildQueryKeyFull(&qkey, trigdata->tg_trigger->tgoid,
-									RI_PLAN_RESTRICT_DEL_CHECKREF,
-									fk_rel, pk_rel,
-									tgnargs, tgargs);
+								 RI_PLAN_RESTRICT_DEL_CHECKREF,
+								 fk_rel, pk_rel,
+								 tgnargs, tgargs);
 
 			switch (ri_NullCheck(pk_rel, old_row, &qkey, RI_KEYPAIR_PK_IDX))
 			{
@@ -1441,7 +1448,7 @@ RI_FKey_restrict_del (FmgrInfo *proinfo)
 					 */
 					heap_close(fk_rel, NoLock);
 					return NULL;
-					
+
 				case RI_KEYS_NONE_NULL:
 					/* ----------
 					 * Have a full qualified key - continue below
@@ -1463,7 +1470,7 @@ RI_FKey_restrict_del (FmgrInfo *proinfo)
 			{
 				char		buf[256];
 				char		querystr[8192];
-				char		*querysep;
+				char	   *querysep;
 				Oid			queryoids[RI_MAX_NUMKEYS];
 
 				/* ----------
@@ -1475,20 +1482,20 @@ RI_FKey_restrict_del (FmgrInfo *proinfo)
 				 * how to compare these two types by '='.
 				 * ----------
 				 */
-				sprintf(querystr, "SELECT oid FROM \"%s\"", 
-									tgargs[RI_FK_RELNAME_ARGNO]);
+				sprintf(querystr, "SELECT oid FROM \"%s\"",
+						tgargs[RI_FK_RELNAME_ARGNO]);
 				querysep = "WHERE";
 				for (i = 0; i < qkey.nkeypairs; i++)
 				{
-					sprintf(buf, " %s \"%s\" = $%d", querysep, 
-										tgargs[4 + i * 2], i + 1);
+					sprintf(buf, " %s \"%s\" = $%d", querysep,
+							tgargs[4 + i * 2], i + 1);
 					strcat(querystr, buf);
 					querysep = "AND";
 					queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
-									qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
+									 qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
 				}
-				sprintf(buf, " FOR UPDATE OF \"%s\"", 
-									tgargs[RI_FK_RELNAME_ARGNO]);
+				sprintf(buf, " FOR UPDATE OF \"%s\"",
+						tgargs[RI_FK_RELNAME_ARGNO]);
 				strcat(querystr, buf);
 
 				/* ----------
@@ -1508,10 +1515,10 @@ RI_FKey_restrict_del (FmgrInfo *proinfo)
 			for (i = 0; i < qkey.nkeypairs; i++)
 			{
 				del_values[i] = SPI_getbinval(old_row,
-									pk_rel->rd_att,
-									qkey.keypair[i][RI_KEYPAIR_PK_IDX],
-									&isnull);
-				if (isnull) 
+											  pk_rel->rd_att,
+									  qkey.keypair[i][RI_KEYPAIR_PK_IDX],
+											  &isnull);
+				if (isnull)
 					del_nulls[i] = 'n';
 				else
 					del_nulls[i] = ' ';
@@ -1524,23 +1531,23 @@ RI_FKey_restrict_del (FmgrInfo *proinfo)
 			 */
 			if (SPI_execp(qplan, del_values, del_nulls, 1) != SPI_OK_SELECT)
 				elog(ERROR, "SPI_execp() failed in RI_FKey_restrict_del()");
-			
+
 			if (SPI_processed > 0)
 				elog(ERROR, "%s referential integrity violation - "
-							"key in %s still referenced from %s",
-						tgargs[RI_CONSTRAINT_NAME_ARGNO],
-						tgargs[RI_PK_RELNAME_ARGNO],
-						tgargs[RI_FK_RELNAME_ARGNO]);
+					 "key in %s still referenced from %s",
+					 tgargs[RI_CONSTRAINT_NAME_ARGNO],
+					 tgargs[RI_PK_RELNAME_ARGNO],
+					 tgargs[RI_FK_RELNAME_ARGNO]);
 
 			if (SPI_finish() != SPI_OK_FINISH)
 				elog(NOTICE, "SPI_finish() failed in RI_FKey_restrict_del()");
 
 			return NULL;
 
-		/* ----------
-		 * Handle MATCH PARTIAL restrict delete.
-		 * ----------
-		 */
+			/* ----------
+			 * Handle MATCH PARTIAL restrict delete.
+			 * ----------
+			 */
 		case RI_MATCH_TYPE_PARTIAL:
 			elog(ERROR, "MATCH PARTIAL not yet supported");
 			return NULL;
@@ -1560,33 +1567,33 @@ RI_FKey_restrict_del (FmgrInfo *proinfo)
  *
  *	Restrict update of PK to rows unreferenced by foreign key.
  *
- *  SQL3 intends that this referential action occur BEFORE the
- *  update is performed, rather than after.  This appears to be
- *  the only difference between "NO ACTION" and "RESTRICT".
+ *	SQL3 intends that this referential action occur BEFORE the
+ *	update is performed, rather than after.  This appears to be
+ *	the only difference between "NO ACTION" and "RESTRICT".
  *
- *  For now, however, we treat "RESTRICT" and "NO ACTION" as 
- *  equivalent.
+ *	For now, however, we treat "RESTRICT" and "NO ACTION" as
+ *	equivalent.
  * ----------
  */
 HeapTuple
-RI_FKey_restrict_upd (FmgrInfo *proinfo)
+RI_FKey_restrict_upd(FmgrInfo *proinfo)
 {
-	TriggerData		   *trigdata;
-	int					tgnargs;
-	char			  **tgargs;
-	Relation			fk_rel;
-	Relation			pk_rel;
-	HeapTuple			new_row;
-	HeapTuple			old_row;
-	RI_QueryKey			qkey;
-	void			   *qplan;
-	Datum				upd_values[RI_MAX_NUMKEYS];
-	char				upd_nulls[RI_MAX_NUMKEYS + 1];
-	bool				isnull;
-	int					i;
+	TriggerData *trigdata;
+	int			tgnargs;
+	char	  **tgargs;
+	Relation	fk_rel;
+	Relation	pk_rel;
+	HeapTuple	new_row;
+	HeapTuple	old_row;
+	RI_QueryKey qkey;
+	void	   *qplan;
+	Datum		upd_values[RI_MAX_NUMKEYS];
+	char		upd_nulls[RI_MAX_NUMKEYS + 1];
+	bool		isnull;
+	int			i;
 
 	trigdata = CurrentTriggerData;
-	CurrentTriggerData	= NULL;
+	CurrentTriggerData = NULL;
 	ReferentialIntegritySnapshotOverride = true;
 
 	/* ----------
@@ -1595,23 +1602,23 @@ RI_FKey_restrict_upd (FmgrInfo *proinfo)
 	 */
 	if (trigdata == NULL)
 		elog(ERROR, "RI_FKey_restrict_upd() not fired by trigger manager");
-	if (!TRIGGER_FIRED_AFTER(trigdata->tg_event) || 
-				!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
+	if (!TRIGGER_FIRED_AFTER(trigdata->tg_event) ||
+		!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
 		elog(ERROR, "RI_FKey_restrict_upd() must be fired AFTER ROW");
 	if (!TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
 		elog(ERROR, "RI_FKey_restrict_upd() must be fired for UPDATE");
 
 	/* ----------
-	 * Check for the correct # of call arguments 
+	 * Check for the correct # of call arguments
 	 * ----------
 	 */
 	tgnargs = trigdata->tg_trigger->tgnargs;
-	tgargs  = trigdata->tg_trigger->tgargs;
+	tgargs = trigdata->tg_trigger->tgargs;
 	if (tgnargs < 4 || (tgnargs % 2) != 0)
 		elog(ERROR, "wrong # of arguments in call to RI_FKey_restrict_upd()");
 	if (tgnargs > RI_MAX_ARGUMENTS)
 		elog(ERROR, "too many keys (%d max) in call to RI_FKey_restrict_upd()",
-						RI_MAX_NUMKEYS);
+			 RI_MAX_NUMKEYS);
 
 	/* ----------
 	 * Nothing to do if no column names to compare given
@@ -1625,26 +1632,26 @@ RI_FKey_restrict_upd (FmgrInfo *proinfo)
 	 * the new and old tuple.
 	 * ----------
 	 */
-	fk_rel	= heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
-	pk_rel  = trigdata->tg_relation;
+	fk_rel = heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
+	pk_rel = trigdata->tg_relation;
 	new_row = trigdata->tg_newtuple;
 	old_row = trigdata->tg_trigtuple;
 
 	switch (ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO]))
 	{
-		/* ----------
-		 * SQL3 11.9 <referential constraint definition>
-		 *	Gereral rules 6) a) iv):
-		 * 		MATCH <unspecified> or MATCH FULL
-		 *			... ON DELETE CASCADE
-		 * ----------
-		 */
+			/* ----------
+			 * SQL3 11.9 <referential constraint definition>
+			 *	Gereral rules 6) a) iv):
+			 *		MATCH <unspecified> or MATCH FULL
+			 *			... ON DELETE CASCADE
+			 * ----------
+			 */
 		case RI_MATCH_TYPE_UNSPECIFIED:
 		case RI_MATCH_TYPE_FULL:
 			ri_BuildQueryKeyFull(&qkey, trigdata->tg_trigger->tgoid,
-									RI_PLAN_RESTRICT_UPD_CHECKREF,
-									fk_rel, pk_rel,
-									tgnargs, tgargs);
+								 RI_PLAN_RESTRICT_UPD_CHECKREF,
+								 fk_rel, pk_rel,
+								 tgnargs, tgargs);
 
 			switch (ri_NullCheck(pk_rel, old_row, &qkey, RI_KEYPAIR_PK_IDX))
 			{
@@ -1657,7 +1664,7 @@ RI_FKey_restrict_upd (FmgrInfo *proinfo)
 					 */
 					heap_close(fk_rel, NoLock);
 					return NULL;
-					
+
 				case RI_KEYS_NONE_NULL:
 					/* ----------
 					 * Have a full qualified key - continue below
@@ -1672,7 +1679,7 @@ RI_FKey_restrict_upd (FmgrInfo *proinfo)
 			 * ----------
 			 */
 			if (ri_KeysEqual(pk_rel, old_row, new_row, &qkey,
-													RI_KEYPAIR_PK_IDX))
+							 RI_KEYPAIR_PK_IDX))
 				return NULL;
 
 			if (SPI_connect() != SPI_OK_CONNECT)
@@ -1687,7 +1694,7 @@ RI_FKey_restrict_upd (FmgrInfo *proinfo)
 			{
 				char		buf[256];
 				char		querystr[8192];
-				char		*querysep;
+				char	   *querysep;
 				Oid			queryoids[RI_MAX_NUMKEYS];
 
 				/* ----------
@@ -1699,20 +1706,20 @@ RI_FKey_restrict_upd (FmgrInfo *proinfo)
 				 * how to compare these two types by '='.
 				 * ----------
 				 */
-				sprintf(querystr, "SELECT oid FROM \"%s\"", 
-									tgargs[RI_FK_RELNAME_ARGNO]);
+				sprintf(querystr, "SELECT oid FROM \"%s\"",
+						tgargs[RI_FK_RELNAME_ARGNO]);
 				querysep = "WHERE";
 				for (i = 0; i < qkey.nkeypairs; i++)
 				{
-					sprintf(buf, " %s \"%s\" = $%d", querysep, 
-										tgargs[4 + i * 2], i + 1);
+					sprintf(buf, " %s \"%s\" = $%d", querysep,
+							tgargs[4 + i * 2], i + 1);
 					strcat(querystr, buf);
 					querysep = "AND";
 					queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
-									qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
+									 qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
 				}
-				sprintf(buf, " FOR UPDATE OF \"%s\"", 
-									tgargs[RI_FK_RELNAME_ARGNO]);
+				sprintf(buf, " FOR UPDATE OF \"%s\"",
+						tgargs[RI_FK_RELNAME_ARGNO]);
 				strcat(querystr, buf);
 
 				/* ----------
@@ -1732,10 +1739,10 @@ RI_FKey_restrict_upd (FmgrInfo *proinfo)
 			for (i = 0; i < qkey.nkeypairs; i++)
 			{
 				upd_values[i] = SPI_getbinval(old_row,
-									pk_rel->rd_att,
-									qkey.keypair[i][RI_KEYPAIR_PK_IDX],
-									&isnull);
-				if (isnull) 
+											  pk_rel->rd_att,
+									  qkey.keypair[i][RI_KEYPAIR_PK_IDX],
+											  &isnull);
+				if (isnull)
 					upd_nulls[i] = 'n';
 				else
 					upd_nulls[i] = ' ';
@@ -1748,23 +1755,23 @@ RI_FKey_restrict_upd (FmgrInfo *proinfo)
 			 */
 			if (SPI_execp(qplan, upd_values, upd_nulls, 1) != SPI_OK_SELECT)
 				elog(ERROR, "SPI_execp() failed in RI_FKey_restrict_upd()");
-			
+
 			if (SPI_processed > 0)
 				elog(ERROR, "%s referential integrity violation - "
-							"key in %s still referenced from %s",
-						tgargs[RI_CONSTRAINT_NAME_ARGNO],
-						tgargs[RI_PK_RELNAME_ARGNO],
-						tgargs[RI_FK_RELNAME_ARGNO]);
+					 "key in %s still referenced from %s",
+					 tgargs[RI_CONSTRAINT_NAME_ARGNO],
+					 tgargs[RI_PK_RELNAME_ARGNO],
+					 tgargs[RI_FK_RELNAME_ARGNO]);
 
 			if (SPI_finish() != SPI_OK_FINISH)
 				elog(NOTICE, "SPI_finish() failed in RI_FKey_restrict_upd()");
 
 			return NULL;
 
-		/* ----------
-		 * Handle MATCH PARTIAL restrict update.
-		 * ----------
-		 */
+			/* ----------
+			 * Handle MATCH PARTIAL restrict update.
+			 * ----------
+			 */
 		case RI_MATCH_TYPE_PARTIAL:
 			elog(ERROR, "MATCH PARTIAL not yet supported");
 			return NULL;
@@ -1786,23 +1793,23 @@ RI_FKey_restrict_upd (FmgrInfo *proinfo)
  * ----------
  */
 HeapTuple
-RI_FKey_setnull_del (FmgrInfo *proinfo)
+RI_FKey_setnull_del(FmgrInfo *proinfo)
 {
-	TriggerData		   *trigdata;
-	int					tgnargs;
-	char			  **tgargs;
-	Relation			fk_rel;
-	Relation			pk_rel;
-	HeapTuple			old_row;
-	RI_QueryKey			qkey;
-	void			   *qplan;
-	Datum				upd_values[RI_MAX_NUMKEYS];
-	char				upd_nulls[RI_MAX_NUMKEYS + 1];
-	bool				isnull;
-	int					i;
+	TriggerData *trigdata;
+	int			tgnargs;
+	char	  **tgargs;
+	Relation	fk_rel;
+	Relation	pk_rel;
+	HeapTuple	old_row;
+	RI_QueryKey qkey;
+	void	   *qplan;
+	Datum		upd_values[RI_MAX_NUMKEYS];
+	char		upd_nulls[RI_MAX_NUMKEYS + 1];
+	bool		isnull;
+	int			i;
 
 	trigdata = CurrentTriggerData;
-	CurrentTriggerData	= NULL;
+	CurrentTriggerData = NULL;
 	ReferentialIntegritySnapshotOverride = true;
 
 	/* ----------
@@ -1811,23 +1818,23 @@ RI_FKey_setnull_del (FmgrInfo *proinfo)
 	 */
 	if (trigdata == NULL)
 		elog(ERROR, "RI_FKey_setnull_del() not fired by trigger manager");
-	if (!TRIGGER_FIRED_AFTER(trigdata->tg_event) || 
-				!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
+	if (!TRIGGER_FIRED_AFTER(trigdata->tg_event) ||
+		!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
 		elog(ERROR, "RI_FKey_setnull_del() must be fired AFTER ROW");
 	if (!TRIGGER_FIRED_BY_DELETE(trigdata->tg_event))
 		elog(ERROR, "RI_FKey_setnull_del() must be fired for DELETE");
 
 	/* ----------
-	 * Check for the correct # of call arguments 
+	 * Check for the correct # of call arguments
 	 * ----------
 	 */
 	tgnargs = trigdata->tg_trigger->tgnargs;
-	tgargs  = trigdata->tg_trigger->tgargs;
+	tgargs = trigdata->tg_trigger->tgargs;
 	if (tgnargs < 4 || (tgnargs % 2) != 0)
 		elog(ERROR, "wrong # of arguments in call to RI_FKey_setnull_del()");
 	if (tgnargs > RI_MAX_ARGUMENTS)
 		elog(ERROR, "too many keys (%d max) in call to RI_FKey_setnull_del()",
-						RI_MAX_NUMKEYS);
+			 RI_MAX_NUMKEYS);
 
 	/* ----------
 	 * Nothing to do if no column names to compare given
@@ -1841,25 +1848,25 @@ RI_FKey_setnull_del (FmgrInfo *proinfo)
 	 * the old tuple.
 	 * ----------
 	 */
-	fk_rel	= heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
-	pk_rel  = trigdata->tg_relation;
+	fk_rel = heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
+	pk_rel = trigdata->tg_relation;
 	old_row = trigdata->tg_trigtuple;
 
 	switch (ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO]))
 	{
-		/* ----------
-		 * SQL3 11.9 <referential constraint definition>
-		 *	Gereral rules 6) a) ii):
-		 * 		MATCH <UNSPECIFIED> or MATCH FULL
-		 *			... ON DELETE SET NULL
-		 * ----------
-		 */
+			/* ----------
+			 * SQL3 11.9 <referential constraint definition>
+			 *	Gereral rules 6) a) ii):
+			 *		MATCH <UNSPECIFIED> or MATCH FULL
+			 *			... ON DELETE SET NULL
+			 * ----------
+			 */
 		case RI_MATCH_TYPE_UNSPECIFIED:
 		case RI_MATCH_TYPE_FULL:
 			ri_BuildQueryKeyFull(&qkey, trigdata->tg_trigger->tgoid,
-									RI_PLAN_SETNULL_DEL_DOUPDATE,
-									fk_rel, pk_rel,
-									tgnargs, tgargs);
+								 RI_PLAN_SETNULL_DEL_DOUPDATE,
+								 fk_rel, pk_rel,
+								 tgnargs, tgargs);
 
 			switch (ri_NullCheck(pk_rel, old_row, &qkey, RI_KEYPAIR_PK_IDX))
 			{
@@ -1872,7 +1879,7 @@ RI_FKey_setnull_del (FmgrInfo *proinfo)
 					 */
 					heap_close(fk_rel, NoLock);
 					return NULL;
-					
+
 				case RI_KEYS_NONE_NULL:
 					/* ----------
 					 * Have a full qualified key - continue below
@@ -1895,8 +1902,8 @@ RI_FKey_setnull_del (FmgrInfo *proinfo)
 				char		buf[256];
 				char		querystr[8192];
 				char		qualstr[8192];
-				char		*querysep;
-				char		*qualsep;
+				char	   *querysep;
+				char	   *qualsep;
 				Oid			queryoids[RI_MAX_NUMKEYS];
 
 				/* ----------
@@ -1909,23 +1916,23 @@ RI_FKey_setnull_del (FmgrInfo *proinfo)
 				 * how to compare these two types by '='.
 				 * ----------
 				 */
-				sprintf(querystr, "UPDATE \"%s\" SET", 
-									tgargs[RI_FK_RELNAME_ARGNO]);
+				sprintf(querystr, "UPDATE \"%s\" SET",
+						tgargs[RI_FK_RELNAME_ARGNO]);
 				qualstr[0] = '\0';
 				querysep = "";
 				qualsep = "WHERE";
 				for (i = 0; i < qkey.nkeypairs; i++)
 				{
-					sprintf(buf, "%s \"%s\" = NULL", querysep, 
-										tgargs[4 + i * 2]);
+					sprintf(buf, "%s \"%s\" = NULL", querysep,
+							tgargs[4 + i * 2]);
 					strcat(querystr, buf);
 					sprintf(buf, " %s \"%s\" = $%d", qualsep,
-										tgargs[4 + i * 2], i + 1);
+							tgargs[4 + i * 2], i + 1);
 					strcat(qualstr, buf);
 					querysep = ",";
 					qualsep = "AND";
 					queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
-									qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
+									 qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
 				}
 				strcat(querystr, qualstr);
 
@@ -1946,10 +1953,10 @@ RI_FKey_setnull_del (FmgrInfo *proinfo)
 			for (i = 0; i < qkey.nkeypairs; i++)
 			{
 				upd_values[i] = SPI_getbinval(old_row,
-									pk_rel->rd_att,
-									qkey.keypair[i][RI_KEYPAIR_PK_IDX],
-									&isnull);
-				if (isnull) 
+											  pk_rel->rd_att,
+									  qkey.keypair[i][RI_KEYPAIR_PK_IDX],
+											  &isnull);
+				if (isnull)
 					upd_nulls[i] = 'n';
 				else
 					upd_nulls[i] = ' ';
@@ -1962,16 +1969,16 @@ RI_FKey_setnull_del (FmgrInfo *proinfo)
 			 */
 			if (SPI_execp(qplan, upd_values, upd_nulls, 0) != SPI_OK_UPDATE)
 				elog(ERROR, "SPI_execp() failed in RI_FKey_setnull_del()");
-			
+
 			if (SPI_finish() != SPI_OK_FINISH)
 				elog(NOTICE, "SPI_finish() failed in RI_FKey_setnull_del()");
 
 			return NULL;
 
-		/* ----------
-		 * Handle MATCH PARTIAL set null delete.
-		 * ----------
-		 */
+			/* ----------
+			 * Handle MATCH PARTIAL set null delete.
+			 * ----------
+			 */
 		case RI_MATCH_TYPE_PARTIAL:
 			elog(ERROR, "MATCH PARTIAL not yet supported");
 			return NULL;
@@ -1993,26 +2000,26 @@ RI_FKey_setnull_del (FmgrInfo *proinfo)
  * ----------
  */
 HeapTuple
-RI_FKey_setnull_upd (FmgrInfo *proinfo)
+RI_FKey_setnull_upd(FmgrInfo *proinfo)
 {
-	TriggerData		   *trigdata;
-	int					tgnargs;
-	char			  **tgargs;
-	Relation			fk_rel;
-	Relation			pk_rel;
-	HeapTuple			new_row;
-	HeapTuple			old_row;
-	RI_QueryKey			qkey;
-	void			   *qplan;
-	Datum				upd_values[RI_MAX_NUMKEYS];
-	char				upd_nulls[RI_MAX_NUMKEYS + 1];
-	bool				isnull;
-	int					i;
-	int				 match_type;
-	bool				use_cached_query;
+	TriggerData *trigdata;
+	int			tgnargs;
+	char	  **tgargs;
+	Relation	fk_rel;
+	Relation	pk_rel;
+	HeapTuple	new_row;
+	HeapTuple	old_row;
+	RI_QueryKey qkey;
+	void	   *qplan;
+	Datum		upd_values[RI_MAX_NUMKEYS];
+	char		upd_nulls[RI_MAX_NUMKEYS + 1];
+	bool		isnull;
+	int			i;
+	int			match_type;
+	bool		use_cached_query;
 
 	trigdata = CurrentTriggerData;
-	CurrentTriggerData	= NULL;
+	CurrentTriggerData = NULL;
 	ReferentialIntegritySnapshotOverride = true;
 
 	/* ----------
@@ -2021,23 +2028,23 @@ RI_FKey_setnull_upd (FmgrInfo *proinfo)
 	 */
 	if (trigdata == NULL)
 		elog(ERROR, "RI_FKey_setnull_upd() not fired by trigger manager");
-	if (!TRIGGER_FIRED_AFTER(trigdata->tg_event) || 
-				!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
+	if (!TRIGGER_FIRED_AFTER(trigdata->tg_event) ||
+		!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
 		elog(ERROR, "RI_FKey_setnull_upd() must be fired AFTER ROW");
 	if (!TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
 		elog(ERROR, "RI_FKey_setnull_upd() must be fired for UPDATE");
 
 	/* ----------
-	 * Check for the correct # of call arguments 
+	 * Check for the correct # of call arguments
 	 * ----------
 	 */
 	tgnargs = trigdata->tg_trigger->tgnargs;
-	tgargs  = trigdata->tg_trigger->tgargs;
+	tgargs = trigdata->tg_trigger->tgargs;
 	if (tgnargs < 4 || (tgnargs % 2) != 0)
 		elog(ERROR, "wrong # of arguments in call to RI_FKey_setnull_upd()");
 	if (tgnargs > RI_MAX_ARGUMENTS)
 		elog(ERROR, "too many keys (%d max) in call to RI_FKey_setnull_upd()",
-						RI_MAX_NUMKEYS);
+			 RI_MAX_NUMKEYS);
 
 	/* ----------
 	 * Nothing to do if no column names to compare given
@@ -2051,27 +2058,27 @@ RI_FKey_setnull_upd (FmgrInfo *proinfo)
 	 * the old tuple.
 	 * ----------
 	 */
-	fk_rel	= heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
-	pk_rel  = trigdata->tg_relation;
+	fk_rel = heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
+	pk_rel = trigdata->tg_relation;
 	new_row = trigdata->tg_newtuple;
 	old_row = trigdata->tg_trigtuple;
 	match_type = ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO]);
 
 	switch (match_type)
 	{
-		/* ----------
-		 * SQL3 11.9 <referential constraint definition>
-		 *	Gereral rules 7) a) ii) 2):
-		 * 		MATCH FULL
-		 *			... ON UPDATE SET NULL
-		 * ----------
-		 */
+			/* ----------
+			 * SQL3 11.9 <referential constraint definition>
+			 *	Gereral rules 7) a) ii) 2):
+			 *		MATCH FULL
+			 *			... ON UPDATE SET NULL
+			 * ----------
+			 */
 		case RI_MATCH_TYPE_UNSPECIFIED:
 		case RI_MATCH_TYPE_FULL:
 			ri_BuildQueryKeyFull(&qkey, trigdata->tg_trigger->tgoid,
-									RI_PLAN_SETNULL_UPD_DOUPDATE,
-									fk_rel, pk_rel,
-									tgnargs, tgargs);
+								 RI_PLAN_SETNULL_UPD_DOUPDATE,
+								 fk_rel, pk_rel,
+								 tgnargs, tgargs);
 
 			switch (ri_NullCheck(pk_rel, old_row, &qkey, RI_KEYPAIR_PK_IDX))
 			{
@@ -2084,7 +2091,7 @@ RI_FKey_setnull_upd (FmgrInfo *proinfo)
 					 */
 					heap_close(fk_rel, NoLock);
 					return NULL;
-					
+
 				case RI_KEYS_NONE_NULL:
 					/* ----------
 					 * Have a full qualified key - continue below
@@ -2100,28 +2107,29 @@ RI_FKey_setnull_upd (FmgrInfo *proinfo)
 			 * ----------
 			 */
 			if (ri_KeysEqual(pk_rel, old_row, new_row, &qkey,
-													RI_KEYPAIR_PK_IDX))
+							 RI_KEYPAIR_PK_IDX))
 				return NULL;
 
 			if (SPI_connect() != SPI_OK_CONNECT)
 				elog(NOTICE, "SPI_connect() failed in RI_FKey_setnull_upd()");
 
-			/* "MATCH <unspecified>" only changes columns corresponding to
-			 * the referenced columns that have changed in pk_rel.  This means
-			 * the "SET attrn=NULL [, attrn=NULL]" string will be change as
-			 * well.  In this case, we need to build a temporary plan 
-			 * rather than use our cached plan, unless the update happens
-			 * to change all columns in the key.  Fortunately, for the most
-			 * common case of a single-column foreign key, this will be
-			 * true.
+			/*
+			 * "MATCH <unspecified>" only changes columns corresponding to
+			 * the referenced columns that have changed in pk_rel.	This
+			 * means the "SET attrn=NULL [, attrn=NULL]" string will be
+			 * change as well.	In this case, we need to build a temporary
+			 * plan rather than use our cached plan, unless the update
+			 * happens to change all columns in the key.  Fortunately, for
+			 * the most common case of a single-column foreign key, this
+			 * will be true.
 			 *
 			 * In case you're wondering, the inequality check works because
 			 * we know that the old key value has no NULLs (see above).
 			 */
 
 			use_cached_query = match_type == RI_MATCH_TYPE_FULL ||
-							   ri_AllKeysUnequal(pk_rel, old_row, new_row,
-												 &qkey, RI_KEYPAIR_PK_IDX);
+				ri_AllKeysUnequal(pk_rel, old_row, new_row,
+								  &qkey, RI_KEYPAIR_PK_IDX);
 
 			/* ----------
 			 * Fetch or prepare a saved plan for the set null update
@@ -2134,8 +2142,8 @@ RI_FKey_setnull_upd (FmgrInfo *proinfo)
 				char		buf[256];
 				char		querystr[8192];
 				char		qualstr[8192];
-				char		*querysep;
-				char		*qualsep;
+				char	   *querysep;
+				char	   *qualsep;
 				Oid			queryoids[RI_MAX_NUMKEYS];
 
 				/* ----------
@@ -2148,31 +2156,33 @@ RI_FKey_setnull_upd (FmgrInfo *proinfo)
 				 * how to compare these two types by '='.
 				 * ----------
 				 */
-				sprintf(querystr, "UPDATE \"%s\" SET", 
-									tgargs[RI_FK_RELNAME_ARGNO]);
+				sprintf(querystr, "UPDATE \"%s\" SET",
+						tgargs[RI_FK_RELNAME_ARGNO]);
 				qualstr[0] = '\0';
 				querysep = "";
 				qualsep = "WHERE";
 				for (i = 0; i < qkey.nkeypairs; i++)
 				{
-					/* MATCH <unspecified> - only change columns corresponding
-					 * to changed columns in pk_rel's key
+
+					/*
+					 * MATCH <unspecified> - only change columns
+					 * corresponding to changed columns in pk_rel's key
 					 */
 					if (match_type == RI_MATCH_TYPE_FULL ||
-						!ri_OneKeyEqual(pk_rel, i, old_row, new_row, &qkey,
-											RI_KEYPAIR_PK_IDX))
+					  !ri_OneKeyEqual(pk_rel, i, old_row, new_row, &qkey,
+									  RI_KEYPAIR_PK_IDX))
 					{
-						sprintf(buf, "%s \"%s\" = NULL", querysep, 
-										tgargs[4 + i * 2]);
+						sprintf(buf, "%s \"%s\" = NULL", querysep,
+								tgargs[4 + i * 2]);
 						strcat(querystr, buf);
 						querysep = ",";
 					}
 					sprintf(buf, " %s \"%s\" = $%d", qualsep,
-										tgargs[4 + i * 2], i + 1);
+							tgargs[4 + i * 2], i + 1);
 					strcat(qualstr, buf);
 					qualsep = "AND";
 					queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
-									qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
+									 qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
 				}
 				strcat(querystr, qualstr);
 
@@ -2182,8 +2192,9 @@ RI_FKey_setnull_upd (FmgrInfo *proinfo)
 				 */
 				qplan = SPI_prepare(querystr, qkey.nkeypairs, queryoids);
 
-				/* Save and remember the plan if we're building the "standard"
-				 * plan.
+				/*
+				 * Save and remember the plan if we're building the
+				 * "standard" plan.
 				 */
 				if (use_cached_query)
 				{
@@ -2200,10 +2211,10 @@ RI_FKey_setnull_upd (FmgrInfo *proinfo)
 			for (i = 0; i < qkey.nkeypairs; i++)
 			{
 				upd_values[i] = SPI_getbinval(old_row,
-									pk_rel->rd_att,
-									qkey.keypair[i][RI_KEYPAIR_PK_IDX],
-									&isnull);
-				if (isnull) 
+											  pk_rel->rd_att,
+									  qkey.keypair[i][RI_KEYPAIR_PK_IDX],
+											  &isnull);
+				if (isnull)
 					upd_nulls[i] = 'n';
 				else
 					upd_nulls[i] = ' ';
@@ -2216,16 +2227,16 @@ RI_FKey_setnull_upd (FmgrInfo *proinfo)
 			 */
 			if (SPI_execp(qplan, upd_values, upd_nulls, 0) != SPI_OK_UPDATE)
 				elog(ERROR, "SPI_execp() failed in RI_FKey_setnull_upd()");
-			
+
 			if (SPI_finish() != SPI_OK_FINISH)
 				elog(NOTICE, "SPI_finish() failed in RI_FKey_setnull_upd()");
 
 			return NULL;
 
-		/* ----------
-		 * Handle MATCH PARTIAL set null update.
-		 * ----------
-		 */
+			/* ----------
+			 * Handle MATCH PARTIAL set null update.
+			 * ----------
+			 */
 		case RI_MATCH_TYPE_PARTIAL:
 			elog(ERROR, "MATCH PARTIAL not yet supported");
 			return NULL;
@@ -2247,23 +2258,23 @@ RI_FKey_setnull_upd (FmgrInfo *proinfo)
  * ----------
  */
 HeapTuple
-RI_FKey_setdefault_del (FmgrInfo *proinfo)
+RI_FKey_setdefault_del(FmgrInfo *proinfo)
 {
-	TriggerData		   *trigdata;
-	int					tgnargs;
-	char			  **tgargs;
-	Relation			fk_rel;
-	Relation			pk_rel;
-	HeapTuple			old_row;
-	RI_QueryKey			qkey;
-	void			   *qplan;
-	Datum				upd_values[RI_MAX_NUMKEYS];
-	char				upd_nulls[RI_MAX_NUMKEYS + 1];
-	bool				isnull;
-	int					i;
+	TriggerData *trigdata;
+	int			tgnargs;
+	char	  **tgargs;
+	Relation	fk_rel;
+	Relation	pk_rel;
+	HeapTuple	old_row;
+	RI_QueryKey qkey;
+	void	   *qplan;
+	Datum		upd_values[RI_MAX_NUMKEYS];
+	char		upd_nulls[RI_MAX_NUMKEYS + 1];
+	bool		isnull;
+	int			i;
 
 	trigdata = CurrentTriggerData;
-	CurrentTriggerData	= NULL;
+	CurrentTriggerData = NULL;
 	ReferentialIntegritySnapshotOverride = true;
 
 	/* ----------
@@ -2272,23 +2283,23 @@ RI_FKey_setdefault_del (FmgrInfo *proinfo)
 	 */
 	if (trigdata == NULL)
 		elog(ERROR, "RI_FKey_setdefault_del() not fired by trigger manager");
-	if (!TRIGGER_FIRED_AFTER(trigdata->tg_event) || 
-				!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
+	if (!TRIGGER_FIRED_AFTER(trigdata->tg_event) ||
+		!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
 		elog(ERROR, "RI_FKey_setdefault_del() must be fired AFTER ROW");
 	if (!TRIGGER_FIRED_BY_DELETE(trigdata->tg_event))
 		elog(ERROR, "RI_FKey_setdefault_del() must be fired for DELETE");
 
 	/* ----------
-	 * Check for the correct # of call arguments 
+	 * Check for the correct # of call arguments
 	 * ----------
 	 */
 	tgnargs = trigdata->tg_trigger->tgnargs;
-	tgargs  = trigdata->tg_trigger->tgargs;
+	tgargs = trigdata->tg_trigger->tgargs;
 	if (tgnargs < 4 || (tgnargs % 2) != 0)
 		elog(ERROR, "wrong # of arguments in call to RI_FKey_setdefault_del()");
 	if (tgnargs > RI_MAX_ARGUMENTS)
 		elog(ERROR, "too many keys (%d max) in call to RI_FKey_setdefault_del()",
-						RI_MAX_NUMKEYS);
+			 RI_MAX_NUMKEYS);
 
 	/* ----------
 	 * Nothing to do if no column names to compare given
@@ -2302,25 +2313,25 @@ RI_FKey_setdefault_del (FmgrInfo *proinfo)
 	 * the old tuple.
 	 * ----------
 	 */
-	fk_rel	= heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
-	pk_rel  = trigdata->tg_relation;
+	fk_rel = heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
+	pk_rel = trigdata->tg_relation;
 	old_row = trigdata->tg_trigtuple;
 
 	switch (ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO]))
 	{
-		/* ----------
-		 * SQL3 11.9 <referential constraint definition>
-		 *	Gereral rules 6) a) iii):
-		 * 		MATCH <UNSPECIFIED> or MATCH FULL
-		 *			... ON DELETE SET DEFAULT
-		 * ----------
-		 */
+			/* ----------
+			 * SQL3 11.9 <referential constraint definition>
+			 *	Gereral rules 6) a) iii):
+			 *		MATCH <UNSPECIFIED> or MATCH FULL
+			 *			... ON DELETE SET DEFAULT
+			 * ----------
+			 */
 		case RI_MATCH_TYPE_UNSPECIFIED:
 		case RI_MATCH_TYPE_FULL:
 			ri_BuildQueryKeyFull(&qkey, trigdata->tg_trigger->tgoid,
-									RI_PLAN_SETNULL_DEL_DOUPDATE,
-									fk_rel, pk_rel,
-									tgnargs, tgargs);
+								 RI_PLAN_SETNULL_DEL_DOUPDATE,
+								 fk_rel, pk_rel,
+								 tgnargs, tgargs);
 
 			switch (ri_NullCheck(pk_rel, old_row, &qkey, RI_KEYPAIR_PK_IDX))
 			{
@@ -2333,7 +2344,7 @@ RI_FKey_setdefault_del (FmgrInfo *proinfo)
 					 */
 					heap_close(fk_rel, NoLock);
 					return NULL;
-					
+
 				case RI_KEYS_NONE_NULL:
 					/* ----------
 					 * Have a full qualified key - continue below
@@ -2357,13 +2368,14 @@ RI_FKey_setdefault_del (FmgrInfo *proinfo)
 				char		buf[256];
 				char		querystr[8192];
 				char		qualstr[8192];
-				char		*querysep;
-				char		*qualsep;
+				char	   *querysep;
+				char	   *qualsep;
 				Oid			queryoids[RI_MAX_NUMKEYS];
-				Plan		*spi_plan;
-				AttrDefault	*defval;
-				TargetEntry	*spi_qptle;
-				int			i, j;
+				Plan	   *spi_plan;
+				AttrDefault *defval;
+				TargetEntry *spi_qptle;
+				int			i,
+							j;
 
 				/* ----------
 				 * The query string built is
@@ -2375,23 +2387,23 @@ RI_FKey_setdefault_del (FmgrInfo *proinfo)
 				 * how to compare these two types by '='.
 				 * ----------
 				 */
-				sprintf(querystr, "UPDATE \"%s\" SET", 
-									tgargs[RI_FK_RELNAME_ARGNO]);
+				sprintf(querystr, "UPDATE \"%s\" SET",
+						tgargs[RI_FK_RELNAME_ARGNO]);
 				qualstr[0] = '\0';
 				querysep = "";
 				qualsep = "WHERE";
 				for (i = 0; i < qkey.nkeypairs; i++)
 				{
-					sprintf(buf, "%s \"%s\" = NULL", querysep, 
-										tgargs[4 + i * 2]);
+					sprintf(buf, "%s \"%s\" = NULL", querysep,
+							tgargs[4 + i * 2]);
 					strcat(querystr, buf);
 					sprintf(buf, " %s \"%s\" = $%d", qualsep,
-										tgargs[4 + i * 2], i + 1);
+							tgargs[4 + i * 2], i + 1);
 					strcat(qualstr, buf);
 					querysep = ",";
 					qualsep = "AND";
 					queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
-									qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
+									 qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
 				}
 				strcat(querystr, qualstr);
 
@@ -2412,7 +2424,7 @@ RI_FKey_setdefault_del (FmgrInfo *proinfo)
 				 * in the tuple constructor.
 				 * ----------
 				 */
-				spi_plan = (Plan *)lfirst(((_SPI_plan *)qplan)->ptlist);
+				spi_plan = (Plan *) lfirst(((_SPI_plan *) qplan)->ptlist);
 				if (fk_rel->rd_att->constr != NULL)
 					defval = fk_rel->rd_att->constr->defval;
 				else
@@ -2426,8 +2438,8 @@ RI_FKey_setdefault_del (FmgrInfo *proinfo)
 					 */
 					for (j = 0; j < fk_rel->rd_att->constr->num_defval; j++)
 					{
-						if (defval[j].adnum == 
-											qkey.keypair[i][RI_KEYPAIR_FK_IDX])
+						if (defval[j].adnum ==
+							qkey.keypair[i][RI_KEYPAIR_FK_IDX])
 						{
 							/* ----------
 							 * That's the one - push the expression
@@ -2435,8 +2447,8 @@ RI_FKey_setdefault_del (FmgrInfo *proinfo)
 							 * ----------
 							 */
 							spi_qptle = (TargetEntry *)
-										nth(defval[j].adnum - 1,
-										spi_plan->targetlist);
+								nth(defval[j].adnum - 1,
+									spi_plan->targetlist);
 							spi_qptle->expr = stringToNode(defval[j].adbin);
 
 							break;
@@ -2453,10 +2465,10 @@ RI_FKey_setdefault_del (FmgrInfo *proinfo)
 			for (i = 0; i < qkey.nkeypairs; i++)
 			{
 				upd_values[i] = SPI_getbinval(old_row,
-									pk_rel->rd_att,
-									qkey.keypair[i][RI_KEYPAIR_PK_IDX],
-									&isnull);
-				if (isnull) 
+											  pk_rel->rd_att,
+									  qkey.keypair[i][RI_KEYPAIR_PK_IDX],
+											  &isnull);
+				if (isnull)
 					upd_nulls[i] = 'n';
 				else
 					upd_nulls[i] = ' ';
@@ -2469,16 +2481,16 @@ RI_FKey_setdefault_del (FmgrInfo *proinfo)
 			 */
 			if (SPI_execp(qplan, upd_values, upd_nulls, 0) != SPI_OK_UPDATE)
 				elog(ERROR, "SPI_execp() failed in RI_FKey_setdefault_del()");
-			
+
 			if (SPI_finish() != SPI_OK_FINISH)
 				elog(NOTICE, "SPI_finish() failed in RI_FKey_setdefault_del()");
 
 			return NULL;
 
-		/* ----------
-		 * Handle MATCH PARTIAL set null delete.
-		 * ----------
-		 */
+			/* ----------
+			 * Handle MATCH PARTIAL set null delete.
+			 * ----------
+			 */
 		case RI_MATCH_TYPE_PARTIAL:
 			elog(ERROR, "MATCH PARTIAL not yet supported");
 			return NULL;
@@ -2500,25 +2512,25 @@ RI_FKey_setdefault_del (FmgrInfo *proinfo)
  * ----------
  */
 HeapTuple
-RI_FKey_setdefault_upd (FmgrInfo *proinfo)
+RI_FKey_setdefault_upd(FmgrInfo *proinfo)
 {
-	TriggerData		   *trigdata;
-	int					tgnargs;
-	char			  **tgargs;
-	Relation			fk_rel;
-	Relation			pk_rel;
-	HeapTuple			new_row;
-	HeapTuple			old_row;
-	RI_QueryKey			qkey;
-	void			   *qplan;
-	Datum				upd_values[RI_MAX_NUMKEYS];
-	char				upd_nulls[RI_MAX_NUMKEYS + 1];
-	bool				isnull;
-	int					i;
-	int				 match_type;
+	TriggerData *trigdata;
+	int			tgnargs;
+	char	  **tgargs;
+	Relation	fk_rel;
+	Relation	pk_rel;
+	HeapTuple	new_row;
+	HeapTuple	old_row;
+	RI_QueryKey qkey;
+	void	   *qplan;
+	Datum		upd_values[RI_MAX_NUMKEYS];
+	char		upd_nulls[RI_MAX_NUMKEYS + 1];
+	bool		isnull;
+	int			i;
+	int			match_type;
 
 	trigdata = CurrentTriggerData;
-	CurrentTriggerData	= NULL;
+	CurrentTriggerData = NULL;
 	ReferentialIntegritySnapshotOverride = true;
 
 	/* ----------
@@ -2527,23 +2539,23 @@ RI_FKey_setdefault_upd (FmgrInfo *proinfo)
 	 */
 	if (trigdata == NULL)
 		elog(ERROR, "RI_FKey_setdefault_upd() not fired by trigger manager");
-	if (!TRIGGER_FIRED_AFTER(trigdata->tg_event) || 
-				!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
+	if (!TRIGGER_FIRED_AFTER(trigdata->tg_event) ||
+		!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
 		elog(ERROR, "RI_FKey_setdefault_upd() must be fired AFTER ROW");
 	if (!TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
 		elog(ERROR, "RI_FKey_setdefault_upd() must be fired for UPDATE");
 
 	/* ----------
-	 * Check for the correct # of call arguments 
+	 * Check for the correct # of call arguments
 	 * ----------
 	 */
 	tgnargs = trigdata->tg_trigger->tgnargs;
-	tgargs  = trigdata->tg_trigger->tgargs;
+	tgargs = trigdata->tg_trigger->tgargs;
 	if (tgnargs < 4 || (tgnargs % 2) != 0)
 		elog(ERROR, "wrong # of arguments in call to RI_FKey_setdefault_upd()");
 	if (tgnargs > RI_MAX_ARGUMENTS)
 		elog(ERROR, "too many keys (%d max) in call to RI_FKey_setdefault_upd()",
-						RI_MAX_NUMKEYS);
+			 RI_MAX_NUMKEYS);
 
 	/* ----------
 	 * Nothing to do if no column names to compare given
@@ -2557,8 +2569,8 @@ RI_FKey_setdefault_upd (FmgrInfo *proinfo)
 	 * the old tuple.
 	 * ----------
 	 */
-	fk_rel	= heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
-	pk_rel  = trigdata->tg_relation;
+	fk_rel = heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
+	pk_rel = trigdata->tg_relation;
 	new_row = trigdata->tg_newtuple;
 	old_row = trigdata->tg_trigtuple;
 
@@ -2566,19 +2578,19 @@ RI_FKey_setdefault_upd (FmgrInfo *proinfo)
 
 	switch (match_type)
 	{
-		/* ----------
-		 * SQL3 11.9 <referential constraint definition>
-		 *	Gereral rules 7) a) iii):
-		 * 		MATCH <UNSPECIFIED> or MATCH FULL
-		 *			... ON UPDATE SET DEFAULT
-		 * ----------
-		 */
+			/* ----------
+			 * SQL3 11.9 <referential constraint definition>
+			 *	Gereral rules 7) a) iii):
+			 *		MATCH <UNSPECIFIED> or MATCH FULL
+			 *			... ON UPDATE SET DEFAULT
+			 * ----------
+			 */
 		case RI_MATCH_TYPE_UNSPECIFIED:
 		case RI_MATCH_TYPE_FULL:
 			ri_BuildQueryKeyFull(&qkey, trigdata->tg_trigger->tgoid,
-									RI_PLAN_SETNULL_DEL_DOUPDATE,
-									fk_rel, pk_rel,
-									tgnargs, tgargs);
+								 RI_PLAN_SETNULL_DEL_DOUPDATE,
+								 fk_rel, pk_rel,
+								 tgnargs, tgargs);
 
 			switch (ri_NullCheck(pk_rel, old_row, &qkey, RI_KEYPAIR_PK_IDX))
 			{
@@ -2591,7 +2603,7 @@ RI_FKey_setdefault_upd (FmgrInfo *proinfo)
 					 */
 					heap_close(fk_rel, NoLock);
 					return NULL;
-					
+
 				case RI_KEYS_NONE_NULL:
 					/* ----------
 					 * Have a full qualified key - continue below
@@ -2606,7 +2618,7 @@ RI_FKey_setdefault_upd (FmgrInfo *proinfo)
 			 * ----------
 			 */
 			if (ri_KeysEqual(pk_rel, old_row, new_row, &qkey,
-													RI_KEYPAIR_PK_IDX))
+							 RI_KEYPAIR_PK_IDX))
 				return NULL;
 
 			if (SPI_connect() != SPI_OK_CONNECT)
@@ -2623,13 +2635,14 @@ RI_FKey_setdefault_upd (FmgrInfo *proinfo)
 				char		buf[256];
 				char		querystr[8192];
 				char		qualstr[8192];
-				char		*querysep;
-				char		*qualsep;
+				char	   *querysep;
+				char	   *qualsep;
 				Oid			queryoids[RI_MAX_NUMKEYS];
-				Plan		*spi_plan;
-				AttrDefault	*defval;
-				TargetEntry	*spi_qptle;
-				int			i, j;
+				Plan	   *spi_plan;
+				AttrDefault *defval;
+				TargetEntry *spi_qptle;
+				int			i,
+							j;
 
 				/* ----------
 				 * The query string built is
@@ -2641,31 +2654,33 @@ RI_FKey_setdefault_upd (FmgrInfo *proinfo)
 				 * how to compare these two types by '='.
 				 * ----------
 				 */
-				sprintf(querystr, "UPDATE \"%s\" SET", 
-									tgargs[RI_FK_RELNAME_ARGNO]);
+				sprintf(querystr, "UPDATE \"%s\" SET",
+						tgargs[RI_FK_RELNAME_ARGNO]);
 				qualstr[0] = '\0';
 				querysep = "";
 				qualsep = "WHERE";
 				for (i = 0; i < qkey.nkeypairs; i++)
 				{
-					/* MATCH <unspecified> - only change columns corresponding
-					 * to changed columns in pk_rel's key
+
+					/*
+					 * MATCH <unspecified> - only change columns
+					 * corresponding to changed columns in pk_rel's key
 					 */
 					if (match_type == RI_MATCH_TYPE_FULL ||
 						!ri_OneKeyEqual(pk_rel, i, old_row,
-										new_row, &qkey, RI_KEYPAIR_PK_IDX))
+									  new_row, &qkey, RI_KEYPAIR_PK_IDX))
 					{
-						sprintf(buf, "%s \"%s\" = NULL", querysep, 
-										tgargs[4 + i * 2]);
+						sprintf(buf, "%s \"%s\" = NULL", querysep,
+								tgargs[4 + i * 2]);
 						strcat(querystr, buf);
 						querysep = ",";
 					}
 					sprintf(buf, " %s \"%s\" = $%d", qualsep,
-										tgargs[4 + i * 2], i + 1);
+							tgargs[4 + i * 2], i + 1);
 					strcat(qualstr, buf);
 					qualsep = "AND";
 					queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
-									qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
+									 qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
 				}
 				strcat(querystr, qualstr);
 
@@ -2681,21 +2696,23 @@ RI_FKey_setdefault_upd (FmgrInfo *proinfo)
 				 * in the tuple constructor.
 				 * ----------
 				 */
-				spi_plan = (Plan *)lfirst(((_SPI_plan *)qplan)->ptlist);
+				spi_plan = (Plan *) lfirst(((_SPI_plan *) qplan)->ptlist);
 				if (fk_rel->rd_att->constr != NULL)
 					defval = fk_rel->rd_att->constr->defval;
 				else
 					defval = NULL;
 				for (i = 0; i < qkey.nkeypairs && defval != NULL; i++)
 				{
-					/* MATCH <unspecified> - only change columns corresponding
-					 * to changed columns in pk_rel's key.  This conditional
-					 * must match the one in the loop above that built the
-					 * SET attrn=NULL list.
+
+					/*
+					 * MATCH <unspecified> - only change columns
+					 * corresponding to changed columns in pk_rel's key.
+					 * This conditional must match the one in the loop
+					 * above that built the SET attrn=NULL list.
 					 */
 					if (match_type == RI_MATCH_TYPE_FULL ||
 						!ri_OneKeyEqual(pk_rel, i, old_row,
-										new_row, &qkey, RI_KEYPAIR_PK_IDX))
+									  new_row, &qkey, RI_KEYPAIR_PK_IDX))
 					{
 						/* ----------
 						 * For each key attribute lookup the tuple constructor
@@ -2704,8 +2721,8 @@ RI_FKey_setdefault_upd (FmgrInfo *proinfo)
 						 */
 						for (j = 0; j < fk_rel->rd_att->constr->num_defval; j++)
 						{
-							if (defval[j].adnum == 
-											qkey.keypair[i][RI_KEYPAIR_FK_IDX])
+							if (defval[j].adnum ==
+								qkey.keypair[i][RI_KEYPAIR_FK_IDX])
 							{
 								/* ----------
 								 * That's the one - push the expression
@@ -2713,12 +2730,12 @@ RI_FKey_setdefault_upd (FmgrInfo *proinfo)
 								 * ----------
 								 */
 								spi_qptle = (TargetEntry *)
-										nth(defval[j].adnum - 1,
+									nth(defval[j].adnum - 1,
 										spi_plan->targetlist);
 								spi_qptle->expr = stringToNode(defval[j].adbin);
 
 								break;
-							 }
+							}
 						}
 					}
 				}
@@ -2732,10 +2749,10 @@ RI_FKey_setdefault_upd (FmgrInfo *proinfo)
 			for (i = 0; i < qkey.nkeypairs; i++)
 			{
 				upd_values[i] = SPI_getbinval(old_row,
-									pk_rel->rd_att,
-									qkey.keypair[i][RI_KEYPAIR_PK_IDX],
-									&isnull);
-				if (isnull) 
+											  pk_rel->rd_att,
+									  qkey.keypair[i][RI_KEYPAIR_PK_IDX],
+											  &isnull);
+				if (isnull)
 					upd_nulls[i] = 'n';
 				else
 					upd_nulls[i] = ' ';
@@ -2748,16 +2765,16 @@ RI_FKey_setdefault_upd (FmgrInfo *proinfo)
 			 */
 			if (SPI_execp(qplan, upd_values, upd_nulls, 0) != SPI_OK_UPDATE)
 				elog(ERROR, "SPI_execp() failed in RI_FKey_setdefault_upd()");
-			
+
 			if (SPI_finish() != SPI_OK_FINISH)
 				elog(NOTICE, "SPI_finish() failed in RI_FKey_setdefault_upd()");
 
 			return NULL;
 
-		/* ----------
-		 * Handle MATCH PARTIAL set null delete.
-		 * ----------
-		 */
+			/* ----------
+			 * Handle MATCH PARTIAL set null delete.
+			 * ----------
+			 */
 		case RI_MATCH_TYPE_PARTIAL:
 			elog(ERROR, "MATCH PARTIAL not yet supported");
 			return NULL;
@@ -2782,31 +2799,31 @@ RI_FKey_setdefault_upd (FmgrInfo *proinfo)
  * ----------
  */
 bool
-RI_FKey_keyequal_upd (void)
+RI_FKey_keyequal_upd(void)
 {
-	TriggerData		   *trigdata;
-	int					tgnargs;
-	char			  **tgargs;
-	Relation			fk_rel;
-	Relation			pk_rel;
-	HeapTuple			new_row;
-	HeapTuple			old_row;
-	RI_QueryKey			qkey;
+	TriggerData *trigdata;
+	int			tgnargs;
+	char	  **tgargs;
+	Relation	fk_rel;
+	Relation	pk_rel;
+	HeapTuple	new_row;
+	HeapTuple	old_row;
+	RI_QueryKey qkey;
 
 	trigdata = CurrentTriggerData;
-	CurrentTriggerData	= NULL;
+	CurrentTriggerData = NULL;
 
 	/* ----------
-	 * Check for the correct # of call arguments 
+	 * Check for the correct # of call arguments
 	 * ----------
 	 */
 	tgnargs = trigdata->tg_trigger->tgnargs;
-	tgargs  = trigdata->tg_trigger->tgargs;
+	tgargs = trigdata->tg_trigger->tgargs;
 	if (tgnargs < 4 || (tgnargs % 2) != 0)
 		elog(ERROR, "wrong # of arguments in call to RI_FKey_keyequal_upd()");
 	if (tgnargs > RI_MAX_ARGUMENTS)
 		elog(ERROR, "too many keys (%d max) in call to RI_FKey_keyequal_upd()",
-						RI_MAX_NUMKEYS);
+			 RI_MAX_NUMKEYS);
 
 	/* ----------
 	 * Nothing to do if no column names to compare given
@@ -2820,23 +2837,23 @@ RI_FKey_keyequal_upd (void)
 	 * the new and old tuple.
 	 * ----------
 	 */
-	fk_rel	= heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
-	pk_rel  = trigdata->tg_relation;
+	fk_rel = heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
+	pk_rel = trigdata->tg_relation;
 	new_row = trigdata->tg_newtuple;
 	old_row = trigdata->tg_trigtuple;
 
 	switch (ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO]))
 	{
-		/* ----------
-		 * MATCH <UNSPECIFIED>
-		 * ----------
-		 */
+			/* ----------
+			 * MATCH <UNSPECIFIED>
+			 * ----------
+			 */
 		case RI_MATCH_TYPE_UNSPECIFIED:
 		case RI_MATCH_TYPE_FULL:
 			ri_BuildQueryKeyFull(&qkey, trigdata->tg_trigger->tgoid,
-									0,
-									fk_rel, pk_rel,
-									tgnargs, tgargs);
+								 0,
+								 fk_rel, pk_rel,
+								 tgnargs, tgargs);
 			heap_close(fk_rel, NoLock);
 
 			/* ----------
@@ -2844,12 +2861,12 @@ RI_FKey_keyequal_upd (void)
 			 * ----------
 			 */
 			return ri_KeysEqual(pk_rel, old_row, new_row, &qkey,
-													RI_KEYPAIR_PK_IDX);
+								RI_KEYPAIR_PK_IDX);
 
-		/* ----------
-		 * Handle MATCH PARTIAL set null delete.
-		 * ----------
-		 */
+			/* ----------
+			 * Handle MATCH PARTIAL set null delete.
+			 * ----------
+			 */
 		case RI_MATCH_TYPE_PARTIAL:
 			elog(ERROR, "MATCH PARTIAL not yet supported");
 			break;
@@ -2914,26 +2931,26 @@ ri_DetermineMatchType(char *str)
  *	At least for MATCH FULL this builds a unique key per plan.
  * ----------
  */
-static void 
+static void
 ri_BuildQueryKeyFull(RI_QueryKey *key, Oid constr_id, int32 constr_queryno,
-							Relation fk_rel, Relation pk_rel,
-							int argc, char **argv)
+					 Relation fk_rel, Relation pk_rel,
+					 int argc, char **argv)
 {
-	int 				i;
-	int					j;
-	int					fno;
+	int			i;
+	int			j;
+	int			fno;
 
 	/* ----------
 	 * Initialize the key and fill in type, oid's and number of keypairs
 	 * ----------
 	 */
-	memset ((void *)key, 0, sizeof(RI_QueryKey));
-	key->constr_type	= RI_MATCH_TYPE_FULL;
-	key->constr_id		= constr_id;
-	key->constr_queryno	= constr_queryno;
-	key->fk_relid		= fk_rel->rd_id;
-	key->pk_relid		= pk_rel->rd_id;
-	key->nkeypairs		= (argc - RI_FIRST_ATTNAME_ARGNO) / 2;
+	memset((void *) key, 0, sizeof(RI_QueryKey));
+	key->constr_type = RI_MATCH_TYPE_FULL;
+	key->constr_id = constr_id;
+	key->constr_queryno = constr_queryno;
+	key->fk_relid = fk_rel->rd_id;
+	key->pk_relid = pk_rel->rd_id;
+	key->nkeypairs = (argc - RI_FIRST_ATTNAME_ARGNO) / 2;
 
 	/* ----------
 	 * Lookup the attribute numbers of the arguments to the trigger call
@@ -2945,17 +2962,17 @@ ri_BuildQueryKeyFull(RI_QueryKey *key, Oid constr_id, int32 constr_queryno,
 		fno = SPI_fnumber(fk_rel->rd_att, argv[j]);
 		if (fno == SPI_ERROR_NOATTRIBUTE)
 			elog(ERROR, "constraint %s: table %s does not have an attribute %s",
-					argv[RI_CONSTRAINT_NAME_ARGNO],
-					argv[RI_FK_RELNAME_ARGNO],
-					argv[j]);
+				 argv[RI_CONSTRAINT_NAME_ARGNO],
+				 argv[RI_FK_RELNAME_ARGNO],
+				 argv[j]);
 		key->keypair[i][RI_KEYPAIR_FK_IDX] = fno;
 
 		fno = SPI_fnumber(pk_rel->rd_att, argv[j + 1]);
 		if (fno == SPI_ERROR_NOATTRIBUTE)
 			elog(ERROR, "constraint %s: table %s does not have an attribute %s",
-					argv[RI_CONSTRAINT_NAME_ARGNO],
-					argv[RI_PK_RELNAME_ARGNO],
-					argv[j + 1]);
+				 argv[RI_CONSTRAINT_NAME_ARGNO],
+				 argv[RI_PK_RELNAME_ARGNO],
+				 argv[j + 1]);
 		key->keypair[i][RI_KEYPAIR_PK_IDX] = fno;
 	}
 
@@ -2971,13 +2988,13 @@ ri_BuildQueryKeyFull(RI_QueryKey *key, Oid constr_id, int32 constr_queryno,
  *	Returns one of RI_KEYS_ALL_NULL, RI_KEYS_NONE_NULL or RI_KEYS_SOME_NULL.
  * ----------
  */
-static int 
+static int
 ri_NullCheck(Relation rel, HeapTuple tup, RI_QueryKey *key, int pairidx)
 {
-	int				i;
-	bool			isnull;
-	bool			allnull  = true;
-	bool			nonenull = true;
+	int			i;
+	bool		isnull;
+	bool		allnull = true;
+	bool		nonenull = true;
 
 	for (i = 0; i < key->nkeypairs; i++)
 	{
@@ -3012,16 +3029,16 @@ ri_InitHashTables(void)
 	HASHCTL		ctl;
 
 	memset(&ctl, 0, sizeof(ctl));
-	ctl.keysize		= sizeof(RI_QueryKey);
-	ctl.datasize	= sizeof(void *);
+	ctl.keysize = sizeof(RI_QueryKey);
+	ctl.datasize = sizeof(void *);
 	ri_query_cache = hash_create(RI_INIT_QUERYHASHSIZE, &ctl, HASH_ELEM);
 
 	memset(&ctl, 0, sizeof(ctl));
-	ctl.keysize		= sizeof(Oid);
-	ctl.datasize	= sizeof(Oid) + sizeof(FmgrInfo);
-	ctl.hash		= tag_hash;
-	ri_opreq_cache = hash_create(RI_INIT_OPREQHASHSIZE, &ctl, 
-												HASH_ELEM | HASH_FUNCTION);
+	ctl.keysize = sizeof(Oid);
+	ctl.datasize = sizeof(Oid) + sizeof(FmgrInfo);
+	ctl.hash = tag_hash;
+	ri_opreq_cache = hash_create(RI_INIT_OPREQHASHSIZE, &ctl,
+								 HASH_ELEM | HASH_FUNCTION);
 }
 
 
@@ -3035,8 +3052,8 @@ ri_InitHashTables(void)
 static void *
 ri_FetchPreparedPlan(RI_QueryKey *key)
 {
-	RI_QueryHashEntry  *entry;
-	bool				found;
+	RI_QueryHashEntry *entry;
+	bool		found;
 
 	/* ----------
 	 * On the first call initialize the hashtable
@@ -3049,8 +3066,8 @@ ri_FetchPreparedPlan(RI_QueryKey *key)
 	 * Lookup for the key
 	 * ----------
 	 */
-	entry = (RI_QueryHashEntry *)hash_search(ri_query_cache, 
-										(char *)key, HASH_FIND, &found);
+	entry = (RI_QueryHashEntry *) hash_search(ri_query_cache,
+										(char *) key, HASH_FIND, &found);
 	if (entry == NULL)
 		elog(FATAL, "error in RI plan cache");
 	if (!found)
@@ -3068,8 +3085,8 @@ ri_FetchPreparedPlan(RI_QueryKey *key)
 static void
 ri_HashPreparedPlan(RI_QueryKey *key, void *plan)
 {
-	RI_QueryHashEntry  *entry;
-	bool				found;
+	RI_QueryHashEntry *entry;
+	bool		found;
 
 	/* ----------
 	 * On the first call initialize the hashtable
@@ -3082,8 +3099,8 @@ ri_HashPreparedPlan(RI_QueryKey *key, void *plan)
 	 * Add the new plan.
 	 * ----------
 	 */
-	entry = (RI_QueryHashEntry *)hash_search(ri_query_cache, 
-										(char *)key, HASH_ENTER, &found);
+	entry = (RI_QueryHashEntry *) hash_search(ri_query_cache,
+									   (char *) key, HASH_ENTER, &found);
 	if (entry == NULL)
 		elog(FATAL, "can't insert into RI plan cache");
 	entry->plan = plan;
@@ -3097,14 +3114,14 @@ ri_HashPreparedPlan(RI_QueryKey *key, void *plan)
  * ----------
  */
 static bool
-ri_KeysEqual(Relation rel, HeapTuple oldtup, HeapTuple newtup, 
-							RI_QueryKey *key, int pairidx)
+ri_KeysEqual(Relation rel, HeapTuple oldtup, HeapTuple newtup,
+			 RI_QueryKey *key, int pairidx)
 {
-	int				i;
-	Oid				typeid;
-	Datum			oldvalue;
-	Datum			newvalue;
-	bool			isnull;
+	int			i;
+	Oid			typeid;
+	Datum		oldvalue;
+	Datum		newvalue;
+	bool		isnull;
 
 	for (i = 0; i < key->nkeypairs; i++)
 	{
@@ -3112,8 +3129,8 @@ ri_KeysEqual(Relation rel, HeapTuple oldtup, HeapTuple newtup,
 		 * Get one attributes oldvalue. If it is NULL - they're not equal.
 		 * ----------
 		 */
-		oldvalue = SPI_getbinval(oldtup, rel->rd_att, 
-									key->keypair[i][pairidx], &isnull);
+		oldvalue = SPI_getbinval(oldtup, rel->rd_att,
+								 key->keypair[i][pairidx], &isnull);
 		if (isnull)
 			return false;
 
@@ -3121,8 +3138,8 @@ ri_KeysEqual(Relation rel, HeapTuple oldtup, HeapTuple newtup,
 		 * Get one attributes oldvalue. If it is NULL - they're not equal.
 		 * ----------
 		 */
-		newvalue = SPI_getbinval(newtup, rel->rd_att, 
-									key->keypair[i][pairidx], &isnull);
+		newvalue = SPI_getbinval(newtup, rel->rd_att,
+								 key->keypair[i][pairidx], &isnull);
 		if (isnull)
 			return false;
 
@@ -3147,15 +3164,15 @@ ri_KeysEqual(Relation rel, HeapTuple oldtup, HeapTuple newtup,
  * ----------
  */
 static bool
-ri_AllKeysUnequal(Relation rel, HeapTuple oldtup, HeapTuple newtup, 
-							RI_QueryKey *key, int pairidx)
+ri_AllKeysUnequal(Relation rel, HeapTuple oldtup, HeapTuple newtup,
+				  RI_QueryKey *key, int pairidx)
 {
-	int				i;
-	Oid				typeid;
-	Datum			oldvalue;
-	Datum			newvalue;
-	bool			isnull;
-	bool			keys_unequal;
+	int			i;
+	Oid			typeid;
+	Datum		oldvalue;
+	Datum		newvalue;
+	bool		isnull;
+	bool		keys_unequal;
 
 	keys_unequal = true;
 	for (i = 0; keys_unequal && i < key->nkeypairs; i++)
@@ -3164,8 +3181,8 @@ ri_AllKeysUnequal(Relation rel, HeapTuple oldtup, HeapTuple newtup,
 		 * Get one attributes oldvalue. If it is NULL - they're not equal.
 		 * ----------
 		 */
-		oldvalue = SPI_getbinval(oldtup, rel->rd_att, 
-									key->keypair[i][pairidx], &isnull);
+		oldvalue = SPI_getbinval(oldtup, rel->rd_att,
+								 key->keypair[i][pairidx], &isnull);
 		if (isnull)
 			continue;
 
@@ -3173,8 +3190,8 @@ ri_AllKeysUnequal(Relation rel, HeapTuple oldtup, HeapTuple newtup,
 		 * Get one attributes oldvalue. If it is NULL - they're not equal.
 		 * ----------
 		 */
-		newvalue = SPI_getbinval(newtup, rel->rd_att, 
-									key->keypair[i][pairidx], &isnull);
+		newvalue = SPI_getbinval(newtup, rel->rd_att,
+								 key->keypair[i][pairidx], &isnull);
 		if (isnull)
 			continue;
 
@@ -3198,25 +3215,25 @@ ri_AllKeysUnequal(Relation rel, HeapTuple oldtup, HeapTuple newtup,
  *
  *	Check if one key value in OLD and NEW is equal.
  *
- *  ri_KeysEqual could call this but would run a bit slower.  For
- *  now, let's duplicate the code.
+ *	ri_KeysEqual could call this but would run a bit slower.  For
+ *	now, let's duplicate the code.
  * ----------
  */
 static bool
-ri_OneKeyEqual(Relation rel, int column, HeapTuple oldtup, HeapTuple newtup, 
-							RI_QueryKey *key, int pairidx)
+ri_OneKeyEqual(Relation rel, int column, HeapTuple oldtup, HeapTuple newtup,
+			   RI_QueryKey *key, int pairidx)
 {
-	Oid				typeid;
-	Datum			oldvalue;
-	Datum			newvalue;
-	bool			isnull;
+	Oid			typeid;
+	Datum		oldvalue;
+	Datum		newvalue;
+	bool		isnull;
 
 	/* ----------
 	 * Get one attributes oldvalue. If it is NULL - they're not equal.
 	 * ----------
 	 */
-	oldvalue = SPI_getbinval(oldtup, rel->rd_att, 
-								key->keypair[column][pairidx], &isnull);
+	oldvalue = SPI_getbinval(oldtup, rel->rd_att,
+							 key->keypair[column][pairidx], &isnull);
 	if (isnull)
 		return false;
 
@@ -3224,8 +3241,8 @@ ri_OneKeyEqual(Relation rel, int column, HeapTuple oldtup, HeapTuple newtup,
 	 * Get one attributes oldvalue. If it is NULL - they're not equal.
 	 * ----------
 	 */
-	newvalue = SPI_getbinval(newtup, rel->rd_att, 
-								key->keypair[column][pairidx], &isnull);
+	newvalue = SPI_getbinval(newtup, rel->rd_att,
+							 key->keypair[column][pairidx], &isnull);
 	if (isnull)
 		return false;
 
@@ -3236,7 +3253,7 @@ ri_OneKeyEqual(Relation rel, int column, HeapTuple oldtup, HeapTuple newtup,
 	 */
 	typeid = SPI_gettypeid(rel->rd_att, key->keypair[column][pairidx]);
 	if (!ri_AttributesEqual(typeid, oldvalue, newvalue))
-			return false;
+		return false;
 
 	return true;
 }
@@ -3252,9 +3269,9 @@ ri_OneKeyEqual(Relation rel, int column, HeapTuple oldtup, HeapTuple newtup,
 static bool
 ri_AttributesEqual(Oid typeid, Datum oldvalue, Datum newvalue)
 {
-	RI_OpreqHashEntry	   *entry;
-	bool					found;
-	Datum					result;
+	RI_OpreqHashEntry *entry;
+	bool		found;
+	Datum		result;
 
 	/* ----------
 	 * On the first call initialize the hashtable
@@ -3267,8 +3284,8 @@ ri_AttributesEqual(Oid typeid, Datum oldvalue, Datum newvalue)
 	 * Try to find the '=' operator for this type in our cache
 	 * ----------
 	 */
-	entry = (RI_OpreqHashEntry *)hash_search(ri_opreq_cache,
-										(char *)&typeid, HASH_FIND, &found);
+	entry = (RI_OpreqHashEntry *) hash_search(ri_opreq_cache,
+									(char *) &typeid, HASH_FIND, &found);
 	if (entry == NULL)
 		elog(FATAL, "error in RI operator cache");
 
@@ -3279,22 +3296,22 @@ ri_AttributesEqual(Oid typeid, Datum oldvalue, Datum newvalue)
 	 */
 	if (!found)
 	{
-		HeapTuple			opr_tup;
-		Form_pg_operator	opr_struct;
+		HeapTuple	opr_tup;
+		Form_pg_operator opr_struct;
 
 		opr_tup = SearchSysCacheTuple(OPERNAME,
-							PointerGetDatum("="),
-							ObjectIdGetDatum(typeid),
-							ObjectIdGetDatum(typeid),
-							CharGetDatum('b'));
+									  PointerGetDatum("="),
+									  ObjectIdGetDatum(typeid),
+									  ObjectIdGetDatum(typeid),
+									  CharGetDatum('b'));
 
 		if (!HeapTupleIsValid(opr_tup))
 			elog(ERROR, "ri_AttributesEqual(): cannot find '=' operator "
-						"for type %d", typeid);
+				 "for type %d", typeid);
 		opr_struct = (Form_pg_operator) GETSTRUCT(opr_tup);
 
-		entry = (RI_OpreqHashEntry *)hash_search(ri_opreq_cache,
-										(char *)&typeid, HASH_ENTER, &found);
+		entry = (RI_OpreqHashEntry *) hash_search(ri_opreq_cache,
+								   (char *) &typeid, HASH_ENTER, &found);
 		if (entry == NULL)
 			elog(FATAL, "can't insert into RI operator cache");
 
@@ -3307,8 +3324,6 @@ ri_AttributesEqual(Oid typeid, Datum oldvalue, Datum newvalue)
 	 * ----------
 	 */
 	fmgr_info(entry->oprfnid, &(entry->oprfmgrinfo));
-	result = (Datum)(*fmgr_faddr(&(entry->oprfmgrinfo)))(oldvalue, newvalue);
-	return (bool)result;
+	result = (Datum) (*fmgr_faddr(&(entry->oprfmgrinfo))) (oldvalue, newvalue);
+	return (bool) result;
 }
-
-
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 9397ec6c0d3acf66977777a22030a52a70bf1156..69305acf55a45f49ec4816c53ec7ef4d60222368 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -3,7 +3,7 @@
  *			  out of its tuple
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.47 2000/03/17 02:36:23 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.48 2000/04/12 17:15:51 momjian Exp $
  *
  *	  This software is copyrighted by Jan Wieck - Hamburg.
  *
@@ -66,7 +66,8 @@ typedef struct
 	bool		varprefix;		/* TRUE to print prefixes on Vars */
 } deparse_context;
 
-typedef struct {
+typedef struct
+{
 	Index		rt_index;
 	int			levelsup;
 } check_if_rte_used_context;
@@ -113,7 +114,7 @@ static char *get_relation_name(Oid relid);
 static char *get_attribute_name(Oid relid, int2 attnum);
 static bool check_if_rte_used(Node *node, Index rt_index, int levelsup);
 static bool check_if_rte_used_walker(Node *node,
-									 check_if_rte_used_context *context);
+						 check_if_rte_used_context *context);
 
 #define inherit_marker(rte)  ((rte)->inh ? "*" : "")
 
@@ -133,7 +134,7 @@ pg_get_ruledef(NameData *rname)
 	int			spirc;
 	HeapTuple	ruletup;
 	TupleDesc	rulettc;
-	StringInfoData	buf;
+	StringInfoData buf;
 	int			len;
 
 	/* ----------
@@ -231,7 +232,7 @@ pg_get_viewdef(NameData *rname)
 	int			spirc;
 	HeapTuple	ruletup;
 	TupleDesc	rulettc;
-	StringInfoData	buf;
+	StringInfoData buf;
 	int			len;
 	char		name1[NAMEDATALEN + 5];
 	char		name2[NAMEDATALEN + 5];
@@ -338,8 +339,8 @@ pg_get_indexdef(Oid indexrelid)
 	int			spirc;
 	int			len;
 	int			keyno;
-	StringInfoData	buf;
-	StringInfoData	keybuf;
+	StringInfoData buf;
+	StringInfoData keybuf;
 	char	   *sep;
 
 	/* ----------
@@ -427,8 +428,8 @@ pg_get_indexdef(Oid indexrelid)
 	initStringInfo(&buf);
 	appendStringInfo(&buf, "CREATE %sINDEX %s ON %s USING %s (",
 					 idxrec->indisunique ? "UNIQUE " : "",
-					 quote_identifier(pstrdup(NameStr(idxrelrec->relname))),
-					 quote_identifier(pstrdup(NameStr(indrelrec->relname))),
+				  quote_identifier(pstrdup(NameStr(idxrelrec->relname))),
+				  quote_identifier(pstrdup(NameStr(indrelrec->relname))),
 					 quote_identifier(SPI_getvalue(spi_tup, spi_ttc,
 												   spi_fno)));
 
@@ -451,8 +452,8 @@ pg_get_indexdef(Oid indexrelid)
 		 * ----------
 		 */
 		appendStringInfo(&keybuf, "%s",
-				quote_identifier(get_attribute_name(idxrec->indrelid,
-													idxrec->indkey[keyno])));
+					quote_identifier(get_attribute_name(idxrec->indrelid,
+												idxrec->indkey[keyno])));
 
 		/* ----------
 		 * If not a functional index, add the operator class name
@@ -472,8 +473,8 @@ pg_get_indexdef(Oid indexrelid)
 			spi_ttc = SPI_tuptable->tupdesc;
 			spi_fno = SPI_fnumber(spi_ttc, "opcname");
 			appendStringInfo(&keybuf, " %s",
-							 quote_identifier(SPI_getvalue(spi_tup, spi_ttc,
-														   spi_fno)));
+						  quote_identifier(SPI_getvalue(spi_tup, spi_ttc,
+														spi_fno)));
 		}
 	}
 
@@ -493,7 +494,7 @@ pg_get_indexdef(Oid indexrelid)
 
 		procStruct = (Form_pg_proc) GETSTRUCT(proctup);
 		appendStringInfo(&buf, "%s(%s) ",
-						 quote_identifier(pstrdup(NameStr(procStruct->proname))),
+				 quote_identifier(pstrdup(NameStr(procStruct->proname))),
 						 keybuf.data);
 
 		spi_args[0] = ObjectIdGetDatum(idxrec->indclass[0]);
@@ -589,8 +590,8 @@ pg_get_userbyid(int32 uid)
  * tree (ie, not the raw output of gram.y).
  *
  * rangetables is a List of Lists of RangeTblEntry nodes: first sublist is for
- * varlevelsup = 0, next for varlevelsup = 1, etc.  In each sublist the first
- * item is for varno = 1, next varno = 2, etc.  (Each sublist has the same
+ * varlevelsup = 0, next for varlevelsup = 1, etc.	In each sublist the first
+ * item is for varno = 1, next varno = 2, etc.	(Each sublist has the same
  * format as the rtable list of a parsetree or query.)
  *
  * forceprefix is TRUE to force all Vars to be prefixed with their table names.
@@ -603,8 +604,8 @@ pg_get_userbyid(int32 uid)
 char *
 deparse_expression(Node *expr, List *rangetables, bool forceprefix)
 {
-	StringInfoData	buf;
-	deparse_context	context;
+	StringInfoData buf;
+	deparse_context context;
 
 	initStringInfo(&buf);
 	context.buf = &buf;
@@ -710,7 +711,7 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc)
 	{
 		Node	   *qual;
 		Query	   *query;
-		deparse_context	context;
+		deparse_context context;
 
 		appendStringInfo(buf, " WHERE ");
 
@@ -834,7 +835,7 @@ make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc)
 static void
 get_query_def(Query *query, StringInfo buf, List *parentrtables)
 {
-	deparse_context	context;
+	deparse_context context;
 
 	context.buf = buf;
 	context.rangetables = lcons(query->rtable, parentrtables);
@@ -954,7 +955,7 @@ get_select_query_def(Query *query, deparse_context *context)
 		get_rule_expr(tle->expr, context);
 
 		/* Check if we must say AS ... */
-		if (! IsA(tle->expr, Var))
+		if (!IsA(tle->expr, Var))
 			tell_as = strcmp(tle->resdom->resname, "?column?");
 		else
 		{
@@ -996,11 +997,12 @@ get_select_query_def(Query *query, deparse_context *context)
 				appendStringInfo(buf, "%s%s",
 								 quote_identifier(rte->relname),
 								 inherit_marker(rte));
+
 				/*
 				 * NOTE: SQL92 says you can't write column aliases unless
-				 * you write a table alias --- so, if there's an alias list,
-				 * make sure we emit a table alias even if it's the same as
-				 * the table's real name.
+				 * you write a table alias --- so, if there's an alias
+				 * list, make sure we emit a table alias even if it's the
+				 * same as the table's real name.
 				 */
 				if ((rte->ref != NULL)
 					&& ((strcmp(rte->relname, rte->ref->relname) != 0)
@@ -1010,7 +1012,7 @@ get_select_query_def(Query *query, deparse_context *context)
 									 quote_identifier(rte->ref->relname));
 					if (rte->ref->attrs != NIL)
 					{
-						List *col;
+						List	   *col;
 
 						appendStringInfo(buf, " (");
 						foreach(col, rte->ref->attrs)
@@ -1018,7 +1020,7 @@ get_select_query_def(Query *query, deparse_context *context)
 							if (col != rte->ref->attrs)
 								appendStringInfo(buf, ", ");
 							appendStringInfo(buf, "%s",
-											 quote_identifier(strVal(lfirst(col))));
+								  quote_identifier(strVal(lfirst(col))));
 						}
 						appendStringInfoChar(buf, ')');
 					}
@@ -1042,7 +1044,7 @@ get_select_query_def(Query *query, deparse_context *context)
 		foreach(l, query->groupClause)
 		{
 			GroupClause *grp = (GroupClause *) lfirst(l);
-			Node *groupexpr;
+			Node	   *groupexpr;
 
 			groupexpr = get_sortgroupclause_expr(grp,
 												 query->targetList);
@@ -1228,8 +1230,8 @@ get_delete_query_def(Query *query, deparse_context *context)
 static RangeTblEntry *
 get_rte_for_var(Var *var, deparse_context *context)
 {
-	List   *rtlist = context->rangetables;
-	int		sup = var->varlevelsup;
+	List	   *rtlist = context->rangetables;
+	int			sup = var->varlevelsup;
 
 	while (sup-- > 0)
 		rtlist = lnext(rtlist);
@@ -1281,11 +1283,11 @@ get_rule_expr(Node *node, deparse_context *context)
 						appendStringInfo(buf, "old.");
 					else
 						appendStringInfo(buf, "%s.",
-										 quote_identifier(rte->ref->relname));
+									quote_identifier(rte->ref->relname));
 				}
 				appendStringInfo(buf, "%s",
-						quote_identifier(get_attribute_name(rte->relid,
-															var->varattno)));
+						  quote_identifier(get_attribute_name(rte->relid,
+														var->varattno)));
 			}
 			break;
 
@@ -1307,7 +1309,7 @@ get_rule_expr(Node *node, deparse_context *context)
 							/* binary operator */
 							get_rule_expr((Node *) lfirst(args), context);
 							appendStringInfo(buf, " %s ",
-									get_opname(((Oper *) expr->oper)->opno));
+								get_opname(((Oper *) expr->oper)->opno));
 							get_rule_expr((Node *) lsecond(args), context);
 						}
 						else
@@ -1318,7 +1320,7 @@ get_rule_expr(Node *node, deparse_context *context)
 							Form_pg_operator optup;
 
 							tp = SearchSysCacheTuple(OPEROID,
-													 ObjectIdGetDatum(opno),
+												  ObjectIdGetDatum(opno),
 													 0, 0, 0);
 							Assert(HeapTupleIsValid(tp));
 							optup = (Form_pg_operator) GETSTRUCT(tp);
@@ -1435,7 +1437,7 @@ get_rule_expr(Node *node, deparse_context *context)
 				appendStringInfoChar(buf, '(');
 				get_rule_expr(relabel->arg, context);
 				typetup = SearchSysCacheTuple(TYPEOID,
-									ObjectIdGetDatum(relabel->resulttype),
+								   ObjectIdGetDatum(relabel->resulttype),
 											  0, 0, 0);
 				if (!HeapTupleIsValid(typetup))
 					elog(ERROR, "cache lookup of type %u failed",
@@ -1510,7 +1512,8 @@ get_func_expr(Expr *expr, deparse_context *context)
 	proname = pstrdup(NameStr(procStruct->proname));
 
 	/*
-	 * nullvalue() and nonnullvalue() should get turned into special syntax
+	 * nullvalue() and nonnullvalue() should get turned into special
+	 * syntax
 	 */
 	if (procStruct->pronargs == 1 && procStruct->proargtypes[0] == InvalidOid)
 	{
@@ -1540,18 +1543,19 @@ get_func_expr(Expr *expr, deparse_context *context)
 
 		/*
 		 * Strip off any RelabelType on the input, so we don't print
-		 * redundancies like x::bpchar::char(8).
-		 * XXX Are there any cases where this is a bad idea?
+		 * redundancies like x::bpchar::char(8). XXX Are there any cases
+		 * where this is a bad idea?
 		 */
 		if (IsA(arg, RelabelType))
 			arg = ((RelabelType *) arg)->arg;
 		appendStringInfoChar(buf, '(');
 		get_rule_expr(arg, context);
 		appendStringInfo(buf, ")::");
+
 		/*
-		 * Show typename with appropriate length decoration.
-		 * Note that since exprIsLengthCoercion succeeded, the function
-		 * name is the same as its output type name.
+		 * Show typename with appropriate length decoration. Note that
+		 * since exprIsLengthCoercion succeeded, the function name is the
+		 * same as its output type name.
 		 */
 		if (strcmp(proname, "bpchar") == 0)
 		{
@@ -1571,7 +1575,7 @@ get_func_expr(Expr *expr, deparse_context *context)
 		{
 			if (coercedTypmod >= (int32) VARHDRSZ)
 				appendStringInfo(buf, "numeric(%d,%d)",
-								 ((coercedTypmod - VARHDRSZ) >> 16) & 0xffff,
+							 ((coercedTypmod - VARHDRSZ) >> 16) & 0xffff,
 								 (coercedTypmod - VARHDRSZ) & 0xffff);
 			else
 				appendStringInfo(buf, "numeric");
@@ -1621,8 +1625,8 @@ get_tle_expr(TargetEntry *tle, deparse_context *context)
 	int32		coercedTypmod;
 
 	/*
-	 * If top level is a length coercion to the correct length, suppress it;
-	 * else dump the expression normally.
+	 * If top level is a length coercion to the correct length, suppress
+	 * it; else dump the expression normally.
 	 */
 	if (tle->resdom->restypmod >= 0 &&
 		exprIsLengthCoercion((Node *) expr, &coercedTypmod) &&
@@ -1659,10 +1663,11 @@ get_const_expr(Const *constval, deparse_context *context)
 
 	if (constval->constisnull)
 	{
+
 		/*
 		 * Always label the type of a NULL constant.  This not only
-		 * prevents misdecisions about the type, but it ensures that
-		 * our output is a valid b_expr.
+		 * prevents misdecisions about the type, but it ensures that our
+		 * output is a valid b_expr.
 		 */
 		extval = pstrdup(NameStr(typeStruct->typname));
 		appendStringInfo(buf, "NULL::%s", quote_identifier(extval));
@@ -1681,20 +1686,21 @@ get_const_expr(Const *constval, deparse_context *context)
 		case INT4OID:
 		case OIDOID:			/* int types */
 		case FLOAT4OID:
-		case FLOAT8OID:			/* float types */
+		case FLOAT8OID: /* float types */
 			/* These types are printed without quotes */
 			appendStringInfo(buf, extval);
 			break;
 		default:
+
 			/*
 			 * We must quote any funny characters in the constant's
-			 * representation.
-			 * XXX Any MULTIBYTE considerations here?
+			 * representation. XXX Any MULTIBYTE considerations here?
 			 */
 			appendStringInfoChar(buf, '\'');
 			for (valptr = extval; *valptr; valptr++)
 			{
-				char	ch = *valptr;
+				char		ch = *valptr;
+
 				if (ch == '\'' || ch == '\\')
 				{
 					appendStringInfoChar(buf, '\\');
@@ -1818,10 +1824,11 @@ get_sublink_expr(Node *node, deparse_context *context)
 static char *
 quote_identifier(char *ident)
 {
+
 	/*
 	 * Can avoid quoting if ident starts with a lowercase letter and
-	 * contains only lowercase letters, digits, and underscores,
-	 * *and* is not any SQL keyword.  Otherwise, supply quotes.
+	 * contains only lowercase letters, digits, and underscores, *and* is
+	 * not any SQL keyword.  Otherwise, supply quotes.
 	 */
 	bool		safe;
 	char	   *result;
@@ -1835,20 +1842,21 @@ quote_identifier(char *ident)
 	{
 		char	   *ptr;
 
-		for (ptr = ident+1; *ptr; ptr++)
+		for (ptr = ident + 1; *ptr; ptr++)
 		{
-			char	ch = *ptr;
+			char		ch = *ptr;
 
 			safe = ((ch >= 'a' && ch <= 'z') ||
 					(ch >= '0' && ch <= '9') ||
 					(ch == '_'));
-			if (! safe)
+			if (!safe)
 				break;
 		}
 	}
 
 	if (safe)
 	{
+
 		/*
 		 * Check for keyword.  This test is overly strong, since many of
 		 * the "keywords" known to the parser are usable as column names,
@@ -1955,7 +1963,11 @@ check_if_rte_used_walker(Node *node,
 			check_if_rte_used(query->havingQual,
 							  context->rt_index, context->levelsup + 1))
 			return true;
-		/* fall through to let expression_tree_walker examine lefthand args */
+
+		/*
+		 * fall through to let expression_tree_walker examine lefthand
+		 * args
+		 */
 	}
 	return expression_tree_walker(node, check_if_rte_used_walker,
 								  (void *) context);
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index 7e03b10d43105615d9befae1faa2f69e2d5211d6..fc6852c14902ebc5b94b100d35a81b4377aebe11 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -15,7 +15,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.63 2000/04/09 04:31:37 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.64 2000/04/12 17:15:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -45,25 +45,25 @@
 #define FunctionalSelectivity(nIndKeys,attNum) ((attNum)==InvalidAttrNumber)
 
 /* default selectivity estimate for equalities such as "A = b" */
-#define DEFAULT_EQ_SEL  0.01
+#define DEFAULT_EQ_SEL	0.01
 
 /* default selectivity estimate for inequalities such as "A < b" */
 #define DEFAULT_INEQ_SEL  (1.0 / 3.0)
 
 static bool convert_string_to_scalar(char *str, int strlength,
-									 double *scaleval);
+						 double *scaleval);
 static void getattproperties(Oid relid, AttrNumber attnum,
-							 Oid *typid,
-							 int *typlen,
-							 bool *typbyval,
-							 int32 *typmod);
+				 Oid *typid,
+				 int *typlen,
+				 bool *typbyval,
+				 int32 *typmod);
 static bool getattstatistics(Oid relid, AttrNumber attnum,
-							 Oid typid, int32 typmod,
-							 double *nullfrac,
-							 double *commonfrac,
-							 Datum *commonval,
-							 Datum *loval,
-							 Datum *hival);
+				 Oid typid, int32 typmod,
+				 double *nullfrac,
+				 double *commonfrac,
+				 Datum *commonval,
+				 Datum *loval,
+				 Datum *hival);
 
 
 /*
@@ -109,15 +109,17 @@ eqsel(Oid opid,
 		{
 			if (flag & SEL_CONSTANT)
 			{
-				/* Is the constant "=" to the column's most common value?
-				 * (Although the operator may not really be "=",
-				 * we will assume that seeing whether it returns TRUE
-				 * for the most common value is useful information.
-				 * If you don't like it, maybe you shouldn't be using
-				 * eqsel for your operator...)
+
+				/*
+				 * Is the constant "=" to the column's most common value?
+				 * (Although the operator may not really be "=", we will
+				 * assume that seeing whether it returns TRUE for the most
+				 * common value is useful information. If you don't like
+				 * it, maybe you shouldn't be using eqsel for your
+				 * operator...)
 				 */
-				RegProcedure	eqproc = get_opcode(opid);
-				bool			mostcommon;
+				RegProcedure eqproc = get_opcode(opid);
+				bool		mostcommon;
 
 				if (eqproc == (RegProcedure) NULL)
 					elog(ERROR, "eqsel: no procedure for operator %u",
@@ -133,7 +135,9 @@ eqsel(Oid opid,
 
 				if (mostcommon)
 				{
-					/* Constant is "=" to the most common value.  We know
+
+					/*
+					 * Constant is "=" to the most common value.  We know
 					 * selectivity exactly (or as exactly as VACUUM could
 					 * calculate it, anyway).
 					 */
@@ -141,17 +145,22 @@ eqsel(Oid opid,
 				}
 				else
 				{
-					/* Comparison is against a constant that is neither the
-					 * most common value nor null.  Its selectivity cannot
-					 * be more than this:
+
+					/*
+					 * Comparison is against a constant that is neither
+					 * the most common value nor null.	Its selectivity
+					 * cannot be more than this:
 					 */
 					selec = 1.0 - commonfrac - nullfrac;
 					if (selec > commonfrac)
 						selec = commonfrac;
-					/* and in fact it's probably less, so we should apply
-					 * a fudge factor.  The only case where we don't is
-					 * for a boolean column, where indeed we have estimated
-					 * the less-common value's frequency exactly!
+
+					/*
+					 * and in fact it's probably less, so we should apply
+					 * a fudge factor.	The only case where we don't is
+					 * for a boolean column, where indeed we have
+					 * estimated the less-common value's frequency
+					 * exactly!
 					 */
 					if (typid != BOOLOID)
 						selec *= 0.5;
@@ -159,14 +168,18 @@ eqsel(Oid opid,
 			}
 			else
 			{
-				/* Search is for a value that we do not know a priori,
-				 * but we will assume it is not NULL.  Selectivity
-				 * cannot be more than this:
+
+				/*
+				 * Search is for a value that we do not know a priori, but
+				 * we will assume it is not NULL.  Selectivity cannot be
+				 * more than this:
 				 */
 				selec = 1.0 - nullfrac;
 				if (selec > commonfrac)
 					selec = commonfrac;
-				/* and in fact it's probably less, so apply a fudge
+
+				/*
+				 * and in fact it's probably less, so apply a fudge
 				 * factor.
 				 */
 				selec *= 0.5;
@@ -178,15 +191,17 @@ eqsel(Oid opid,
 			else if (selec > 1.0)
 				selec = 1.0;
 
-			if (! typbyval)
+			if (!typbyval)
 				pfree(DatumGetPointer(commonval));
 		}
 		else
 		{
-			/* No VACUUM ANALYZE stats available, so make a guess using
-			 * the disbursion stat (if we have that, which is unlikely
-			 * for a normal attribute; but for a system attribute we may
-			 * be able to estimate it).
+
+			/*
+			 * No VACUUM ANALYZE stats available, so make a guess using
+			 * the disbursion stat (if we have that, which is unlikely for
+			 * a normal attribute; but for a system attribute we may be
+			 * able to estimate it).
 			 */
 			selec = get_attdisbursion(relid, attno, 0.01);
 		}
@@ -234,7 +249,7 @@ scalarltsel(Oid opid,
 	float64		result;
 
 	result = (float64) palloc(sizeof(float64data));
-	if (! (flag & SEL_CONSTANT) || NONVALUE(attno) || NONVALUE(relid))
+	if (!(flag & SEL_CONSTANT) || NONVALUE(attno) || NONVALUE(relid))
 		*result = DEFAULT_INEQ_SEL;
 	else
 	{
@@ -253,21 +268,24 @@ scalarltsel(Oid opid,
 					numerator,
 					denominator;
 
-		/* Get left and right datatypes of the operator so we know
-		 * what type the constant is.
+		/*
+		 * Get left and right datatypes of the operator so we know what
+		 * type the constant is.
 		 */
 		oprtuple = get_operator_tuple(opid);
-		if (! HeapTupleIsValid(oprtuple))
+		if (!HeapTupleIsValid(oprtuple))
 			elog(ERROR, "scalarltsel: no tuple for operator %u", opid);
 		ltype = ((Form_pg_operator) GETSTRUCT(oprtuple))->oprleft;
 		rtype = ((Form_pg_operator) GETSTRUCT(oprtuple))->oprright;
 
 		/* Convert the constant to a uniform comparison scale. */
-		if (! convert_to_scalar(value,
-								((flag & SEL_RIGHT) ? rtype : ltype),
-								&val))
+		if (!convert_to_scalar(value,
+							   ((flag & SEL_RIGHT) ? rtype : ltype),
+							   &val))
 		{
-			/* Ideally we'd produce an error here, on the grounds that the
+
+			/*
+			 * Ideally we'd produce an error here, on the grounds that the
 			 * given operator shouldn't have scalarltsel registered as its
 			 * selectivity func unless we can deal with its operand types.
 			 * But currently, all manner of stuff is invoking scalarltsel,
@@ -281,9 +299,9 @@ scalarltsel(Oid opid,
 		getattproperties(relid, attno,
 						 &typid, &typlen, &typbyval, &typmod);
 
-		if (! getattstatistics(relid, attno, typid, typmod,
-							   NULL, NULL, NULL,
-							   &loval, &hival))
+		if (!getattstatistics(relid, attno, typid, typmod,
+							  NULL, NULL, NULL,
+							  &loval, &hival))
 		{
 			/* no stats available, so default result */
 			*result = DEFAULT_INEQ_SEL;
@@ -291,11 +309,11 @@ scalarltsel(Oid opid,
 		}
 
 		/* Convert the attribute's loval/hival to common scale. */
-		if (! convert_to_scalar(loval, typid, &low) ||
-			! convert_to_scalar(hival, typid, &high))
+		if (!convert_to_scalar(loval, typid, &low) ||
+			!convert_to_scalar(hival, typid, &high))
 		{
 			/* See above comments... */
-			if (! typbyval)
+			if (!typbyval)
 			{
 				pfree(DatumGetPointer(hival));
 				pfree(DatumGetPointer(loval));
@@ -306,7 +324,7 @@ scalarltsel(Oid opid,
 		}
 
 		/* release temp storage if needed */
-		if (! typbyval)
+		if (!typbyval)
 		{
 			pfree(DatumGetPointer(hival));
 			pfree(DatumGetPointer(loval));
@@ -314,18 +332,22 @@ scalarltsel(Oid opid,
 
 		if (high <= low)
 		{
-			/* If we trusted the stats fully, we could return a small or
-			 * large selec depending on which side of the single data point
-			 * the constant is on.  But it seems better to assume that the
-			 * stats are wrong and return a default...
+
+			/*
+			 * If we trusted the stats fully, we could return a small or
+			 * large selec depending on which side of the single data
+			 * point the constant is on.  But it seems better to assume
+			 * that the stats are wrong and return a default...
 			 */
 			*result = DEFAULT_INEQ_SEL;
 		}
 		else if (val < low || val > high)
 		{
-			/* If given value is outside the statistical range, return a
-			 * small or large value; but not 0.0/1.0 since there is a chance
-			 * the stats are out of date.
+
+			/*
+			 * If given value is outside the statistical range, return a
+			 * small or large value; but not 0.0/1.0 since there is a
+			 * chance the stats are out of date.
 			 */
 			if (flag & SEL_RIGHT)
 				*result = (val < low) ? 0.001 : 0.999;
@@ -359,8 +381,9 @@ scalargtsel(Oid opid,
 {
 	float64		result;
 
-	/* Compute selectivity of "<", then invert --- but only if we
-	 * were able to produce a non-default estimate.
+	/*
+	 * Compute selectivity of "<", then invert --- but only if we were
+	 * able to produce a non-default estimate.
 	 */
 	result = scalarltsel(opid, relid, attno, value, flag);
 	if (*result != DEFAULT_INEQ_SEL)
@@ -392,23 +415,24 @@ eqjoinsel(Oid opid,
 	{
 		num1 = unknown1 ? 1.0 : get_attdisbursion(relid1, attno1, 0.01);
 		num2 = unknown2 ? 1.0 : get_attdisbursion(relid2, attno2, 0.01);
+
 		/*
-		 * The join selectivity cannot be more than num2, since each
-		 * tuple in table 1 could match no more than num2 fraction of
-		 * tuples in table 2 (and that's only if the table-1 tuple
-		 * matches the most common value in table 2, so probably it's
-		 * less).  By the same reasoning it is not more than num1.
-		 * The min is therefore an upper bound.
+		 * The join selectivity cannot be more than num2, since each tuple
+		 * in table 1 could match no more than num2 fraction of tuples in
+		 * table 2 (and that's only if the table-1 tuple matches the most
+		 * common value in table 2, so probably it's less).  By the same
+		 * reasoning it is not more than num1. The min is therefore an
+		 * upper bound.
 		 *
 		 * If we know the disbursion of only one side, use it; the reasoning
 		 * above still works.
 		 *
-		 * XXX can we make a better estimate here?  Using the nullfrac
+		 * XXX can we make a better estimate here?	Using the nullfrac
 		 * statistic might be helpful, for example.  Assuming the operator
-		 * is strict (does not succeed for null inputs) then the selectivity
-		 * couldn't be more than (1-nullfrac1)*(1-nullfrac2), which might
-		 * be usefully small if there are many nulls.  How about applying
-		 * the operator to the most common values?
+		 * is strict (does not succeed for null inputs) then the
+		 * selectivity couldn't be more than (1-nullfrac1)*(1-nullfrac2),
+		 * which might be usefully small if there are many nulls.  How
+		 * about applying the operator to the most common values?
 		 */
 		min = (num1 < num2) ? num1 : num2;
 		*result = min;
@@ -434,7 +458,7 @@ neqjoinsel(Oid opid,
 }
 
 /*
- *		scalarltjoinsel	- Join selectivity of "<" and "<=" for scalars
+ *		scalarltjoinsel - Join selectivity of "<" and "<=" for scalars
  */
 float64
 scalarltjoinsel(Oid opid,
@@ -451,7 +475,7 @@ scalarltjoinsel(Oid opid,
 }
 
 /*
- *		scalargtjoinsel	- Join selectivity of ">" and ">=" for scalars
+ *		scalargtjoinsel - Join selectivity of ">" and ">=" for scalars
  */
 float64
 scalargtjoinsel(Oid opid,
@@ -493,10 +517,11 @@ convert_to_scalar(Datum value, Oid typid,
 {
 	switch (typid)
 	{
-		/*
-		 * Built-in numeric types
-		 */
-		case BOOLOID:
+
+			/*
+			 * Built-in numeric types
+			 */
+			case BOOLOID:
 			*scaleval = (double) DatumGetUInt8(value);
 			return true;
 		case INT2OID:
@@ -506,16 +531,16 @@ convert_to_scalar(Datum value, Oid typid,
 			*scaleval = (double) DatumGetInt32(value);
 			return true;
 		case INT8OID:
-			*scaleval = (double) (* i8tod((int64 *) DatumGetPointer(value)));
+			*scaleval = (double) (*i8tod((int64 *) DatumGetPointer(value)));
 			return true;
 		case FLOAT4OID:
-			*scaleval = (double) (* DatumGetFloat32(value));
+			*scaleval = (double) (*DatumGetFloat32(value));
 			return true;
 		case FLOAT8OID:
-			*scaleval = (double) (* DatumGetFloat64(value));
+			*scaleval = (double) (*DatumGetFloat64(value));
 			return true;
 		case NUMERICOID:
-			*scaleval = (double) (* numeric_float8((Numeric) DatumGetPointer(value)));
+			*scaleval = (double) (*numeric_float8((Numeric) DatumGetPointer(value)));
 			return true;
 		case OIDOID:
 		case REGPROCOID:
@@ -523,110 +548,114 @@ convert_to_scalar(Datum value, Oid typid,
 			*scaleval = (double) DatumGetObjectId(value);
 			return true;
 
-		/*
-		 * Built-in string types
-		 */
+			/*
+			 * Built-in string types
+			 */
 		case CHAROID:
-		{
-			char	ch = DatumGetChar(value);
+			{
+				char		ch = DatumGetChar(value);
 
-			return convert_string_to_scalar(&ch, 1, scaleval);
-		}
+				return convert_string_to_scalar(&ch, 1, scaleval);
+			}
 		case BPCHAROID:
 		case VARCHAROID:
 		case TEXTOID:
-		{
-			char   *str = (char *) VARDATA(DatumGetPointer(value));
-			int		strlength = VARSIZE(DatumGetPointer(value)) - VARHDRSZ;
+			{
+				char	   *str = (char *) VARDATA(DatumGetPointer(value));
+				int			strlength = VARSIZE(DatumGetPointer(value)) - VARHDRSZ;
 
-			return convert_string_to_scalar(str, strlength, scaleval);
-		}
+				return convert_string_to_scalar(str, strlength, scaleval);
+			}
 		case NAMEOID:
-		{
-			NameData   *nm = (NameData *) DatumGetPointer(value);
+			{
+				NameData   *nm = (NameData *) DatumGetPointer(value);
 
-			return convert_string_to_scalar(NameStr(*nm), strlen(NameStr(*nm)),
-											scaleval);
-		}
+				return convert_string_to_scalar(NameStr(*nm), strlen(NameStr(*nm)),
+												scaleval);
+			}
 
-		/*
-		 * Built-in absolute-time types
-		 */
+			/*
+			 * Built-in absolute-time types
+			 */
 		case TIMESTAMPOID:
-			*scaleval = * ((Timestamp *) DatumGetPointer(value));
+			*scaleval = *((Timestamp *) DatumGetPointer(value));
 			return true;
 		case ABSTIMEOID:
-			*scaleval = * abstime_timestamp(value);
+			*scaleval = *abstime_timestamp(value);
 			return true;
 		case DATEOID:
-			*scaleval = * date_timestamp(value);
+			*scaleval = *date_timestamp(value);
 			return true;
 
-		/*
-		 * Built-in relative-time types
-		 */
-		case INTERVALOID:
-		{
-			Interval   *interval = (Interval *) DatumGetPointer(value);
-
 			/*
-			 * Convert the month part of Interval to days using assumed
-			 * average month length of 365.25/12.0 days.  Not too accurate,
-			 * but plenty good enough for our purposes.
+			 * Built-in relative-time types
 			 */
-			*scaleval = interval->time +
-				interval->month * (365.25/12.0 * 24.0 * 60.0 * 60.0);
-			return true;
-		}
+		case INTERVALOID:
+			{
+				Interval   *interval = (Interval *) DatumGetPointer(value);
+
+				/*
+				 * Convert the month part of Interval to days using
+				 * assumed average month length of 365.25/12.0 days.  Not
+				 * too accurate, but plenty good enough for our purposes.
+				 */
+				*scaleval = interval->time +
+					interval->month * (365.25 / 12.0 * 24.0 * 60.0 * 60.0);
+				return true;
+			}
 		case RELTIMEOID:
 			*scaleval = (RelativeTime) DatumGetInt32(value);
 			return true;
 		case TINTERVALOID:
-		{
-			TimeInterval	interval = (TimeInterval) DatumGetPointer(value);
-
-			if (interval->status != 0)
 			{
-				*scaleval = interval->data[1] - interval->data[0];
-				return true;
+				TimeInterval interval = (TimeInterval) DatumGetPointer(value);
+
+				if (interval->status != 0)
+				{
+					*scaleval = interval->data[1] - interval->data[0];
+					return true;
+				}
+				break;
 			}
-			break;
-		}
 		case TIMEOID:
-			*scaleval = * ((TimeADT *) DatumGetPointer(value));
+			*scaleval = *((TimeADT *) DatumGetPointer(value));
 			return true;
 
 		default:
-		{
-			/*
-			 * See whether there is a registered type-conversion function,
-			 * namely a procedure named "float8" with the right signature.
-			 * If so, assume we can convert the value to the numeric scale.
-			 *
-			 * NOTE: there are no such procedures in the standard distribution,
-			 * except with argument types that we already dealt with above.
-			 * This code is just here as an escape for user-defined types.
-			 */
-			Oid			oid_array[FUNC_MAX_ARGS];
-			HeapTuple	ftup;
-
-			MemSet(oid_array, 0, FUNC_MAX_ARGS * sizeof(Oid));
-			oid_array[0] = typid;
-			ftup = SearchSysCacheTuple(PROCNAME,
-									   PointerGetDatum("float8"),
-									   Int32GetDatum(1),
-									   PointerGetDatum(oid_array),
-									   0);
-			if (HeapTupleIsValid(ftup) &&
-				((Form_pg_proc) GETSTRUCT(ftup))->prorettype == FLOAT8OID)
 			{
-				RegProcedure convertproc = (RegProcedure) ftup->t_data->t_oid;
-				Datum converted = (Datum) fmgr(convertproc, value);
-				*scaleval = (double) (* DatumGetFloat64(converted));
-				return true;
+
+				/*
+				 * See whether there is a registered type-conversion
+				 * function, namely a procedure named "float8" with the
+				 * right signature. If so, assume we can convert the value
+				 * to the numeric scale.
+				 *
+				 * NOTE: there are no such procedures in the standard
+				 * distribution, except with argument types that we
+				 * already dealt with above. This code is just here as an
+				 * escape for user-defined types.
+				 */
+				Oid			oid_array[FUNC_MAX_ARGS];
+				HeapTuple	ftup;
+
+				MemSet(oid_array, 0, FUNC_MAX_ARGS * sizeof(Oid));
+				oid_array[0] = typid;
+				ftup = SearchSysCacheTuple(PROCNAME,
+										   PointerGetDatum("float8"),
+										   Int32GetDatum(1),
+										   PointerGetDatum(oid_array),
+										   0);
+				if (HeapTupleIsValid(ftup) &&
+				((Form_pg_proc) GETSTRUCT(ftup))->prorettype == FLOAT8OID)
+				{
+					RegProcedure convertproc = (RegProcedure) ftup->t_data->t_oid;
+					Datum		converted = (Datum) fmgr(convertproc, value);
+
+					*scaleval = (double) (*DatumGetFloat64(converted));
+					return true;
+				}
+				break;
 			}
-			break;
-		}
 	}
 	/* Don't know how to convert */
 	return false;
@@ -649,16 +678,18 @@ static bool
 convert_string_to_scalar(char *str, int strlength,
 						 double *scaleval)
 {
-	unsigned char   *sptr;
-	int				slen;
+	unsigned char *sptr;
+	int			slen;
+
 #ifdef USE_LOCALE
-	char		   *rawstr;
-	char		   *xfrmstr;
-	size_t			xfrmsize;
-	size_t			xfrmlen;
+	char	   *rawstr;
+	char	   *xfrmstr;
+	size_t		xfrmsize;
+	size_t		xfrmlen;
+
 #endif
-	double			num,
-					denom;
+	double		num,
+				denom;
 
 	if (strlength <= 0)
 	{
@@ -680,8 +711,8 @@ convert_string_to_scalar(char *str, int strlength,
 	{
 		/* Oops, didn't make it */
 		pfree(xfrmstr);
-		xfrmstr = (char *) palloc(xfrmlen+1);
-		xfrmlen = strxfrm(xfrmstr, rawstr, xfrmlen+1);
+		xfrmstr = (char *) palloc(xfrmlen + 1);
+		xfrmlen = strxfrm(xfrmstr, rawstr, xfrmlen + 1);
 	}
 	pfree(rawstr);
 
@@ -730,7 +761,7 @@ getattproperties(Oid relid, AttrNumber attnum,
 							  ObjectIdGetDatum(relid),
 							  Int16GetDatum(attnum),
 							  0, 0);
-	if (! HeapTupleIsValid(atp))
+	if (!HeapTupleIsValid(atp))
 		elog(ERROR, "getattproperties: no attribute tuple %u %d",
 			 relid, (int) attnum);
 	att_tup = (Form_pg_attribute) GETSTRUCT(atp);
@@ -778,14 +809,14 @@ getattstatistics(Oid relid,
 	bool		isnull;
 
 	/*
-	 * We assume that there will only be one entry in pg_statistic for
-	 * the given rel/att, so we search WITHOUT considering the staop
-	 * column.  Someday, VACUUM might store more than one entry per rel/att,
+	 * We assume that there will only be one entry in pg_statistic for the
+	 * given rel/att, so we search WITHOUT considering the staop column.
+	 * Someday, VACUUM might store more than one entry per rel/att,
 	 * corresponding to more than one possible sort ordering defined for
 	 * the column type.  However, to make that work we will need to figure
 	 * out which staop to search for --- it's not necessarily the one we
-	 * have at hand!  (For example, we might have a '>' operator rather than
-	 * the '<' operator that will appear in staop.)
+	 * have at hand!  (For example, we might have a '>' operator rather
+	 * than the '<' operator that will appear in staop.)
 	 */
 	tuple = SearchSysCacheTuple(STATRELID,
 								ObjectIdGetDatum(relid),
@@ -807,20 +838,22 @@ getattstatistics(Oid relid,
 	typeTuple = SearchSysCacheTuple(TYPEOID,
 									ObjectIdGetDatum(typid),
 									0, 0, 0);
-	if (! HeapTupleIsValid(typeTuple))
+	if (!HeapTupleIsValid(typeTuple))
 		elog(ERROR, "getattstatistics: Cache lookup failed for type %u",
 			 typid);
 	fmgr_info(((Form_pg_type) GETSTRUCT(typeTuple))->typinput, &inputproc);
 	typelem = ((Form_pg_type) GETSTRUCT(typeTuple))->typelem;
 
-	/* Values are variable-length fields, so cannot access as struct fields.
-	 * Must do it the hard way with SysCacheGetAttr.
+	/*
+	 * Values are variable-length fields, so cannot access as struct
+	 * fields. Must do it the hard way with SysCacheGetAttr.
 	 */
 	if (commonval)
 	{
-		text *val = (text *) SysCacheGetAttr(STATRELID, tuple,
-											 Anum_pg_statistic_stacommonval,
-											 &isnull);
+		text	   *val = (text *) SysCacheGetAttr(STATRELID, tuple,
+										  Anum_pg_statistic_stacommonval,
+												   &isnull);
+
 		if (isnull)
 		{
 			elog(DEBUG, "getattstatistics: stacommonval is null");
@@ -828,7 +861,8 @@ getattstatistics(Oid relid,
 		}
 		else
 		{
-			char *strval = textout(val);
+			char	   *strval = textout(val);
+
 			*commonval = (Datum)
 				(*fmgr_faddr(&inputproc)) (strval, typelem, typmod);
 			pfree(strval);
@@ -837,9 +871,10 @@ getattstatistics(Oid relid,
 
 	if (loval)
 	{
-		text *val = (text *) SysCacheGetAttr(STATRELID, tuple,
-											 Anum_pg_statistic_staloval,
-											 &isnull);
+		text	   *val = (text *) SysCacheGetAttr(STATRELID, tuple,
+											  Anum_pg_statistic_staloval,
+												   &isnull);
+
 		if (isnull)
 		{
 			elog(DEBUG, "getattstatistics: staloval is null");
@@ -847,7 +882,8 @@ getattstatistics(Oid relid,
 		}
 		else
 		{
-			char *strval = textout(val);
+			char	   *strval = textout(val);
+
 			*loval = (Datum)
 				(*fmgr_faddr(&inputproc)) (strval, typelem, typmod);
 			pfree(strval);
@@ -856,9 +892,10 @@ getattstatistics(Oid relid,
 
 	if (hival)
 	{
-		text *val = (text *) SysCacheGetAttr(STATRELID, tuple,
-											 Anum_pg_statistic_stahival,
-											 &isnull);
+		text	   *val = (text *) SysCacheGetAttr(STATRELID, tuple,
+											  Anum_pg_statistic_stahival,
+												   &isnull);
+
 		if (isnull)
 		{
 			elog(DEBUG, "getattstatistics: stahival is null");
@@ -866,7 +903,8 @@ getattstatistics(Oid relid,
 		}
 		else
 		{
-			char *strval = textout(val);
+			char	   *strval = textout(val);
+
 			*hival = (Datum)
 				(*fmgr_faddr(&inputproc)) (strval, typelem, typmod);
 			pfree(strval);
@@ -894,11 +932,11 @@ genericcostestimate(Query *root, RelOptInfo *rel,
 					Cost *indexTotalCost,
 					Selectivity *indexSelectivity)
 {
-	double numIndexTuples;
-	double numIndexPages;
+	double		numIndexTuples;
+	double		numIndexPages;
 
 	/* Estimate the fraction of main-table tuples that will be visited */
-    *indexSelectivity = clauselist_selectivity(root, indexQuals,
+	*indexSelectivity = clauselist_selectivity(root, indexQuals,
 											   lfirsti(rel->relids));
 
 	/* Estimate the number of index tuples that will be visited */
@@ -908,8 +946,8 @@ genericcostestimate(Query *root, RelOptInfo *rel,
 	numIndexPages = *indexSelectivity * index->pages;
 
 	/*
-	 * Always estimate at least one tuple and page are touched,
-	 * even when indexSelectivity estimate is tiny.
+	 * Always estimate at least one tuple and page are touched, even when
+	 * indexSelectivity estimate is tiny.
 	 */
 	if (numIndexTuples < 1.0)
 		numIndexTuples = 1.0;
@@ -921,11 +959,12 @@ genericcostestimate(Query *root, RelOptInfo *rel,
 	 *
 	 * Our generic assumption is that the index pages will be read
 	 * sequentially, so they have cost 1.0 each, not random_page_cost.
-	 * Also, we charge for evaluation of the indexquals at each index tuple.
-     * All the costs are assumed to be paid incrementally during the scan.
-     */
-    *indexStartupCost = 0;
-    *indexTotalCost = numIndexPages +
+	 * Also, we charge for evaluation of the indexquals at each index
+	 * tuple. All the costs are assumed to be paid incrementally during
+	 * the scan.
+	 */
+	*indexStartupCost = 0;
+	*indexTotalCost = numIndexPages +
 		(cpu_index_tuple_cost + cost_qual_eval(indexQuals)) * numIndexTuples;
 }
 
@@ -941,7 +980,7 @@ btcostestimate(Query *root, RelOptInfo *rel,
 			   Selectivity *indexSelectivity)
 {
 	genericcostestimate(root, rel, index, indexQuals,
-						indexStartupCost, indexTotalCost, indexSelectivity);
+					 indexStartupCost, indexTotalCost, indexSelectivity);
 }
 
 void
@@ -952,7 +991,7 @@ rtcostestimate(Query *root, RelOptInfo *rel,
 			   Selectivity *indexSelectivity)
 {
 	genericcostestimate(root, rel, index, indexQuals,
-						indexStartupCost, indexTotalCost, indexSelectivity);
+					 indexStartupCost, indexTotalCost, indexSelectivity);
 }
 
 void
@@ -963,7 +1002,7 @@ hashcostestimate(Query *root, RelOptInfo *rel,
 				 Selectivity *indexSelectivity)
 {
 	genericcostestimate(root, rel, index, indexQuals,
-						indexStartupCost, indexTotalCost, indexSelectivity);
+					 indexStartupCost, indexTotalCost, indexSelectivity);
 }
 
 void
@@ -974,5 +1013,5 @@ gistcostestimate(Query *root, RelOptInfo *rel,
 				 Selectivity *indexSelectivity)
 {
 	genericcostestimate(root, rel, index, indexQuals,
-						indexStartupCost, indexTotalCost, indexSelectivity);
+					 indexStartupCost, indexTotalCost, indexSelectivity);
 }
diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c
index 06ab6d7a3c593110470a5f78caf7ad5e46c845ca..070cb05018d08691093bb34f60aa31675605bf7d 100644
--- a/src/backend/utils/adt/tid.c
+++ b/src/backend/utils/adt/tid.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.15 2000/01/26 05:57:14 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.16 2000/04/12 17:15:51 momjian Exp $
  *
  * NOTES
  *	  input routine largely stolen from boxin().
@@ -31,7 +31,7 @@
 ItemPointer
 tidin(const char *str)
 {
-	const	char	   *p,
+	const char *p,
 			   *coord[NTIDARGS];
 	int			i;
 	ItemPointer result;
@@ -105,25 +105,21 @@ bool
 tideq(ItemPointer arg1, ItemPointer arg2)
 {
 	if ((!arg1) || (!arg2))
-	{
 		return false;
-	}
-	
-	return ( BlockIdGetBlockNumber(&(arg1->ip_blkid)) ==
-		 BlockIdGetBlockNumber(&(arg2->ip_blkid)) &&
-		 arg1->ip_posid == arg2->ip_posid );
+
+	return (BlockIdGetBlockNumber(&(arg1->ip_blkid)) ==
+			BlockIdGetBlockNumber(&(arg2->ip_blkid)) &&
+			arg1->ip_posid == arg2->ip_posid);
 }
 
 bool
 tidne(ItemPointer arg1, ItemPointer arg2)
 {
 	if ((!arg1) || (!arg2))
-	{
 		return false;
-	}
-	return ( BlockIdGetBlockNumber(&(arg1->ip_blkid)) !=
-		 BlockIdGetBlockNumber(&(arg2->ip_blkid)) ||
-		 arg1->ip_posid != arg2->ip_posid );
+	return (BlockIdGetBlockNumber(&(arg1->ip_blkid)) !=
+			BlockIdGetBlockNumber(&(arg2->ip_blkid)) ||
+			arg1->ip_posid != arg2->ip_posid);
 }
 
 text *
@@ -131,7 +127,8 @@ tid_text(ItemPointer tid)
 {
 	char	   *str;
 
-	if (!tid)	return (text *)NULL;
+	if (!tid)
+		return (text *) NULL;
 	str = tidout(tid);
 
 	return textin(str);
@@ -140,10 +137,11 @@ tid_text(ItemPointer tid)
 ItemPointer
 text_tid(const text *string)
 {
-	ItemPointer	result;
-	char		*str;
+	ItemPointer result;
+	char	   *str;
 
-	if (!string)	return (ItemPointer)0;
+	if (!string)
+		return (ItemPointer) 0;
 
 	str = textout((text *) string);
 	result = tidin(str);
@@ -162,7 +160,8 @@ text_tid(const text *string)
 ItemPointer
 currtid_byreloid(Oid reloid, ItemPointer tid)
 {
-	ItemPointer	result = NULL, ret;
+	ItemPointer result = NULL,
+				ret;
 	Relation	rel;
 
 	result = (ItemPointer) palloc(sizeof(ItemPointerData));
@@ -183,11 +182,13 @@ currtid_byreloid(Oid reloid, ItemPointer tid)
 ItemPointer
 currtid_byrelname(const text *relname, ItemPointer tid)
 {
-	ItemPointer	result = NULL, ret;
-	char		*str;
+	ItemPointer result = NULL,
+				ret;
+	char	   *str;
 	Relation	rel;
 
-	if (!relname)	return result;
+	if (!relname)
+		return result;
 
 	str = textout((text *) relname);
 
@@ -201,7 +202,7 @@ currtid_byrelname(const text *relname, ItemPointer tid)
 		heap_close(rel, AccessShareLock);
 	}
 	else
-		elog(ERROR, "Relation %s not found", textout((text *)relname));
+		elog(ERROR, "Relation %s not found", textout((text *) relname));
 	pfree(str);
 
 	return result;
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index 7a94ddd804d2a1a196c15018e2855ea0a0fe3932..a731ce3cef55c1393ff4eb2e6ca128ffd02ccb1d 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.24 2000/04/07 13:39:41 thomas Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.25 2000/04/12 17:15:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -42,10 +42,10 @@ static double time2t(const int hour, const int min, const double sec);
 /* timestamp_in()
  * Convert a string to internal form.
  */
-Timestamp   *
+Timestamp  *
 timestamp_in(char *str)
 {
-	Timestamp   *result;
+	Timestamp  *result;
 
 	double		fsec;
 	struct tm	tt,
@@ -249,10 +249,10 @@ EncodeSpecialTimestamp(Timestamp dt, char *str)
 	return FALSE;
 }	/* EncodeSpecialTimestamp() */
 
-Timestamp *
+Timestamp  *
 now(void)
 {
-	Timestamp *result;
+	Timestamp  *result;
 	AbsoluteTime sec;
 
 	result = palloc(sizeof(Timestamp));
@@ -469,9 +469,9 @@ tm2interval(struct tm * tm, double fsec, Interval *span)
 {
 	span->month = ((tm->tm_year * 12) + tm->tm_mon);
 	span->time = ((((((tm->tm_mday * 24.0)
-					 + tm->tm_hour) * 60.0)
-					 + tm->tm_min) * 60.0)
-					 + tm->tm_sec);
+					  + tm->tm_hour) * 60.0)
+					+ tm->tm_min) * 60.0)
+				  + tm->tm_sec);
 	span->time = JROUND(span->time + fsec);
 
 	return 0;
@@ -562,7 +562,7 @@ SetTimestamp(Timestamp dt)
 	return dt;
 }	/* SetTimestamp() */
 
-/*		timestamp_relop	- is timestamp1 relop timestamp2
+/*		timestamp_relop - is timestamp1 relop timestamp2
  */
 bool
 timestamp_eq(Timestamp *timestamp1, Timestamp *timestamp2)
@@ -896,13 +896,15 @@ overlaps_timestamp(Timestamp *ts1, Timestamp *te1, Timestamp *ts2, Timestamp *te
 	/* Make sure we have ordered pairs... */
 	if (timestamp_gt(ts1, te1))
 	{
-		Timestamp *tt = ts1;
+		Timestamp  *tt = ts1;
+
 		ts1 = te1;
 		te1 = tt;
 	}
 	if (timestamp_gt(ts2, te2))
 	{
-		Timestamp *tt = ts2;
+		Timestamp  *tt = ts2;
+
 		ts2 = te2;
 		te2 = tt;
 	}
@@ -910,7 +912,7 @@ overlaps_timestamp(Timestamp *ts1, Timestamp *te1, Timestamp *ts2, Timestamp *te
 	return ((timestamp_gt(ts1, ts2) && (timestamp_lt(ts1, te2) || timestamp_lt(te1, te2)))
 			|| (timestamp_gt(ts2, ts1) && (timestamp_lt(ts2, te1) || timestamp_lt(te2, te1)))
 			|| timestamp_eq(ts1, ts2));
-} /* overlaps_timestamp() */
+}	/* overlaps_timestamp() */
 
 
 /*----------------------------------------------------------
@@ -921,10 +923,10 @@ overlaps_timestamp(Timestamp *ts1, Timestamp *te1, Timestamp *ts2, Timestamp *te
  *						actual value.
  *---------------------------------------------------------*/
 
-Timestamp   *
+Timestamp  *
 timestamp_smaller(Timestamp *timestamp1, Timestamp *timestamp2)
 {
-	Timestamp   *result;
+	Timestamp  *result;
 
 	Timestamp	dt1,
 				dt2;
@@ -952,10 +954,10 @@ timestamp_smaller(Timestamp *timestamp1, Timestamp *timestamp2)
 	return result;
 }	/* timestamp_smaller() */
 
-Timestamp   *
+Timestamp  *
 timestamp_larger(Timestamp *timestamp1, Timestamp *timestamp2)
 {
-	Timestamp   *result;
+	Timestamp  *result;
 
 	Timestamp	dt1,
 				dt2;
@@ -1028,10 +1030,10 @@ timestamp_mi(Timestamp *timestamp1, Timestamp *timestamp2)
  *	to the last day of month.
  * Lastly, add in the "quantitative time".
  */
-Timestamp   *
+Timestamp  *
 timestamp_pl_span(Timestamp *timestamp, Interval *span)
 {
-	Timestamp   *result;
+	Timestamp  *result;
 	Timestamp	dt;
 	int			tz;
 	char	   *tzn;
@@ -1099,10 +1101,10 @@ timestamp_pl_span(Timestamp *timestamp, Interval *span)
 	return result;
 }	/* timestamp_pl_span() */
 
-Timestamp   *
+Timestamp  *
 timestamp_mi_span(Timestamp *timestamp, Interval *span)
 {
-	Timestamp   *result;
+	Timestamp  *result;
 	Interval	tspan;
 
 	if (!PointerIsValid(timestamp) || !PointerIsValid(span))
@@ -1485,10 +1487,10 @@ timestamp_text(Timestamp *timestamp)
  * Text type is not null terminated, so use temporary string
  *	then call the standard input routine.
  */
-Timestamp   *
+Timestamp  *
 text_timestamp(text *str)
 {
-	Timestamp   *result;
+	Timestamp  *result;
 	int			i;
 	char	   *sp,
 			   *dp,
@@ -1571,10 +1573,10 @@ text_interval(text *str)
 /* timestamp_trunc()
  * Extract specified field from timestamp.
  */
-Timestamp   *
+Timestamp  *
 timestamp_trunc(text *units, Timestamp *timestamp)
 {
-	Timestamp   *result;
+	Timestamp  *result;
 
 	Timestamp	dt;
 	int			tz;
diff --git a/src/backend/utils/adt/varbit.c b/src/backend/utils/adt/varbit.c
index 47946faccc039cfb08d5304bbcdafe1383cc399c..cd2839c6929f285cca434095bb0264be7c00a804 100644
--- a/src/backend/utils/adt/varbit.c
+++ b/src/backend/utils/adt/varbit.c
@@ -4,7 +4,7 @@
  *	  Functions for the built-in type bit() and varying bit().
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.1 2000/04/08 02:12:54 thomas Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.2 2000/04/12 17:15:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -35,235 +35,261 @@
 #include "utils/builtins.h"
 #include "access/htup.h"
 
-/* 
+/*
    Prefixes:
-     zp    -- zero-padded fixed length bit string
-     var   -- varying bit string
+	 zp    -- zero-padded fixed length bit string
+	 var   -- varying bit string
 
    attypmod -- contains the length of the bit string in bits, or for
-               varying bits the maximum length. 
+			   varying bits the maximum length.
 
    The data structure contains the following elements:
-      header  -- length of the whole data structure (incl header)
-                 in bytes. (as with all varying length datatypes)
-      data section -- private data section for the bits data structures
-         bitlength -- lenght of the bit string in bits
+	  header  -- length of the whole data structure (incl header)
+				 in bytes. (as with all varying length datatypes)
+	  data section -- private data section for the bits data structures
+		 bitlength -- lenght of the bit string in bits
 	 bitdata   -- least significant byte first string
 */
 
-char * 
-varbit_out (bits8 *s) {
-  return zpbits_out(s);
+char *
+varbit_out(bits8 *s)
+{
+	return zpbits_out(s);
 }
 
 /*
  * zpbit_in -
  *	  converts a string to the internal representation of a bitstring.
- *        The length is determined by the number of bits required plus
- *        VARHDRSZ bytes or from atttypmod. 
- *	  (XXX dummy is here because we pass typelem as the second argument 
- *        for array_in. copied this, no idea what it means??)
+ *		  The length is determined by the number of bits required plus
+ *		  VARHDRSZ bytes or from atttypmod.
+ *	  (XXX dummy is here because we pass typelem as the second argument
+ *		  for array_in. copied this, no idea what it means??)
  */
 bits8 *
-zpbit_in(char *s, int dummy,  int32 atttypmod)
-{
-  bits8 *result;	/* the bits string that was read in   */ 
-  char  *sp;		/* pointer into the character string  */
-  bits8 *r;
-  int len,		/* Length of the whole data structure */
-    bitlen,		/* Number of bits in the bit string   */
-    slen;		/* Length of the input string         */
-  int bit_not_hex = 0;  /* 0 = hex string  1=bit string       */
-  int bc, ipad;
-  bits8 x = 0;
-
-
-  if (s == NULL)
-    return (bits8 *) NULL;
-
-  /* Check that the first character is a b or an x */
-  if (s[0]=='b' || s[0]=='B') 
-      bit_not_hex = 1;
-  else if (s[0]=='x' || s[0]=='X') 
-      bit_not_hex = 0;
-  else 
-    elog(ERROR, "zpbit_in: %s is not a valid bitstring",s);
-
-  slen = strlen(s) - 1;
-  /* Determine bitlength from input string */
-  bitlen = slen;
-  if (!bit_not_hex)
-    bitlen *= 4;
-  
-  /* Sometimes atttypmod is not supplied. If it is supplied we need to make
-     sure that the bitstring fits. Note that the number of infered bits can
-     be larger than the number of actual bits needed, but only if we are 
-     reading a hex string and not by more than 3 bits, as a hex string gives 
-     and accurate length upto 4 bits */
-  if (atttypmod == -1)
-    atttypmod = bitlen;
-  else
-    if ((bitlen>atttypmod && bit_not_hex) || 
-	(bitlen>atttypmod+3 && !bit_not_hex))
-	  elog(ERROR, "zpbit_in: bit string of size %d cannot be written into bits(%d)",
-	       bitlen,atttypmod);
-
-
-  len = VARBITDATALEN(atttypmod);
-
-  if (len > MaxAttrSize)
-    elog(ERROR, "zpbit_in: length of bit() must be less than %ld",
-	 (MaxAttrSize-VARHDRSZ-VARBITHDRSZ)*BITSPERBYTE);
-
-  result = (bits8 *) palloc(len);
-  /* set to 0 so that *r is always initialised and strin is zero-padded */
-  memset(result, 0, len);
-  VARSIZE(result) = len;
-  VARBITLEN(result) = atttypmod;
-
-  /* We need to read the bitstring from the end, as we store it least 
-     significant byte first. s points to the byte before the beginning
-     of the bitstring */
-  sp = s+1;
-  r = VARBITS(result);
-  if (bit_not_hex) 
-    {
-      /* Parse the bit representation of the string */
-      /* We know it fits, as bitlen was compared to atttypmod */
-      x = BITHIGH;
-      for (bc = 0; sp != s+slen+1; sp++, bc++)
+zpbit_in(char *s, int dummy, int32 atttypmod)
+{
+	bits8	   *result;			/* the bits string that was read in   */
+	char	   *sp;				/* pointer into the character string  */
+	bits8	   *r;
+	int			len,			/* Length of the whole data structure */
+				bitlen,			/* Number of bits in the bit string   */
+				slen;			/* Length of the input string		  */
+	int			bit_not_hex = 0;/* 0 = hex string  1=bit string		  */
+	int			bc,
+				ipad;
+	bits8		x = 0;
+
+
+	if (s == NULL)
+		return (bits8 *) NULL;
+
+	/* Check that the first character is a b or an x */
+	if (s[0] == 'b' || s[0] == 'B')
+		bit_not_hex = 1;
+	else if (s[0] == 'x' || s[0] == 'X')
+		bit_not_hex = 0;
+	else
+		elog(ERROR, "zpbit_in: %s is not a valid bitstring", s);
+
+	slen = strlen(s) - 1;
+	/* Determine bitlength from input string */
+	bitlen = slen;
+	if (!bit_not_hex)
+		bitlen *= 4;
+
+	/*
+	 * Sometimes atttypmod is not supplied. If it is supplied we need to
+	 * make sure that the bitstring fits. Note that the number of infered
+	 * bits can be larger than the number of actual bits needed, but only
+	 * if we are reading a hex string and not by more than 3 bits, as a
+	 * hex string gives and accurate length upto 4 bits
+	 */
+	if (atttypmod == -1)
+		atttypmod = bitlen;
+	else if ((bitlen > atttypmod && bit_not_hex) ||
+			 (bitlen > atttypmod + 3 && !bit_not_hex))
+		elog(ERROR, "zpbit_in: bit string of size %d cannot be written into bits(%d)",
+			 bitlen, atttypmod);
+
+
+	len = VARBITDATALEN(atttypmod);
+
+	if (len > MaxAttrSize)
+		elog(ERROR, "zpbit_in: length of bit() must be less than %ld",
+			 (MaxAttrSize - VARHDRSZ - VARBITHDRSZ) * BITSPERBYTE);
+
+	result = (bits8 *) palloc(len);
+	/* set to 0 so that *r is always initialised and strin is zero-padded */
+	memset(result, 0, len);
+	VARSIZE(result) = len;
+	VARBITLEN(result) = atttypmod;
+
+	/*
+	 * We need to read the bitstring from the end, as we store it least
+	 * significant byte first. s points to the byte before the beginning
+	 * of the bitstring
+	 */
+	sp = s + 1;
+	r = VARBITS(result);
+	if (bit_not_hex)
 	{
-	  if (*sp=='1')
-	    *r |= x;
-	  if (bc==7) {
-	    bc = 0;
-	    x = BITHIGH;
-	    r++;
-	  } else 
-	    x >>= 1;
+		/* Parse the bit representation of the string */
+		/* We know it fits, as bitlen was compared to atttypmod */
+		x = BITHIGH;
+		for (bc = 0; sp != s + slen + 1; sp++, bc++)
+		{
+			if (*sp == '1')
+				*r |= x;
+			if (bc == 7)
+			{
+				bc = 0;
+				x = BITHIGH;
+				r++;
+			}
+			else
+				x >>= 1;
+		}
 	}
-     }
-  else 
-    {
-      /* Parse the hex representation of the string */
-      for (bc = 0; sp != s+slen+1; sp++)
+	else
 	{
-	  if (*sp>='0' && *sp<='9') 
-	    x = (bits8) (*sp - '0');
-	  else if (*sp>='A' && *sp<='F') 
-	    x = (bits8) (*sp - 'A') + 10;
-	  else if (*sp>='a' && *sp<='f') 
-	    x = (bits8) (*sp - 'a') + 10;
-	  else 
-	    elog(ERROR,"Cannot parse %c as a hex digit",*sp);
-	  if (bc) {
-	    bc = 0;
-	    *r++ |= x;
-	  } else {
-	    bc++;
-	    *r = x<<4;
-	  }
+		/* Parse the hex representation of the string */
+		for (bc = 0; sp != s + slen + 1; sp++)
+		{
+			if (*sp >= '0' && *sp <= '9')
+				x = (bits8) (*sp - '0');
+			else if (*sp >= 'A' && *sp <= 'F')
+				x = (bits8) (*sp - 'A') + 10;
+			else if (*sp >= 'a' && *sp <= 'f')
+				x = (bits8) (*sp - 'a') + 10;
+			else
+				elog(ERROR, "Cannot parse %c as a hex digit", *sp);
+			if (bc)
+			{
+				bc = 0;
+				*r++ |= x;
+			}
+			else
+			{
+				bc++;
+				*r = x << 4;
+			}
+		}
 	}
-    }
 
-  if (bitlen > atttypmod) {
-    /* Check that this fitted */
-    r = (bits8 *) (result + len - 1);
-    ipad = VARBITPAD(result);
-    /* The bottom ipad bits of the byte pointed to by r need to be zero */
-    if (((*r << (BITSPERBYTE-ipad)) & BITMASK) > 0)
-      elog(ERROR, "zpbit_in: bit string too large for bit(%d) data type",
-	   atttypmod);
-  }
+	if (bitlen > atttypmod)
+	{
+		/* Check that this fitted */
+		r = (bits8 *) (result + len - 1);
+		ipad = VARBITPAD(result);
+
+		/*
+		 * The bottom ipad bits of the byte pointed to by r need to be
+		 * zero
+		 */
+		if (((*r << (BITSPERBYTE - ipad)) & BITMASK) > 0)
+			elog(ERROR, "zpbit_in: bit string too large for bit(%d) data type",
+				 atttypmod);
+	}
 
-  return result;
+	return result;
 }
 
 /* zpbit_out -
- *    for the time being we print everything as hex strings, as this is likely 
- *    to be more compact than bit strings, and consequently much more efficient
- *    for long strings
+ *	  for the time being we print everything as hex strings, as this is likely
+ *	  to be more compact than bit strings, and consequently much more efficient
+ *	  for long strings
  */
 char *
 zpbit_out(bits8 *s)
 {
-  char	   *result, *r;
-  bits8    *sp;
-  int	   i, len, bitlen;
-  
-  if (s == NULL)
-    {
-      result = (char *) palloc(2);
-      result[0] = '-';
-      result[1] = '\0';
-    }
-  else
-    {
-      bitlen = VARBITLEN(s);
-      len = bitlen/4 + (bitlen%4>0 ? 1 : 0);
-      result = (char *) palloc(len + 4);
-      sp = VARBITS(s);
-      r = result;
-      *r++ = 'X';
-      *r++ = '\'';
-      /* we cheat by knowing that we store full bytes zero padded */
-      for (i=0; i<len; i+=2, sp++) {
-	*r++ = HEXDIG((*sp)>>4);
-	*r++ = HEXDIG((*sp) & 0xF);
-      }
-      /* Go back one step if we printed a hex number that was not part
-	 of the bitstring anymore */
-      if (i==len+1)
-	r--;
-      *r++ = '\'';
-      *r = '\0';
-    }
-  return result;
+	char	   *result,
+			   *r;
+	bits8	   *sp;
+	int			i,
+				len,
+				bitlen;
+
+	if (s == NULL)
+	{
+		result = (char *) palloc(2);
+		result[0] = '-';
+		result[1] = '\0';
+	}
+	else
+	{
+		bitlen = VARBITLEN(s);
+		len = bitlen / 4 + (bitlen % 4 > 0 ? 1 : 0);
+		result = (char *) palloc(len + 4);
+		sp = VARBITS(s);
+		r = result;
+		*r++ = 'X';
+		*r++ = '\'';
+		/* we cheat by knowing that we store full bytes zero padded */
+		for (i = 0; i < len; i += 2, sp++)
+		{
+			*r++ = HEXDIG((*sp) >> 4);
+			*r++ = HEXDIG((*sp) & 0xF);
+		}
+
+		/*
+		 * Go back one step if we printed a hex number that was not part
+		 * of the bitstring anymore
+		 */
+		if (i == len + 1)
+			r--;
+		*r++ = '\'';
+		*r = '\0';
+	}
+	return result;
 }
 
 /* zpbits_out -
- *    Prints the string a bits
+ *	  Prints the string a bits
  */
 char *
 zpbits_out(bits8 *s)
 {
-  char	   *result, *r;
-  bits8    *sp;
-  bits8    x;
-  int	   i, k, len;
-  
-  if (s == NULL)
-    {
-      result = (char *) palloc(2);
-      result[0] = '-';
-      result[1] = '\0';
-    }
-  else
-    {
-      len = VARBITLEN(s);
-      result = (char *) palloc(len + 4);
-      sp = VARBITS(s);
-      r = result;
-      *r++ = 'B';
-      *r++ = '\'';
-      for (i=0; i<len-BITSPERBYTE; i+=BITSPERBYTE, sp++) {
-	x = *sp;
-	for (k=0; k<BITSPERBYTE; k++) 
-	  {
-	    *r++ = (x & BITHIGH) ? '1' : '0';
-	    x <<= 1;
-	  }
-      }
-      x = *sp;
-      for (k=i; k<len; k++)
+	char	   *result,
+			   *r;
+	bits8	   *sp;
+	bits8		x;
+	int			i,
+				k,
+				len;
+
+	if (s == NULL)
 	{
-	  *r++ = (x & BITHIGH) ? '1' : '0';
-	  x <<= 1;
+		result = (char *) palloc(2);
+		result[0] = '-';
+		result[1] = '\0';
 	}
-      *r++ = '\'';
-      *r = '\0';
-    }
-  return result;
+	else
+	{
+		len = VARBITLEN(s);
+		result = (char *) palloc(len + 4);
+		sp = VARBITS(s);
+		r = result;
+		*r++ = 'B';
+		*r++ = '\'';
+		for (i = 0; i < len - BITSPERBYTE; i += BITSPERBYTE, sp++)
+		{
+			x = *sp;
+			for (k = 0; k < BITSPERBYTE; k++)
+			{
+				*r++ = (x & BITHIGH) ? '1' : '0';
+				x <<= 1;
+			}
+		}
+		x = *sp;
+		for (k = i; k < len; k++)
+		{
+			*r++ = (x & BITHIGH) ? '1' : '0';
+			x <<= 1;
+		}
+		*r++ = '\'';
+		*r = '\0';
+	}
+	return result;
 }
 
 
@@ -272,118 +298,133 @@ zpbits_out(bits8 *s)
  *	  converts a string to the internal representation of a bitstring.
 */
 bits8 *
-varbit_in(char *s, int dummy,  int32 atttypmod)
-{
-  bits8 *result;	/* The resulting bit string           */
-  char *sp;		/* pointer into the character string  */
-  bits8 *r;
-  int len,		/* Length of the whole data structure */
-    bitlen,		/* Number of bits in the bit string   */
-    slen;		/* Length of the input string         */
-  int bit_not_hex = 0;
-  int bc, ipad;
-  bits8 x = 0;
-
-
-  if (s == NULL)
-    return (bits8 *) NULL;
-
-  /* Check that the first character is a b or an x */
-  if (s[0]=='b' || s[0]=='B') 
-      bit_not_hex = 1;
-  else if (s[0]=='x' || s[0]=='X') 
-      bit_not_hex = 0;
-  else 
-    elog(ERROR, "zpbit_in: %s is not a valid bitstring",s);
-
-  slen = strlen(s) - 1;
-  /* Determine bitlength from input string */
-  bitlen = slen;
-  if (!bit_not_hex)
-    bitlen *= 4;
-  
-  /* Sometimes atttypmod is not supplied. If it is supplied we need to make
-     sure that the bitstring fits. Note that the number of infered bits can
-     be larger than the number of actual bits needed, but only if we are 
-     reading a hex string and not by more than 3 bits, as a hex string gives 
-     and accurate length upto 4 bits */
-  if (atttypmod > -1)
-    if ((bitlen>atttypmod && bit_not_hex) || 
-	(bitlen>atttypmod+3 && !bit_not_hex))
-	  elog(ERROR, "varbit_in: bit string of size %d cannot be written into varying bits(%d)",
-	       bitlen,atttypmod);
-
-
-  len = VARBITDATALEN(bitlen);
-
-  if (len > MaxAttrSize)
-    elog(ERROR, "varbit_in: length of bit() must be less than %ld",
-	 (MaxAttrSize-VARHDRSZ-VARBITHDRSZ)*BITSPERBYTE);
-
-  result = (bits8 *) palloc(len);
-  /* set to 0 so that *r is always initialised and strin is zero-padded */
-  memset(result, 0, len);
-  VARSIZE(result) = len;
-  VARBITLEN(result) = bitlen;
-
-  /* We need to read the bitstring from the end, as we store it least 
-     significant byte first. s points to the byte before the beginning
-     of the bitstring */
-  sp = s + 1;
-  r = VARBITS(result);
-  if (bit_not_hex) 
-    {
-      /* Parse the bit representation of the string */
-      x = BITHIGH;
-      for (bc = 0; sp != s+slen+1; sp++, bc++)
+varbit_in(char *s, int dummy, int32 atttypmod)
+{
+	bits8	   *result;			/* The resulting bit string			  */
+	char	   *sp;				/* pointer into the character string  */
+	bits8	   *r;
+	int			len,			/* Length of the whole data structure */
+				bitlen,			/* Number of bits in the bit string   */
+				slen;			/* Length of the input string		  */
+	int			bit_not_hex = 0;
+	int			bc,
+				ipad;
+	bits8		x = 0;
+
+
+	if (s == NULL)
+		return (bits8 *) NULL;
+
+	/* Check that the first character is a b or an x */
+	if (s[0] == 'b' || s[0] == 'B')
+		bit_not_hex = 1;
+	else if (s[0] == 'x' || s[0] == 'X')
+		bit_not_hex = 0;
+	else
+		elog(ERROR, "zpbit_in: %s is not a valid bitstring", s);
+
+	slen = strlen(s) - 1;
+	/* Determine bitlength from input string */
+	bitlen = slen;
+	if (!bit_not_hex)
+		bitlen *= 4;
+
+	/*
+	 * Sometimes atttypmod is not supplied. If it is supplied we need to
+	 * make sure that the bitstring fits. Note that the number of infered
+	 * bits can be larger than the number of actual bits needed, but only
+	 * if we are reading a hex string and not by more than 3 bits, as a
+	 * hex string gives and accurate length upto 4 bits
+	 */
+	if (atttypmod > -1)
+		if ((bitlen > atttypmod && bit_not_hex) ||
+			(bitlen > atttypmod + 3 && !bit_not_hex))
+			elog(ERROR, "varbit_in: bit string of size %d cannot be written into varying bits(%d)",
+				 bitlen, atttypmod);
+
+
+	len = VARBITDATALEN(bitlen);
+
+	if (len > MaxAttrSize)
+		elog(ERROR, "varbit_in: length of bit() must be less than %ld",
+			 (MaxAttrSize - VARHDRSZ - VARBITHDRSZ) * BITSPERBYTE);
+
+	result = (bits8 *) palloc(len);
+	/* set to 0 so that *r is always initialised and strin is zero-padded */
+	memset(result, 0, len);
+	VARSIZE(result) = len;
+	VARBITLEN(result) = bitlen;
+
+	/*
+	 * We need to read the bitstring from the end, as we store it least
+	 * significant byte first. s points to the byte before the beginning
+	 * of the bitstring
+	 */
+	sp = s + 1;
+	r = VARBITS(result);
+	if (bit_not_hex)
 	{
-	  if (*sp=='1')
-	    *r |= x;
-	  if (bc==7) {
-	    bc = 0;
-	    x = BITHIGH;
-	    r++;
-	  } else 
-	    x >>= 1;
+		/* Parse the bit representation of the string */
+		x = BITHIGH;
+		for (bc = 0; sp != s + slen + 1; sp++, bc++)
+		{
+			if (*sp == '1')
+				*r |= x;
+			if (bc == 7)
+			{
+				bc = 0;
+				x = BITHIGH;
+				r++;
+			}
+			else
+				x >>= 1;
+		}
 	}
-     }
-  else 
-    {
-      for (bc = 0; sp != s+slen+1; sp++)
+	else
 	{
-	  if (*sp>='0' && *sp<='9') 
-	    x = (bits8) (*sp - '0');
-	  else if (*sp>='A' && *sp<='F') 
-	    x = (bits8) (*sp - 'A') + 10;
-	  else if (*sp>='a' && *sp<='f') 
-	    x = (bits8) (*sp - 'a') + 10;
-	  else 
-	    elog(ERROR,"Cannot parse %c as a hex digit",*sp);
-	  if (bc) {
-	    bc = 0;
-	    *r++ |= x;
-	  } else {
-	    bc++;
-	    *r = x<<4;
-	  }
+		for (bc = 0; sp != s + slen + 1; sp++)
+		{
+			if (*sp >= '0' && *sp <= '9')
+				x = (bits8) (*sp - '0');
+			else if (*sp >= 'A' && *sp <= 'F')
+				x = (bits8) (*sp - 'A') + 10;
+			else if (*sp >= 'a' && *sp <= 'f')
+				x = (bits8) (*sp - 'a') + 10;
+			else
+				elog(ERROR, "Cannot parse %c as a hex digit", *sp);
+			if (bc)
+			{
+				bc = 0;
+				*r++ |= x;
+			}
+			else
+			{
+				bc++;
+				*r = x << 4;
+			}
+		}
 	}
-    }
 
-  if (bitlen > atttypmod) {
-    /* Check that this fitted */
-    r = (bits8 *) (result + len - 1);
-    ipad = VARBITPAD(result);
-    /* The bottom ipad bits of the byte pointed to by r need to be zero */
-    if (((*r << (BITSPERBYTE-ipad)) & BITMASK) > 0)
-      elog(ERROR, "varbit_in: bit string too large for varying bit(%d) data type",
-	   atttypmod);
-  }
+	if (bitlen > atttypmod)
+	{
+		/* Check that this fitted */
+		r = (bits8 *) (result + len - 1);
+		ipad = VARBITPAD(result);
+
+		/*
+		 * The bottom ipad bits of the byte pointed to by r need to be
+		 * zero
+		 */
+		if (((*r << (BITSPERBYTE - ipad)) & BITMASK) > 0)
+			elog(ERROR, "varbit_in: bit string too large for varying bit(%d) data type",
+				 atttypmod);
+	}
 
-  return result;
+	return result;
 }
 
 /*
-  the zpbit_out routines are fine for varying bits as well 
+  the zpbit_out routines are fine for varying bits as well
 */
 
 
@@ -391,227 +432,243 @@ varbit_in(char *s, int dummy,  int32 atttypmod)
  * Comparison operators
  *
  * We only need one set of comparison operators for bitstrings, as the lengths
- * are stored in the same way for zero-padded and varying bit strings. 
+ * are stored in the same way for zero-padded and varying bit strings.
  *
- * Note that the standard is not unambiguous about the comparison between 
+ * Note that the standard is not unambiguous about the comparison between
  * zero-padded bit strings and varying bitstrings. If the same value is written
- * into a zero padded bitstring as into a varying bitstring, but the zero 
- * padded bitstring has greater length, it will be bigger. 
+ * into a zero padded bitstring as into a varying bitstring, but the zero
+ * padded bitstring has greater length, it will be bigger.
  *
  * Zeros from the beginning of a bitstring cannot simply be ignored, as they
  * may be part of a bit string and may be significant.
  */
 
 bool
-biteq (bits8 *arg1, bits8 *arg2)
+biteq(bits8 *arg1, bits8 *arg2)
 {
-  int bitlen1,
-    bitlen2;
+	int			bitlen1,
+				bitlen2;
+
+	if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
+		return (bool) 0;
+	bitlen1 = VARBITLEN(arg1);
+	bitlen2 = VARBITLEN(arg2);
+	if (bitlen1 != bitlen2)
+		return (bool) 0;
 
-  if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
-    return (bool) 0;
-  bitlen1 = VARBITLEN(arg1);
-  bitlen2 = VARBITLEN(arg2);
-  if (bitlen1 != bitlen2)
-    return (bool) 0;
-  
-  /* bit strings are always stored in a full number of bytes */
-  return memcmp((void *)VARBITS(arg1),(void *)VARBITS(arg2),
-		VARBITBYTES(arg1)) == 0;
+	/* bit strings are always stored in a full number of bytes */
+	return memcmp((void *) VARBITS(arg1), (void *) VARBITS(arg2),
+				  VARBITBYTES(arg1)) == 0;
 }
 
 bool
-bitne (bits8 *arg1, bits8 *arg2)
+bitne(bits8 *arg1, bits8 *arg2)
 {
-  int bitlen1,
-    bitlen2;
+	int			bitlen1,
+				bitlen2;
 
-  if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
-    return (bool) 0;
-  bitlen1 = VARBITLEN(arg1);
-  bitlen2 = VARBITLEN(arg2);
-  if (bitlen1 != bitlen2)
-    return (bool) 1;
-  
-  /* bit strings are always stored in a full number of bytes */
-  return memcmp((void *)VARBITS(arg1),(void *)VARBITS(arg2),
-		VARBITBYTES(arg1)) != 0;
+	if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
+		return (bool) 0;
+	bitlen1 = VARBITLEN(arg1);
+	bitlen2 = VARBITLEN(arg2);
+	if (bitlen1 != bitlen2)
+		return (bool) 1;
+
+	/* bit strings are always stored in a full number of bytes */
+	return memcmp((void *) VARBITS(arg1), (void *) VARBITS(arg2),
+				  VARBITBYTES(arg1)) != 0;
 }
 
 /* bitcmp
- * 
+ *
  * Compares two bitstrings and returns -1, 0, 1 depending on whether the first
  * string is smaller, equal, or bigger than the second. All bits are considered
  * and additional zero bits may make one string smaller/larger than the other,
  * even if their zero-padded values would be the same.
- *   Anything is equal to undefined.
+ *	 Anything is equal to undefined.
  */
-int 
-bitcmp (bits8 *arg1, bits8 *arg2)
-{
-  int bitlen1, bytelen1,
-    bitlen2, bytelen2;
-  int cmp;
-
-  if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
-    return (bool) 0;
-  bytelen1 = VARBITBYTES(arg1);  
-  bytelen2 = VARBITBYTES(arg2);
-  
-  cmp = memcmp(VARBITS(arg1),VARBITS(arg2),Min(bytelen1,bytelen2));
-  if (cmp==0) {
-    bitlen1 = VARBITLEN(arg1);
-    bitlen2 = VARBITLEN(arg2);
-    if (bitlen1 != bitlen2) 
-      return bitlen1 < bitlen2 ? -1 : 1;
-  }
-  return cmp;
+int
+bitcmp(bits8 *arg1, bits8 *arg2)
+{
+	int			bitlen1,
+				bytelen1,
+				bitlen2,
+				bytelen2;
+	int			cmp;
+
+	if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
+		return (bool) 0;
+	bytelen1 = VARBITBYTES(arg1);
+	bytelen2 = VARBITBYTES(arg2);
+
+	cmp = memcmp(VARBITS(arg1), VARBITS(arg2), Min(bytelen1, bytelen2));
+	if (cmp == 0)
+	{
+		bitlen1 = VARBITLEN(arg1);
+		bitlen2 = VARBITLEN(arg2);
+		if (bitlen1 != bitlen2)
+			return bitlen1 < bitlen2 ? -1 : 1;
+	}
+	return cmp;
 }
 
 bool
-bitlt (bits8 *arg1, bits8 *arg2)
+bitlt(bits8 *arg1, bits8 *arg2)
 {
-  return (bool) (bitcmp(arg1,arg2) == -1);
+	return (bool) (bitcmp(arg1, arg2) == -1);
 }
 
 bool
-bitle (bits8 *arg1, bits8 *arg2)
+bitle(bits8 *arg1, bits8 *arg2)
 {
-  return (bool) (bitcmp(arg1,arg2) <= 0);
+	return (bool) (bitcmp(arg1, arg2) <= 0);
 }
 
 bool
-bitge (bits8 *arg1, bits8 *arg2)
+bitge(bits8 *arg1, bits8 *arg2)
 {
-  return (bool) (bitcmp(arg1,arg2) >= 0);
+	return (bool) (bitcmp(arg1, arg2) >= 0);
 }
 
 bool
-bitgt (bits8 *arg1, bits8 *arg2)
+bitgt(bits8 *arg1, bits8 *arg2)
 {
-  return (bool) (bitcmp(arg1,arg2) == 1);
+	return (bool) (bitcmp(arg1, arg2) == 1);
 }
 
 /* bitcat
  * Concatenation of bit strings
  */
 bits8 *
-bitcat (bits8 *arg1, bits8 *arg2)
-{
-  int bitlen1, bitlen2, bytelen, bit1pad, bit2shift;
-  bits8 *result;
-  bits8 *pr, *pa;
-
-  if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
-    return NULL;
-
-  bitlen1 = VARBITLEN(arg1);
-  bitlen2 = VARBITLEN(arg2);
-
-  bytelen = VARBITDATALEN(bitlen1+bitlen2);
-  
-  result = (bits8 *) palloc(bytelen*sizeof(bits8));
-  VARSIZE(result) = bytelen;
-  VARBITLEN(result) = bitlen1+bitlen2;
-  /* Copy the first bitstring in */
-  memcpy(VARBITS(result),VARBITS(arg1),VARBITBYTES(arg1));
-  /* Copy the second bit string */
-  bit1pad = VARBITPAD(arg1);
-  if (bit1pad==0) 
-    {
-      memcpy(VARBITS(result)+VARBITBYTES(arg1),VARBITS(arg2),
-	     VARBITBYTES(arg2));
-    }
-  else if (bitlen2>0)
-    {
-      /* We need to shift all the results to fit */
-      bit2shift = BITSPERBYTE - bit1pad;
-      pa = VARBITS(arg2);
-      pr = VARBITS(result)+VARBITBYTES(arg1)-1;
-      for ( ; pa < VARBITEND(arg2); pa++) {
-	*pr |= ((*pa >> bit2shift) & BITMASK);
-	pr++;
-	if (pr < VARBITEND(result))
-	  *pr = (*pa << bit1pad) & BITMASK;
-      }
-    }
-
-  return result;
+bitcat(bits8 *arg1, bits8 *arg2)
+{
+	int			bitlen1,
+				bitlen2,
+				bytelen,
+				bit1pad,
+				bit2shift;
+	bits8	   *result;
+	bits8	   *pr,
+			   *pa;
+
+	if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
+		return NULL;
+
+	bitlen1 = VARBITLEN(arg1);
+	bitlen2 = VARBITLEN(arg2);
+
+	bytelen = VARBITDATALEN(bitlen1 + bitlen2);
+
+	result = (bits8 *) palloc(bytelen * sizeof(bits8));
+	VARSIZE(result) = bytelen;
+	VARBITLEN(result) = bitlen1 + bitlen2;
+	/* Copy the first bitstring in */
+	memcpy(VARBITS(result), VARBITS(arg1), VARBITBYTES(arg1));
+	/* Copy the second bit string */
+	bit1pad = VARBITPAD(arg1);
+	if (bit1pad == 0)
+	{
+		memcpy(VARBITS(result) + VARBITBYTES(arg1), VARBITS(arg2),
+			   VARBITBYTES(arg2));
+	}
+	else if (bitlen2 > 0)
+	{
+		/* We need to shift all the results to fit */
+		bit2shift = BITSPERBYTE - bit1pad;
+		pa = VARBITS(arg2);
+		pr = VARBITS(result) + VARBITBYTES(arg1) - 1;
+		for (; pa < VARBITEND(arg2); pa++)
+		{
+			*pr |= ((*pa >> bit2shift) & BITMASK);
+			pr++;
+			if (pr < VARBITEND(result))
+				*pr = (*pa << bit1pad) & BITMASK;
+		}
+	}
+
+	return result;
 }
 
 /* bitsubstr
- * retrieve a substring from the bit string. 
+ * retrieve a substring from the bit string.
  * Note, s is 1-based.
  * SQL draft 6.10 9)
  */
-bits8 * 
-bitsubstr (bits8 *arg, int32 s, int32 l)
-{
-  int bitlen,
-    rbitlen,
-    len,
-    ipad = 0,
-    ishift,
-    i;
-  int e, s1, e1;
-  bits8 * result;
-  bits8 mask, *r, *ps;
-
-  if (!PointerIsValid(arg))
-    return NULL;
-
-  bitlen = VARBITLEN(arg);
-  e = s+l;
-  s1 = Max(s,1);
-  e1 = Min(e,bitlen+1);
-  if (s1>bitlen || e1<1) 
-    {
-      /* Need to return a null string */
-      len = VARBITDATALEN(0);
-      result = (bits8 *) palloc(len);
-      VARBITLEN(result) = 0;
-      VARSIZE(result) = len;
-    } 
-  else 
-    {
-      /* OK, we've got a true substring starting at position s1-1 and 
-	 ending at position e1-1 */
-      rbitlen = e1-s1;
-      len = VARBITDATALEN(rbitlen);
-      result = (bits8 *) palloc(len);
-      VARBITLEN(result) = rbitlen;
-      VARSIZE(result) = len;
-      len -= VARHDRSZ + VARBITHDRSZ;
-      /* Are we copying from a byte boundary? */
-      if ((s1-1)%BITSPERBYTE==0) 
-	{
-	  /* Yep, we are copying bytes */
-	  memcpy(VARBITS(result),VARBITS(arg)+(s1-1)/BITSPERBYTE,len);
-	} 
-      else 
+bits8 *
+bitsubstr(bits8 *arg, int32 s, int32 l)
+{
+	int			bitlen,
+				rbitlen,
+				len,
+				ipad = 0,
+				ishift,
+				i;
+	int			e,
+				s1,
+				e1;
+	bits8	   *result;
+	bits8		mask,
+			   *r,
+			   *ps;
+
+	if (!PointerIsValid(arg))
+		return NULL;
+
+	bitlen = VARBITLEN(arg);
+	e = s + l;
+	s1 = Max(s, 1);
+	e1 = Min(e, bitlen + 1);
+	if (s1 > bitlen || e1 < 1)
 	{
-	  /* Figure out how much we need to shift the sequence by */
-	  ishift = (s1-1)%BITSPERBYTE;
-	  r = VARBITS(result);
-	  ps = VARBITS(arg) + (s1-1)/BITSPERBYTE;
-	  for (i=0; i<len; i++) 
-	    {
-	      *r = (*ps <<ishift) & BITMASK;
-	      if ((++ps) < VARBITEND(arg))
-		*r |= *ps >>(BITSPERBYTE-ishift);
-	      r++;
-	    }
+		/* Need to return a null string */
+		len = VARBITDATALEN(0);
+		result = (bits8 *) palloc(len);
+		VARBITLEN(result) = 0;
+		VARSIZE(result) = len;
 	}
-      /* Do we need to pad at the end? */
-      ipad = VARBITPAD(result);
-      if (ipad > 0) 
+	else
 	{
-	  mask = BITMASK << ipad;
-	  *(VARBITS(result) + len - 1) &= mask;
+
+		/*
+		 * OK, we've got a true substring starting at position s1-1 and
+		 * ending at position e1-1
+		 */
+		rbitlen = e1 - s1;
+		len = VARBITDATALEN(rbitlen);
+		result = (bits8 *) palloc(len);
+		VARBITLEN(result) = rbitlen;
+		VARSIZE(result) = len;
+		len -= VARHDRSZ + VARBITHDRSZ;
+		/* Are we copying from a byte boundary? */
+		if ((s1 - 1) % BITSPERBYTE == 0)
+		{
+			/* Yep, we are copying bytes */
+			memcpy(VARBITS(result), VARBITS(arg) + (s1 - 1) / BITSPERBYTE, len);
+		}
+		else
+		{
+			/* Figure out how much we need to shift the sequence by */
+			ishift = (s1 - 1) % BITSPERBYTE;
+			r = VARBITS(result);
+			ps = VARBITS(arg) + (s1 - 1) / BITSPERBYTE;
+			for (i = 0; i < len; i++)
+			{
+				*r = (*ps << ishift) & BITMASK;
+				if ((++ps) < VARBITEND(arg))
+					*r |= *ps >> (BITSPERBYTE - ishift);
+				r++;
+			}
+		}
+		/* Do we need to pad at the end? */
+		ipad = VARBITPAD(result);
+		if (ipad > 0)
+		{
+			mask = BITMASK << ipad;
+			*(VARBITS(result) + len - 1) &= mask;
+		}
 	}
-    }
 
-  return result;
+	return result;
 }
 
 /* bitand
@@ -619,32 +676,32 @@ bitsubstr (bits8 *arg, int32 s, int32 l)
  * truncated to the shorter bit string
  */
 bits8 *
-bitand (bits8 * arg1, bits8 * arg2)
-{
-  int len,
-    i;
-  bits8 *result;
-  bits8 *p1, 
-    *p2, 
-    *r;
-
-  if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
-    return (bool) 0;
-
-  len = Min(VARSIZE(arg1),VARSIZE(arg2));
-  result = (bits8 *) palloc(len);
-  VARSIZE(result) = len;
-  VARBITLEN(result) = Min(VARBITLEN(arg1),VARBITLEN(arg2));
-
-  p1 = (bits8 *) VARBITS(arg1);
-  p2 = (bits8 *) VARBITS(arg2);
-  r = (bits8 *) VARBITS(result);
-  for (i=0; i<Min(VARBITBYTES(arg1),VARBITBYTES(arg2)); i++)
-    *r++ = *p1++ & *p2++;
-  
-  /* Padding is not needed as & of 0 pad is 0 */
-  
-  return result;
+bitand(bits8 *arg1, bits8 *arg2)
+{
+	int			len,
+				i;
+	bits8	   *result;
+	bits8	   *p1,
+			   *p2,
+			   *r;
+
+	if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
+		return (bool) 0;
+
+	len = Min(VARSIZE(arg1), VARSIZE(arg2));
+	result = (bits8 *) palloc(len);
+	VARSIZE(result) = len;
+	VARBITLEN(result) = Min(VARBITLEN(arg1), VARBITLEN(arg2));
+
+	p1 = (bits8 *) VARBITS(arg1);
+	p2 = (bits8 *) VARBITS(arg2);
+	r = (bits8 *) VARBITS(result);
+	for (i = 0; i < Min(VARBITBYTES(arg1), VARBITBYTES(arg2)); i++)
+		*r++ = *p1++ & *p2++;
+
+	/* Padding is not needed as & of 0 pad is 0 */
+
+	return result;
 }
 
 /* bitor
@@ -652,35 +709,35 @@ bitand (bits8 * arg1, bits8 * arg2)
  * truncated to the shorter bit string.
  */
 bits8 *
-bitor (bits8 * arg1, bits8 * arg2)
+bitor(bits8 *arg1, bits8 *arg2)
 {
-  int len,
-    i;
-  bits8 *result;
-  bits8 *p1, 
-    *p2, 
-    *r;
-  bits8 mask;
+	int			len,
+				i;
+	bits8	   *result;
+	bits8	   *p1,
+			   *p2,
+			   *r;
+	bits8		mask;
 
-  if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
-    return (bool) 0;
+	if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
+		return (bool) 0;
 
-  len = Min(VARSIZE(arg1),VARSIZE(arg2));
-  result = (bits8 *) palloc(len);
-  VARSIZE(result) = len;
-  VARBITLEN(result) = Min(VARBITLEN(arg1),VARBITLEN(arg2));
+	len = Min(VARSIZE(arg1), VARSIZE(arg2));
+	result = (bits8 *) palloc(len);
+	VARSIZE(result) = len;
+	VARBITLEN(result) = Min(VARBITLEN(arg1), VARBITLEN(arg2));
 
-  p1 = (bits8 *) VARBITS(arg1);
-  p2 = (bits8 *) VARBITS(arg2);
-  r = (bits8 *) VARBITS(result);
-  for (i=0; i<Min(VARBITBYTES(arg1),VARBITBYTES(arg2)); i++)
-    *r++ = *p1++ | *p2++;
+	p1 = (bits8 *) VARBITS(arg1);
+	p2 = (bits8 *) VARBITS(arg2);
+	r = (bits8 *) VARBITS(result);
+	for (i = 0; i < Min(VARBITBYTES(arg1), VARBITBYTES(arg2)); i++)
+		*r++ = *p1++ | *p2++;
 
-  /* Pad the result */
-  mask = BITMASK << VARBITPAD(result);
-  *r &= mask;
-  
-  return result;
+	/* Pad the result */
+	mask = BITMASK << VARBITPAD(result);
+	*r &= mask;
+
+	return result;
 }
 
 /* bitxor
@@ -688,250 +745,257 @@ bitor (bits8 * arg1, bits8 * arg2)
  * truncated to the shorter bit string.
  */
 bits8 *
-bitxor (bits8 * arg1, bits8 * arg2)
-{
-  int len,
-    i;
-  bits8 *result;
-  bits8 *p1, 
-    *p2, 
-    *r;
-  bits8 mask;
-
-  if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
-    return (bool) 0;
-
-  len = Min(VARSIZE(arg1),VARSIZE(arg2));
-  result = (bits8 *) palloc(len);
-  VARSIZE(result) = len;
-  VARBITLEN(result) = Min(VARBITLEN(arg1),VARBITLEN(arg2));
-
-  p1 = (bits8 *) VARBITS(arg1);
-  p2 = (bits8 *) VARBITS(arg2);
-  r = (bits8 *) VARBITS(result);
-  for (i=0; i<Min(VARBITBYTES(arg1),VARBITBYTES(arg2)); i++)
-    {
-      *r++ = *p1++ ^ *p2++;
-    }
-
-  /* Pad the result */
-  mask = BITMASK << VARBITPAD(result);
-  *r &= mask;
-  
-  return result;
+bitxor(bits8 *arg1, bits8 *arg2)
+{
+	int			len,
+				i;
+	bits8	   *result;
+	bits8	   *p1,
+			   *p2,
+			   *r;
+	bits8		mask;
+
+	if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
+		return (bool) 0;
+
+	len = Min(VARSIZE(arg1), VARSIZE(arg2));
+	result = (bits8 *) palloc(len);
+	VARSIZE(result) = len;
+	VARBITLEN(result) = Min(VARBITLEN(arg1), VARBITLEN(arg2));
+
+	p1 = (bits8 *) VARBITS(arg1);
+	p2 = (bits8 *) VARBITS(arg2);
+	r = (bits8 *) VARBITS(result);
+	for (i = 0; i < Min(VARBITBYTES(arg1), VARBITBYTES(arg2)); i++)
+		*r++ = *p1++ ^ *p2++;
+
+	/* Pad the result */
+	mask = BITMASK << VARBITPAD(result);
+	*r &= mask;
+
+	return result;
 }
 
 /* bitnot
  * perform a logical NOT on a bit strings.
  */
 bits8 *
-bitnot (bits8 * arg)
+bitnot(bits8 *arg)
 {
-  bits8 *result;
-  bits8 *p, 
-    *r;
-  bits8 mask;
+	bits8	   *result;
+	bits8	   *p,
+			   *r;
+	bits8		mask;
+
+	if (!PointerIsValid(arg))
+		return (bool) 0;
 
-  if (!PointerIsValid(arg))
-    return (bool) 0;
+	result = (bits8 *) palloc(VARSIZE(arg));
+	VARSIZE(result) = VARSIZE(arg);
+	VARBITLEN(result) = VARBITLEN(arg);
 
-  result = (bits8 *) palloc(VARSIZE(arg));
-  VARSIZE(result) = VARSIZE(arg);
-  VARBITLEN(result) = VARBITLEN(arg);
+	p = (bits8 *) VARBITS(arg);
+	r = (bits8 *) VARBITS(result);
+	for (; p < VARBITEND(arg); p++, r++)
+		*r = ~*p;
 
-  p = (bits8 *) VARBITS(arg);
-  r = (bits8 *) VARBITS(result);
-  for ( ; p < VARBITEND(arg); p++, r++)
-    *r = ~*p;
+	/* Pad the result */
+	mask = BITMASK << VARBITPAD(result);
+	*r &= mask;
 
-  /* Pad the result */
-  mask = BITMASK << VARBITPAD(result);
-  *r &= mask;
-  
-  return result;
+	return result;
 }
 
 /* bitshiftleft
  * do a left shift (i.e. to the beginning of the string) of the bit string
  */
 bits8 *
-bitshiftleft (bits8 * arg, int shft)
-{
-  int byte_shift, ishift, len;
-  bits8 *result;
-  bits8 *p, 
-    *r;
-
-  if (!PointerIsValid(arg))
-    return (bool) 0;
-
-  /* Negative shift is a shift to the right */
-  if (shft < 0) 
-    return bitshiftright(arg, -shft);
-
-  result = (bits8 *) palloc(VARSIZE(arg));
-  VARSIZE(result) = VARSIZE(arg);
-  VARBITLEN(result) = VARBITLEN(arg);
-  r = (bits8 *) VARBITS(result);
-
-  byte_shift = shft/BITSPERBYTE;
-  ishift = shft % BITSPERBYTE;
-  p = ((bits8 *) VARBITS(arg)) + byte_shift;
-  
-  if (ishift == 0) {
-    /* Special case: we can do a memcpy */
-    len = VARBITBYTES(arg) - byte_shift;
-    memcpy(r, p, len);
-    memset(r+len, 0, byte_shift);
-  } else {
-    for ( ; p < VARBITEND(arg); r++) {
-      *r = *p <<ishift;
-      if ((++p) < VARBITEND(arg))
-	*r |= *p >>(BITSPERBYTE-ishift);
-    }
-    for ( ; r < VARBITEND(result) ; r++ ) 
-      *r = (bits8) 0;
-  }
-
-  return result;
+bitshiftleft(bits8 *arg, int shft)
+{
+	int			byte_shift,
+				ishift,
+				len;
+	bits8	   *result;
+	bits8	   *p,
+			   *r;
+
+	if (!PointerIsValid(arg))
+		return (bool) 0;
+
+	/* Negative shift is a shift to the right */
+	if (shft < 0)
+		return bitshiftright(arg, -shft);
+
+	result = (bits8 *) palloc(VARSIZE(arg));
+	VARSIZE(result) = VARSIZE(arg);
+	VARBITLEN(result) = VARBITLEN(arg);
+	r = (bits8 *) VARBITS(result);
+
+	byte_shift = shft / BITSPERBYTE;
+	ishift = shft % BITSPERBYTE;
+	p = ((bits8 *) VARBITS(arg)) + byte_shift;
+
+	if (ishift == 0)
+	{
+		/* Special case: we can do a memcpy */
+		len = VARBITBYTES(arg) - byte_shift;
+		memcpy(r, p, len);
+		memset(r + len, 0, byte_shift);
+	}
+	else
+	{
+		for (; p < VARBITEND(arg); r++)
+		{
+			*r = *p << ishift;
+			if ((++p) < VARBITEND(arg))
+				*r |= *p >> (BITSPERBYTE - ishift);
+		}
+		for (; r < VARBITEND(result); r++)
+			*r = (bits8) 0;
+	}
+
+	return result;
 }
 
 /* bitshiftright
  * do a right shift (i.e. to the beginning of the string) of the bit string
  */
 bits8 *
-bitshiftright (bits8 * arg, int shft)
-{
-  int byte_shift, ishift, len;
-  bits8 *result;
-  bits8 *p, 
-    *r;
-
-  if (!PointerIsValid(arg))
-    return (bits8 *) 0;
-
-  /* Negative shift is a shift to the left */
-  if (shft < 0) 
-    return bitshiftleft(arg, -shft);
-
-  result = (bits8 *) palloc(VARSIZE(arg));
-  VARSIZE(result) = VARSIZE(arg);
-  VARBITLEN(result) = VARBITLEN(arg);
-  r = (bits8 *) VARBITS(result);
-
-  byte_shift = shft/BITSPERBYTE;
-  ishift = shft % BITSPERBYTE;
-  p = (bits8 *) VARBITS(arg);
-
-  /* Set the first part of the result to 0 */
-  memset(r, 0, byte_shift);
-  
-  if (ishift == 0) 
-    {
-      /* Special case: we can do a memcpy */
-      len = VARBITBYTES(arg) - byte_shift;
-      memcpy(r+byte_shift, p, len);
-    } 
-  else 
-    {
-      r += byte_shift;
-      *r = 0;    /* Initialise first byte */
-      for ( ; r < VARBITEND(result); p++) {
-	*r |= *p >> ishift;
-	if ((++r) < VARBITEND(result))
-	  *r = (*p <<(BITSPERBYTE-ishift)) & BITMASK;
-      }
-    }
-
-  return result;
+bitshiftright(bits8 *arg, int shft)
+{
+	int			byte_shift,
+				ishift,
+				len;
+	bits8	   *result;
+	bits8	   *p,
+			   *r;
+
+	if (!PointerIsValid(arg))
+		return (bits8 *) 0;
+
+	/* Negative shift is a shift to the left */
+	if (shft < 0)
+		return bitshiftleft(arg, -shft);
+
+	result = (bits8 *) palloc(VARSIZE(arg));
+	VARSIZE(result) = VARSIZE(arg);
+	VARBITLEN(result) = VARBITLEN(arg);
+	r = (bits8 *) VARBITS(result);
+
+	byte_shift = shft / BITSPERBYTE;
+	ishift = shft % BITSPERBYTE;
+	p = (bits8 *) VARBITS(arg);
+
+	/* Set the first part of the result to 0 */
+	memset(r, 0, byte_shift);
+
+	if (ishift == 0)
+	{
+		/* Special case: we can do a memcpy */
+		len = VARBITBYTES(arg) - byte_shift;
+		memcpy(r + byte_shift, p, len);
+	}
+	else
+	{
+		r += byte_shift;
+		*r = 0;					/* Initialise first byte */
+		for (; r < VARBITEND(result); p++)
+		{
+			*r |= *p >> ishift;
+			if ((++r) < VARBITEND(result))
+				*r = (*p << (BITSPERBYTE - ishift)) & BITMASK;
+		}
+	}
+
+	return result;
 }
 
 bool
-varbiteq (bits8 *arg1, bits8 *arg2)
+varbiteq(bits8 *arg1, bits8 *arg2)
 {
 	return biteq(arg1, arg2);
 }
 
 bool
-varbitne (bits8 *arg1, bits8 *arg2)
+varbitne(bits8 *arg1, bits8 *arg2)
 {
 	return bitne(arg1, arg2);
 }
 
 bool
-varbitge (bits8 *arg1, bits8 *arg2)
+varbitge(bits8 *arg1, bits8 *arg2)
 {
 	return bitge(arg1, arg2);
 }
 
 bool
-varbitgt (bits8 *arg1, bits8 *arg2)
+varbitgt(bits8 *arg1, bits8 *arg2)
 {
 	return bitgt(arg1, arg2);
 }
 
 bool
-varbitle (bits8 *arg1, bits8 *arg2)
+varbitle(bits8 *arg1, bits8 *arg2)
 {
 	return bitle(arg1, arg2);
 }
 
 bool
-varbitlt (bits8 *arg1, bits8 *arg2)
+varbitlt(bits8 *arg1, bits8 *arg2)
 {
 	return bitlt(arg1, arg2);
 }
 
 int
-varbitcmp (bits8 *arg1, bits8 *arg2)
+varbitcmp(bits8 *arg1, bits8 *arg2)
 {
 	return bitcmp(arg1, arg2);
 }
 
 bits8 *
-varbitand (bits8 * arg1, bits8 * arg2)
+varbitand(bits8 *arg1, bits8 *arg2)
 {
 	return bitand(arg1, arg2);
 }
 
 bits8 *
-varbitor (bits8 * arg1, bits8 * arg2)
+varbitor(bits8 *arg1, bits8 *arg2)
 {
 	return bitor(arg1, arg2);
 }
 
 bits8 *
-varbitxor (bits8 * arg1, bits8 * arg2)
+varbitxor(bits8 *arg1, bits8 *arg2)
 {
 	return bitxor(arg1, arg2);
 }
 
 bits8 *
-varbitnot (bits8 * arg)
+varbitnot(bits8 *arg)
 {
 	return bitnot(arg);
 }
 
 bits8 *
-varbitshiftright (bits8 * arg, int shft)
+varbitshiftright(bits8 *arg, int shft)
 {
 	return bitshiftright(arg, shft);
 }
 
 bits8 *
-varbitshiftleft (bits8 * arg, int shft)
+varbitshiftleft(bits8 *arg, int shft)
 {
 	return bitshiftleft(arg, shft);
 }
 
 bits8 *
-varbitcat (bits8 *arg1, bits8 *arg2)
+varbitcat(bits8 *arg1, bits8 *arg2)
 {
 	return bitcat(arg1, arg2);
 }
 
 bits8 *
-varbitsubstr (bits8 *arg, int32 s, int32 l)
+varbitsubstr(bits8 *arg, int32 s, int32 l)
 {
 	return bitsubstr(arg, s, l);
 }
diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c
index 8028f0bce823beeb71f6b16360c2278c69aa9d41..0837b8b63a1ba0ed958d98fa2b83b3ab012224e1 100644
--- a/src/backend/utils/adt/varchar.c
+++ b/src/backend/utils/adt/varchar.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.59 2000/03/13 01:54:07 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.60 2000/04/12 17:15:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -24,6 +24,7 @@
 
 #ifdef CYR_RECODE
 char	   *convertstr(char *, int, int);
+
 #endif
 
 
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index b333a0ed4e36fc2ca49619b5315cc772b00a2026..154d8beb270639c3d0f4844ad26e93a405b17ef1 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.57 2000/03/24 02:41:46 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.58 2000/04/12 17:15:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -682,9 +682,9 @@ byteaGetBit(bytea *v, int32 n)
 
 	len = VARSIZE(v) - VARHDRSZ;
 
-	if (n < 0 || n >= len*8)
+	if (n < 0 || n >= len * 8)
 		elog(ERROR, "byteaGetBit: index %d out of range [0..%d]",
-			 n, len*8 - 1);
+			 n, len * 8 - 1);
 
 	byteNo = n / 8;
 	bitNo = n % 8;
@@ -757,9 +757,9 @@ byteaSetBit(bytea *v, int32 n, int32 newBit)
 
 	len = VARSIZE(v) - VARHDRSZ;
 
-	if (n < 0 || n >= len*8)
+	if (n < 0 || n >= len * 8)
 		elog(ERROR, "byteaSetBit: index %d out of range [0..%d]",
-			 n, len*8 - 1);
+			 n, len * 8 - 1);
 
 	byteNo = n / 8;
 	bitNo = n % 8;
diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c
index 297c92b56e72ca11f16888bff4e48139df1c7649..b593920b1a819a6c7e32178fd2a88d525742424c 100644
--- a/src/backend/utils/cache/catcache.c
+++ b/src/backend/utils/cache/catcache.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.62 2000/02/21 03:36:49 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.63 2000/04/12 17:15:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -30,10 +30,10 @@
 static void CatCacheRemoveCTup(CatCache *cache, Dlelem *e);
 static Index CatalogCacheComputeHashIndex(struct catcache * cacheInP);
 static Index CatalogCacheComputeTupleHashIndex(struct catcache * cacheInOutP,
-											   Relation relation,
-											   HeapTuple tuple);
+								  Relation relation,
+								  HeapTuple tuple);
 static void CatalogCacheInitializeCache(struct catcache * cache,
-										Relation relation);
+							Relation relation);
 static uint32 cc_hashname(NameData *n);
 
 /* ----------------
@@ -57,9 +57,10 @@ static uint32 cc_hashname(NameData *n);
 #define CACHE6_elog(a,b,c,d,e,f,g)
 #endif
 
-static CatCache   *Caches = NULL; /* head of list of caches */
+static CatCache *Caches = NULL; /* head of list of caches */
 
 GlobalMemory CacheCxt;			/* context in which caches are allocated */
+
 /* CacheCxt is global because relcache uses it too. */
 
 
@@ -90,8 +91,8 @@ GetCCHashFunc(Oid keytype)
 {
 	switch (keytype)
 	{
-		case BOOLOID:
-		case CHAROID:
+			case BOOLOID:
+			case CHAROID:
 			return (CCHashFunc) hashchar;
 		case NAMEOID:
 			return (CCHashFunc) cc_hashname;
@@ -118,11 +119,12 @@ GetCCHashFunc(Oid keytype)
 static uint32
 cc_hashname(NameData *n)
 {
+
 	/*
 	 * We need our own variant of hashname because we want to accept
-	 * null-terminated C strings as search values for name fields.
-	 * So, we have to make sure the data is correctly padded before
-	 * we compute the hash value.
+	 * null-terminated C strings as search values for name fields. So, we
+	 * have to make sure the data is correctly padded before we compute
+	 * the hash value.
 	 */
 	NameData	my_n;
 
@@ -242,11 +244,14 @@ CatalogCacheInitializeCache(struct catcache * cache,
 
 		if (cache->cc_key[i] > 0)
 		{
-			Oid		keytype = tupdesc->attrs[cache->cc_key[i] - 1]->atttypid;
+			Oid			keytype = tupdesc->attrs[cache->cc_key[i] - 1]->atttypid;
 
 			cache->cc_hashfunc[i] = GetCCHashFunc(keytype);
 
-			/* If GetCCHashFunc liked the type, safe to index into eqproc[] */
+			/*
+			 * If GetCCHashFunc liked the type, safe to index into
+			 * eqproc[]
+			 */
 			cache->cc_skey[i].sk_procedure = EQPROC(keytype);
 
 			fmgr_info(cache->cc_skey[i].sk_procedure,
@@ -314,19 +319,19 @@ CatalogCacheComputeHashIndex(struct catcache * cacheInP)
 	{
 		case 4:
 			hashIndex ^=
-				(*cacheInP->cc_hashfunc[3])(cacheInP->cc_skey[3].sk_argument) << 9;
+				(*cacheInP->cc_hashfunc[3]) (cacheInP->cc_skey[3].sk_argument) << 9;
 			/* FALLTHROUGH */
 		case 3:
 			hashIndex ^=
-				(*cacheInP->cc_hashfunc[2])(cacheInP->cc_skey[2].sk_argument) << 6;
+				(*cacheInP->cc_hashfunc[2]) (cacheInP->cc_skey[2].sk_argument) << 6;
 			/* FALLTHROUGH */
 		case 2:
 			hashIndex ^=
-				(*cacheInP->cc_hashfunc[1])(cacheInP->cc_skey[1].sk_argument) << 3;
+				(*cacheInP->cc_hashfunc[1]) (cacheInP->cc_skey[1].sk_argument) << 3;
 			/* FALLTHROUGH */
 		case 1:
 			hashIndex ^=
-				(*cacheInP->cc_hashfunc[0])(cacheInP->cc_skey[0].sk_argument);
+				(*cacheInP->cc_hashfunc[0]) (cacheInP->cc_skey[0].sk_argument);
 			break;
 		default:
 			elog(FATAL, "CCComputeHashIndex: %d cc_nkeys", cacheInP->cc_nkeys);
@@ -612,10 +617,11 @@ ResetSystemCache()
 void
 SystemCacheRelationFlushed(Oid relId)
 {
+
 	/*
-	 * XXX Ideally we'd search the caches and just zap entries that actually
-	 * refer to or come from the indicated relation.  For now, we take the
-	 * brute-force approach: just flush the caches entirely.
+	 * XXX Ideally we'd search the caches and just zap entries that
+	 * actually refer to or come from the indicated relation.  For now, we
+	 * take the brute-force approach: just flush the caches entirely.
 	 */
 	ResetSystemCache();
 }
@@ -688,6 +694,7 @@ InitSysCache(char *relname,
 	 * ----------------
 	 */
 	{
+
 		/*
 		 * We can only do this optimization because the number of hash
 		 * buckets never changes.  Without it, we call palloc() too much.
@@ -782,8 +789,8 @@ InitSysCache(char *relname,
  *
  *		This call searches for self-referencing information,
  *		which causes infinite recursion in the system catalog cache.
- *      This code short-circuits the normal index lookup for cache loads
- *      in those cases and replaces it with a heap scan.
+ *		This code short-circuits the normal index lookup for cache loads
+ *		in those cases and replaces it with a heap scan.
  *
  *		cache should already be initailized
  * --------------------------------
@@ -791,40 +798,41 @@ InitSysCache(char *relname,
 static HeapTuple
 SearchSelfReferences(struct catcache * cache)
 {
-	HeapTuple		ntp;
-	Relation		rel;
+	HeapTuple	ntp;
+	Relation	rel;
 
 	if (cache->id == INDEXRELID)
 	{
-		static Oid			indexSelfOid = InvalidOid;
-		static HeapTuple	indexSelfTuple = NULL;
+		static Oid	indexSelfOid = InvalidOid;
+		static HeapTuple indexSelfTuple = NULL;
 
 		if (!OidIsValid(indexSelfOid))
 		{
-			ScanKeyData	key;
-			HeapScanDesc	sd;
+			ScanKeyData key;
+			HeapScanDesc sd;
+
 			/* Find oid of pg_index_indexrelid_index */
 			rel = heap_openr(RelationRelationName, AccessShareLock);
 			ScanKeyEntryInitialize(&key, 0, Anum_pg_class_relname,
-					F_NAMEEQ, PointerGetDatum(IndexRelidIndex));
+							 F_NAMEEQ, PointerGetDatum(IndexRelidIndex));
 			sd = heap_beginscan(rel, false, SnapshotNow, 1, &key);
 			ntp = heap_getnext(sd, 0);
 			if (!HeapTupleIsValid(ntp))
 				elog(ERROR, "SearchSelfReferences: %s not found in %s",
-					IndexRelidIndex, RelationRelationName);
+					 IndexRelidIndex, RelationRelationName);
 			indexSelfOid = ntp->t_data->t_oid;
 			heap_endscan(sd);
 			heap_close(rel, AccessShareLock);
 		}
 		/* Looking for something other than pg_index_indexrelid_index? */
-		if ((Oid)cache->cc_skey[0].sk_argument != indexSelfOid)
-			return (HeapTuple)0;
+		if ((Oid) cache->cc_skey[0].sk_argument != indexSelfOid)
+			return (HeapTuple) 0;
 
 		/* Do we need to load our private copy of the tuple? */
 		if (!HeapTupleIsValid(indexSelfTuple))
 		{
-			HeapScanDesc	sd;
-			MemoryContext	oldcxt;
+			HeapScanDesc sd;
+			MemoryContext oldcxt;
 
 			if (!CacheCxt)
 				CacheCxt = CreateGlobalMemory("Cache");
@@ -844,16 +852,16 @@ SearchSelfReferences(struct catcache * cache)
 	else if (cache->id == OPEROID)
 	{
 		/* bootstrapping this requires preloading a range of rows. bjm */
-		static HeapTuple	operatorSelfTuple[MAX_OIDCMP-MIN_OIDCMP+1];
-		Oid					lookup_oid = (Oid)cache->cc_skey[0].sk_argument;
+		static HeapTuple operatorSelfTuple[MAX_OIDCMP - MIN_OIDCMP + 1];
+		Oid			lookup_oid = (Oid) cache->cc_skey[0].sk_argument;
 
 		if (lookup_oid < MIN_OIDCMP || lookup_oid > MAX_OIDCMP)
-			return (HeapTuple)0;
+			return (HeapTuple) 0;
 
-		if (!HeapTupleIsValid(operatorSelfTuple[lookup_oid-MIN_OIDCMP]))
+		if (!HeapTupleIsValid(operatorSelfTuple[lookup_oid - MIN_OIDCMP]))
 		{
-			HeapScanDesc	sd;
-			MemoryContext	oldcxt;
+			HeapScanDesc sd;
+			MemoryContext oldcxt;
 
 			if (!CacheCxt)
 				CacheCxt = CreateGlobalMemory("Cache");
@@ -863,15 +871,15 @@ SearchSelfReferences(struct catcache * cache)
 			if (!HeapTupleIsValid(ntp))
 				elog(ERROR, "SearchSelfReferences: tuple not found");
 			oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt);
-			operatorSelfTuple[lookup_oid-MIN_OIDCMP] = heap_copytuple(ntp);
+			operatorSelfTuple[lookup_oid - MIN_OIDCMP] = heap_copytuple(ntp);
 			MemoryContextSwitchTo(oldcxt);
 			heap_endscan(sd);
 			heap_close(rel, AccessShareLock);
 		}
-		return operatorSelfTuple[lookup_oid-MIN_OIDCMP];
+		return operatorSelfTuple[lookup_oid - MIN_OIDCMP];
 	}
 	else
-		return (HeapTuple)0;
+		return (HeapTuple) 0;
 
 }
 
@@ -916,7 +924,7 @@ SearchSysCache(struct catcache * cache,
 	cache->cc_skey[3].sk_argument = v4;
 
 	/*
-	 *	resolve self referencing informtion
+	 * resolve self referencing informtion
 	 */
 	if ((ntp = SearchSelfReferences(cache)))
 		return ntp;
@@ -1052,12 +1060,13 @@ SearchSysCache(struct catcache * cache,
 		}
 		/* ----------
 		 *	Back to Cache context. If we got a tuple copy it
-		 *	into our context.   wieck - 10/18/1996
+		 *	into our context.	wieck - 10/18/1996
 		 *	And free the tuple that was allocated in the
 		 *	transaction's context.   tgl - 02/03/2000
 		 * ----------
 		 */
-		if (HeapTupleIsValid(indextp)) {
+		if (HeapTupleIsValid(indextp))
+		{
 			MemoryContextSwitchTo((MemoryContext) CacheCxt);
 			ntp = heap_copytuple(indextp);
 			MemoryContextSwitchTo(oldcxt);
diff --git a/src/backend/utils/cache/fcache.c b/src/backend/utils/cache/fcache.c
index 6660dc0ac4061ef272adb745ee34d6303f604101..26f4cbd8d06d1124010355e84333e3b31715ab00 100644
--- a/src/backend/utils/cache/fcache.c
+++ b/src/backend/utils/cache/fcache.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.29 2000/01/26 05:57:17 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.30 2000/04/12 17:15:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -126,6 +126,7 @@ init_fcache(Oid foid,
 	}
 	else
 	{
+
 		/*
 		 * This is a hack.	We assume here that any function returning a
 		 * relation returns it by reference.  This needs to be fixed.
@@ -137,7 +138,7 @@ init_fcache(Oid foid,
 	retval->func_state = (char *) NULL;
 	retval->setArg = NULL;
 	retval->hasSetArg = false;
-	retval->oneResult = ! procedureStruct->proretset;
+	retval->oneResult = !procedureStruct->proretset;
 	retval->istrusted = procedureStruct->proistrusted;
 
 	/*
@@ -148,7 +149,7 @@ init_fcache(Oid foid,
 	 */
 	if ((retval->language == SQLlanguageId) &&
 		retval->oneResult &&
-		! retval->typbyval)
+		!retval->typbyval)
 	{
 		Form_pg_class relationStruct;
 		HeapTuple	relationTuple;
diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c
index 17071f8e2352849c3da6a0a9557888f4121589e9..7094ed86f386b984bfd1d918732b6fc18535cbc6 100644
--- a/src/backend/utils/cache/inval.c
+++ b/src/backend/utils/cache/inval.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.34 2000/01/31 04:35:52 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.35 2000/04/12 17:15:53 momjian Exp $
  *
  * Note - this code is real crufty...
  *
@@ -95,11 +95,13 @@ typedef InvalidationMessageData *InvalidationMessage;
  * eaten by AtCommit_Cache() in CommitTransaction()
  */
 static LocalInvalid InvalidForall = EmptyLocalInvalid;
+
 /*
  * head of invalidation linked list for the backend itself
  * eaten by AtCommit_LocalCache() in CommandCounterIncrement()
  */
 static LocalInvalid InvalidLocal = EmptyLocalInvalid;
+
 /*
  * head of rollback linked list for the backend itself
  * eaten by AtAbort_Cache() in AbortTransaction()
@@ -110,7 +112,7 @@ static LocalInvalid RollbackStack = EmptyLocalInvalid;
 static InvalidationEntry InvalidationEntryAllocate(uint16 size);
 static void LocalInvalidInvalidate(LocalInvalid invalid, void (*function) (), bool freemember);
 static LocalInvalid LocalInvalidRegister(LocalInvalid invalid,
-										 InvalidationEntry entry);
+					 InvalidationEntry entry);
 static void DiscardInvalidStack(LocalInvalid *invalid);
 static void InvalidationMessageRegisterSharedInvalid(InvalidationMessage message);
 
@@ -161,7 +163,7 @@ LocalInvalidRegister(LocalInvalid invalid,
  * --------------------------------
  */
 static void
-LocalInvalidInvalidate(LocalInvalid invalid, void (*function) (), bool freemember)
+			LocalInvalidInvalidate(LocalInvalid invalid, void (*function) (), bool freemember)
 {
 	InvalidationEntryData *entryDataP;
 
@@ -187,12 +189,12 @@ LocalInvalidInvalidate(LocalInvalid invalid, void (*function) (), bool freemembe
 static void
 DiscardInvalidStack(LocalInvalid *invalid)
 {
-	LocalInvalid	locinv;
+	LocalInvalid locinv;
 
 	locinv = *invalid;
 	*invalid = EmptyLocalInvalid;
 	if (locinv)
-		LocalInvalidInvalidate(locinv, (void (*)()) NULL, true);
+		LocalInvalidInvalidate(locinv, (void (*) ()) NULL, true);
 }
 
 /* ----------------------------------------------------------------
@@ -234,7 +236,7 @@ elog(DEBUG, "CacheIdImmediateRegisterSharedInvalid(%d, %d, [%d, %d])", \
  */
 static LocalInvalid
 CacheIdRegisterSpecifiedLocalInvalid(LocalInvalid invalid,
-		Index cacheId, Index hashIndex, ItemPointer pointer)
+					 Index cacheId, Index hashIndex, ItemPointer pointer)
 {
 	InvalidationMessage message;
 
@@ -286,13 +288,13 @@ CacheIdRegisterLocalInvalid(Index cacheId,
 	 * ----------------
 	 */
 	InvalidForall = CacheIdRegisterSpecifiedLocalInvalid(InvalidForall,
-				cacheId, hashIndex, pointer);
+											cacheId, hashIndex, pointer);
 	/* ----------------
 	 *	Add message to InvalidLocal linked list.
 	 * ----------------
 	 */
 	InvalidLocal = CacheIdRegisterSpecifiedLocalInvalid(InvalidLocal,
-				cacheId, hashIndex, pointer);
+											cacheId, hashIndex, pointer);
 }
 
 /* --------------------------------
@@ -301,7 +303,7 @@ CacheIdRegisterLocalInvalid(Index cacheId,
  */
 static void
 CacheIdRegisterLocalRollback(Index cacheId, Index hashIndex,
-					ItemPointer pointer)
+							 ItemPointer pointer)
 {
 
 	/* ----------------
@@ -315,7 +317,7 @@ CacheIdRegisterLocalRollback(Index cacheId, Index hashIndex,
 	 * ----------------
 	 */
 	RollbackStack = CacheIdRegisterSpecifiedLocalInvalid(
-		RollbackStack, cacheId, hashIndex, pointer);
+							 RollbackStack, cacheId, hashIndex, pointer);
 }
 
 /* --------------------------------
@@ -324,7 +326,7 @@ CacheIdRegisterLocalRollback(Index cacheId, Index hashIndex,
  */
 static void
 CacheIdImmediateRegisterSharedInvalid(Index cacheId, Index hashIndex,
-					ItemPointer pointer)
+									  ItemPointer pointer)
 {
 	InvalidationMessage message;
 
@@ -361,7 +363,7 @@ CacheIdImmediateRegisterSharedInvalid(Index cacheId, Index hashIndex,
  */
 static LocalInvalid
 RelationIdRegisterSpecifiedLocalInvalid(LocalInvalid invalid,
-			Oid relationId, Oid objectId)
+										Oid relationId, Oid objectId)
 {
 	InvalidationMessage message;
 
@@ -415,13 +417,13 @@ RelationIdRegisterLocalInvalid(Oid relationId, Oid objectId)
 	 * ----------------
 	 */
 	InvalidForall = RelationIdRegisterSpecifiedLocalInvalid(InvalidForall,
-		 		relationId, objectId);
+												   relationId, objectId);
 	/* ----------------
 	 *	Add message to InvalidLocal linked list.
 	 * ----------------
 	 */
 	InvalidLocal = RelationIdRegisterSpecifiedLocalInvalid(InvalidLocal,
-		 		relationId, objectId);
+												   relationId, objectId);
 }
 
 /* --------------------------------
@@ -446,7 +448,7 @@ RelationIdRegisterLocalRollback(Oid relationId, Oid objectId)
 	 * ----------------
 	 */
 	RollbackStack = RelationIdRegisterSpecifiedLocalInvalid(
-			RollbackStack, relationId, objectId);
+									RollbackStack, relationId, objectId);
 }
 
 /* --------------------------------
@@ -643,16 +645,16 @@ InvalidationMessageCacheInvalidate(InvalidationMessage message)
 			InvalidationMessageCacheInvalidate_DEBUG1;
 
 			CacheIdInvalidate(message->any.catalog.cacheId,
-									 message->any.catalog.hashIndex,
-									 &message->any.catalog.pointerData);
+							  message->any.catalog.hashIndex,
+							  &message->any.catalog.pointerData);
 			break;
 
 		case 'r':				/* cached relation descriptor */
 			InvalidationMessageCacheInvalidate_DEBUG2;
 
 			CacheIdInvalidate(message->any.relation.relationId,
-						message->any.relation.objectId,
-						(ItemPointer) NULL);
+							  message->any.relation.objectId,
+							  (ItemPointer) NULL);
 			break;
 
 		default:
@@ -753,14 +755,14 @@ RegisterInvalid(bool send)
 	{
 		DiscardInvalidStack(&RollbackStack);
 		invalid = InvalidForall;
-		InvalidForall = EmptyLocalInvalid; /* clear InvalidForall */
+		InvalidForall = EmptyLocalInvalid;		/* clear InvalidForall */
 		LocalInvalidInvalidate(invalid, InvalidationMessageRegisterSharedInvalid, true);
 	}
 	else
 	{
 		DiscardInvalidStack(&InvalidForall);
 		invalid = RollbackStack;
-		RollbackStack = EmptyLocalInvalid; /* clear RollbackStack */
+		RollbackStack = EmptyLocalInvalid;		/* clear RollbackStack */
 		LocalInvalidInvalidate(invalid, InvalidationMessageCacheInvalidate, true);
 	}
 
@@ -794,14 +796,15 @@ ImmediateLocalInvalidation(bool send)
 	if (send)
 	{
 		invalid = InvalidLocal;
-		InvalidLocal = EmptyLocalInvalid; /* clear InvalidLocal */
+		InvalidLocal = EmptyLocalInvalid;		/* clear InvalidLocal */
 		LocalInvalidInvalidate(invalid, InvalidationMessageCacheInvalidate, true);
 	}
 	else
 	{
+
 		/*
-		 * This may be used for rollback to a savepoint.
-		 * Don't clear InvalidForall and RollbackStack here.
+		 * This may be used for rollback to a savepoint. Don't clear
+		 * InvalidForall and RollbackStack here.
 		 */
 		DiscardInvalidStack(&InvalidLocal);
 		invalid = RollbackStack;
@@ -813,8 +816,8 @@ ImmediateLocalInvalidation(bool send)
 /*
  * InvokeHeapTupleInvalidation
  *		Invoke functions for the tuple which register invalidation
- *		of catalog/relation cache.  
- *  Note:
+ *		of catalog/relation cache.
+ *	Note:
  *		Assumes object id is valid.
  *		Assumes tuple is valid.
  */
@@ -831,9 +834,9 @@ elog(DEBUG, "%s(%s, [%d,%d])", \
 
 static void
 InvokeHeapTupleInvalidation(Relation relation, HeapTuple tuple,
-		void (*CacheIdRegisterFunc)(),
-		void (*RelationIdRegisterFunc)(),
-		const char *funcname)
+							void (*CacheIdRegisterFunc) (),
+							void (*RelationIdRegisterFunc) (),
+							const char *funcname)
 {
 	/* ----------------
 	 *	sanity checks
@@ -857,13 +860,13 @@ InvokeHeapTupleInvalidation(Relation relation, HeapTuple tuple,
 	 */
 	InvokeHeapTupleInvalidation_DEBUG1;
 
-	RelationInvalidateCatalogCacheTuple(relation, tuple, 
-		CacheIdRegisterFunc);
+	RelationInvalidateCatalogCacheTuple(relation, tuple,
+										CacheIdRegisterFunc);
 
 	RelationInvalidateRelationCache(relation, tuple,
-		RelationIdRegisterFunc);
+									RelationIdRegisterFunc);
 }
- 
+
 /*
  * RelationInvalidateHeapTuple
  *		Causes the given tuple in a relation to be invalidated.
@@ -871,10 +874,10 @@ InvokeHeapTupleInvalidation(Relation relation, HeapTuple tuple,
 void
 RelationInvalidateHeapTuple(Relation relation, HeapTuple tuple)
 {
-	InvokeHeapTupleInvalidation(relation, tuple, 
-		CacheIdRegisterLocalInvalid,
-		RelationIdRegisterLocalInvalid,
-		"RelationInvalidateHeapTuple");
+	InvokeHeapTupleInvalidation(relation, tuple,
+								CacheIdRegisterLocalInvalid,
+								RelationIdRegisterLocalInvalid,
+								"RelationInvalidateHeapTuple");
 }
 
 /*
@@ -886,9 +889,9 @@ void
 RelationMark4RollbackHeapTuple(Relation relation, HeapTuple tuple)
 {
 	InvokeHeapTupleInvalidation(relation, tuple,
-		CacheIdRegisterLocalRollback,
-		RelationIdRegisterLocalRollback,
-		"RelationMark4RollbackHeapTuple");
+								CacheIdRegisterLocalRollback,
+								RelationIdRegisterLocalRollback,
+								"RelationMark4RollbackHeapTuple");
 }
 
 /*
@@ -900,9 +903,9 @@ void
 ImmediateInvalidateSharedHeapTuple(Relation relation, HeapTuple tuple)
 {
 	InvokeHeapTupleInvalidation(relation, tuple,
-		CacheIdImmediateRegisterSharedInvalid,
-		RelationIdImmediateRegisterSharedInvalid,
-		"ImmediateInvalidateSharedHeapTuple");
+								CacheIdImmediateRegisterSharedInvalid,
+								RelationIdImmediateRegisterSharedInvalid,
+								"ImmediateInvalidateSharedHeapTuple");
 }
 
 /*
@@ -912,8 +915,8 @@ ImmediateInvalidateSharedHeapTuple(Relation relation, HeapTuple tuple)
  *	This is needed for smgrunlink()/smgrtruncate().
  *	Those functions unlink/truncate the base file immediately
  *	and couldn't be rollbacked in case of abort/crash.
- *	So relation cache invalidation must be registerd immediately. 
- *  Note:
+ *	So relation cache invalidation must be registerd immediately.
+ *	Note:
  *		Assumes Relation is valid.
  */
 void
@@ -933,10 +936,10 @@ ImmediateSharedRelationCacheInvalidate(Relation relation)
 	 * ----------------
 	 */
 #ifdef	INVALIDDEBUG
-elog(DEBUG, "ImmediateSharedRelationCacheInvalidate(%s)", \
-	 RelationGetPhysicalRelationName(relation));
+	elog(DEBUG, "ImmediateSharedRelationCacheInvalidate(%s)", \
+		 RelationGetPhysicalRelationName(relation));
 #endif	 /* defined(INVALIDDEBUG) */
 
 	RelationIdImmediateRegisterSharedInvalid(
-		RelOid_pg_class, RelationGetRelid(relation));
+							RelOid_pg_class, RelationGetRelid(relation));
 }
diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c
index 688740e32da4d605737d881cb1e6b09db5e70920..d91f47b7ca2c0c01e2d8a628dcdd9beeb75b592d 100644
--- a/src/backend/utils/cache/lsyscache.c
+++ b/src/backend/utils/cache/lsyscache.c
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.40 2000/02/16 01:00:23 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.41 2000/04/12 17:15:53 momjian Exp $
  *
  * NOTES
  *	  Eventually, the index information should go through here, too.
@@ -64,6 +64,7 @@ get_attname(Oid relid, AttrNumber attnum)
 	if (HeapTupleIsValid(tp))
 	{
 		Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+
 		return pstrdup(NameStr(att_tup->attname));
 	}
 	else
@@ -89,6 +90,7 @@ get_attnum(Oid relid, char *attname)
 	if (HeapTupleIsValid(tp))
 	{
 		Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+
 		return att_tup->attnum;
 	}
 	else
@@ -114,6 +116,7 @@ get_atttype(Oid relid, AttrNumber attnum)
 	if (HeapTupleIsValid(tp))
 	{
 		Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+
 		return att_tup->atttypid;
 	}
 	else
@@ -136,6 +139,7 @@ get_attisset(Oid relid, char *attname)
 	if (HeapTupleIsValid(tp))
 	{
 		Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+
 		return att_tup->attisset;
 	}
 	else
@@ -161,6 +165,7 @@ get_atttypmod(Oid relid, AttrNumber attnum)
 	if (HeapTupleIsValid(tp))
 	{
 		Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
+
 		return att_tup->atttypmod;
 	}
 	else
@@ -206,8 +211,8 @@ get_attdisbursion(Oid relid, AttrNumber attnum, double min_estimate)
 
 	/*
 	 * Special-case boolean columns: the disbursion of a boolean is highly
-	 * unlikely to be anywhere near 1/numtuples, instead it's probably more
-	 * like 0.5.
+	 * unlikely to be anywhere near 1/numtuples, instead it's probably
+	 * more like 0.5.
 	 *
 	 * Are there any other cases we should wire in special estimates for?
 	 */
@@ -215,8 +220,8 @@ get_attdisbursion(Oid relid, AttrNumber attnum, double min_estimate)
 		return 0.5;
 
 	/*
-	 * Disbursion is either 0 (no data available) or -1 (disbursion
-	 * is 1/numtuples).  Either way, we need the relation size.
+	 * Disbursion is either 0 (no data available) or -1 (disbursion is
+	 * 1/numtuples).  Either way, we need the relation size.
 	 */
 
 	atp = SearchSysCacheTuple(RELOID,
@@ -246,10 +251,9 @@ get_attdisbursion(Oid relid, AttrNumber attnum, double min_estimate)
 		return 1.0 / (double) ntuples;
 
 	/*
-	 * VACUUM ANALYZE has not been run for this table.
-	 * Produce an estimate = 1/numtuples.  This may produce
-	 * unreasonably small estimates for large tables, so limit
-	 * the estimate to no less than min_estimate.
+	 * VACUUM ANALYZE has not been run for this table. Produce an estimate
+	 * = 1/numtuples.  This may produce unreasonably small estimates for
+	 * large tables, so limit the estimate to no less than min_estimate.
 	 */
 	disbursion = 1.0 / (double) ntuples;
 	if (disbursion < min_estimate)
@@ -283,6 +287,7 @@ get_opcode(Oid opno)
 	if (HeapTupleIsValid(tp))
 	{
 		Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+
 		return optup->oprcode;
 	}
 	else
@@ -306,6 +311,7 @@ get_opname(Oid opno)
 	if (HeapTupleIsValid(tp))
 	{
 		Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+
 		return pstrdup(NameStr(optup->oprname));
 	}
 	else
@@ -401,6 +407,7 @@ get_commutator(Oid opno)
 	if (HeapTupleIsValid(tp))
 	{
 		Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+
 		return optup->oprcom;
 	}
 	else
@@ -424,6 +431,7 @@ get_negator(Oid opno)
 	if (HeapTupleIsValid(tp))
 	{
 		Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+
 		return optup->oprnegate;
 	}
 	else
@@ -447,6 +455,7 @@ get_oprrest(Oid opno)
 	if (HeapTupleIsValid(tp))
 	{
 		Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+
 		return optup->oprrest;
 	}
 	else
@@ -470,6 +479,7 @@ get_oprjoin(Oid opno)
 	if (HeapTupleIsValid(tp))
 	{
 		Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
+
 		return optup->oprjoin;
 	}
 	else
@@ -520,6 +530,7 @@ get_relnatts(Oid relid)
 	if (HeapTupleIsValid(tp))
 	{
 		Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+
 		return reltup->relnatts;
 	}
 	else
@@ -543,6 +554,7 @@ get_rel_name(Oid relid)
 	if (HeapTupleIsValid(tp))
 	{
 		Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
+
 		return pstrdup(NameStr(reltup->relname));
 	}
 	else
@@ -568,6 +580,7 @@ get_typlen(Oid typid)
 	if (HeapTupleIsValid(tp))
 	{
 		Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+
 		return typtup->typlen;
 	}
 	else
@@ -592,6 +605,7 @@ get_typbyval(Oid typid)
 	if (HeapTupleIsValid(tp))
 	{
 		Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+
 		return (bool) typtup->typbyval;
 	}
 	else
@@ -610,6 +624,7 @@ get_typalign(Oid typid)
 	if (HeapTupleIsValid(tp))
 	{
 		Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+
 		return typtup->typalign;
 	}
 	else
@@ -649,11 +664,12 @@ get_typdefault(Oid typid)
 	type = (Form_pg_type) GETSTRUCT(typeTuple);
 
 	/*
-	 * First, see if there is a non-null typdefault field (usually there isn't)
+	 * First, see if there is a non-null typdefault field (usually there
+	 * isn't)
 	 */
 	typDefault = (struct varlena *) SysCacheGetAttr(TYPEOID,
 													typeTuple,
-													Anum_pg_type_typdefault,
+												 Anum_pg_type_typdefault,
 													&isNull);
 
 	if (isNull)
@@ -743,6 +759,7 @@ get_typtype(Oid typid)
 	if (HeapTupleIsValid(tp))
 	{
 		Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
+
 		return typtup->typtype;
 	}
 	else
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 97ec7d300d1fdbde1decf3229ee89090aeb3463e..41fcdf1d2734b48766afe5fbb08f4a924245889f 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.94 2000/03/31 19:39:22 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.95 2000/04/12 17:15:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -80,8 +80,8 @@ static FormData_pg_attribute Desc_pg_log[Natts_pg_log] = {Schema_pg_log};
  *		thus there are two hash tables for referencing them.
  * ----------------
  */
-static HTAB	   *RelationNameCache;
-static HTAB	   *RelationIdCache;
+static HTAB *RelationNameCache;
+static HTAB *RelationIdCache;
 
 /*
  * newlyCreatedRelns -
@@ -204,20 +204,20 @@ do { \
 
 static void RelationClearRelation(Relation relation, bool rebuildIt);
 static void RelationFlushRelation(Relation *relationPtr,
-								  int skipLocalRelations);
+					  int skipLocalRelations);
 static Relation RelationNameCacheGetRelation(const char *relationName);
 static void RelationCacheAbortWalker(Relation *relationPtr, int dummy);
 static void init_irels(void);
 static void write_irels(void);
 
 static void formrdesc(char *relationName, u_int natts,
-					  FormData_pg_attribute *att);
+		  FormData_pg_attribute *att);
 
 static HeapTuple ScanPgRelation(RelationBuildDescInfo buildinfo);
 static HeapTuple scan_pg_rel_seq(RelationBuildDescInfo buildinfo);
 static HeapTuple scan_pg_rel_ind(RelationBuildDescInfo buildinfo);
 static Relation AllocateRelationDesc(Relation relation, u_int natts,
-									 Form_pg_class relp);
+					 Form_pg_class relp);
 static void RelationBuildTupleDesc(RelationBuildDescInfo buildinfo,
 					   Relation relation, u_int natts);
 static void build_tupdesc_seq(RelationBuildDescInfo buildinfo,
@@ -225,12 +225,13 @@ static void build_tupdesc_seq(RelationBuildDescInfo buildinfo,
 static void build_tupdesc_ind(RelationBuildDescInfo buildinfo,
 				  Relation relation, u_int natts);
 static Relation RelationBuildDesc(RelationBuildDescInfo buildinfo,
-								  Relation oldrelation);
+				  Relation oldrelation);
 static void IndexedAccessMethodInitialize(Relation relation);
 static void AttrDefaultFetch(Relation relation);
 static void RelCheckFetch(Relation relation);
 
-static bool	criticalRelcacheBuild = false;
+static bool criticalRelcacheBuild = false;
+
 /* ----------------------------------------------------------------
  *		RelationIdGetRelation() and RelationNameGetRelation()
  *						support functions
@@ -350,7 +351,7 @@ scan_pg_rel_ind(RelationBuildDescInfo buildinfo)
 
 		default:
 			elog(ERROR, "ScanPgRelation: bad buildinfo");
-			return_tuple = NULL; /* keep compiler quiet */
+			return_tuple = NULL;/* keep compiler quiet */
 	}
 
 	heap_close(pg_class_desc, AccessShareLock);
@@ -483,7 +484,7 @@ build_tupdesc_seq(RelationBuildDescInfo buildinfo,
 	int			need;
 	TupleConstr *constr = (TupleConstr *) palloc(sizeof(TupleConstr));
 	AttrDefault *attrdef = NULL;
-	int		ndef = 0;
+	int			ndef = 0;
 
 	constr->has_not_null = false;
 	/* ----------------
@@ -531,7 +532,7 @@ build_tupdesc_seq(RelationBuildDescInfo buildinfo,
 				if (attrdef == NULL)
 				{
 					attrdef = (AttrDefault *) palloc(relation->rd_rel->relnatts *
-												 	sizeof(AttrDefault));
+													 sizeof(AttrDefault));
 					MemSet(attrdef, 0,
 					   relation->rd_rel->relnatts * sizeof(AttrDefault));
 				}
@@ -569,9 +570,11 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo,
 	AttrDefault *attrdef = NULL;
 	int			ndef = 0;
 	int			i;
+
 #ifdef	_DROP_COLUMN_HACK__
-	bool			columnDropped;
-#endif	/* _DROP_COLUMN_HACK__ */
+	bool		columnDropped;
+
+#endif	 /* _DROP_COLUMN_HACK__ */
 
 	constr->has_not_null = false;
 
@@ -581,7 +584,7 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo,
 	{
 #ifdef	_DROP_COLUMN_HACK__
 		columnDropped = false;
-#endif	/* _DROP_COLUMN_HACK__ */
+#endif	 /* _DROP_COLUMN_HACK__ */
 		atttup = (HeapTuple) AttributeRelidNumIndexScan(attrel,
 										  RelationGetRelid(relation), i);
 
@@ -589,15 +592,15 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo,
 #ifdef	_DROP_COLUMN_HACK__
 		{
 			atttup = (HeapTuple) AttributeRelidNumIndexScan(attrel,
-										  			RelationGetRelid(relation), DROPPED_COLUMN_INDEX(i));
+					RelationGetRelid(relation), DROPPED_COLUMN_INDEX(i));
 			if (!HeapTupleIsValid(atttup))
-#endif	/* _DROP_COLUMN_HACK__ */
-			elog(ERROR, "cannot find attribute %d of relation %s", i,
-				 RelationGetRelationName(relation));
+#endif	 /* _DROP_COLUMN_HACK__ */
+				elog(ERROR, "cannot find attribute %d of relation %s", i,
+					 RelationGetRelationName(relation));
 #ifdef	_DROP_COLUMN_HACK__
 			columnDropped = true;
 		}
-#endif	/* _DROP_COLUMN_HACK__ */
+#endif	 /* _DROP_COLUMN_HACK__ */
 		attp = (Form_pg_attribute) GETSTRUCT(atttup);
 
 		relation->rd_att->attrs[i - 1] =
@@ -610,7 +613,7 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo,
 #ifdef	_DROP_COLUMN_HACK__
 		if (columnDropped)
 			continue;
-#endif	/* _DROP_COLUMN_HACK__ */
+#endif	 /* _DROP_COLUMN_HACK__ */
 		/* Update if this attribute have a constraint */
 		if (attp->attnotnull)
 			constr->has_not_null = true;
@@ -758,7 +761,7 @@ RelationBuildRuleLock(Relation relation)
 static void
 FreeRuleLock(RuleLock *rlock)
 {
-	int		i;
+	int			i;
 
 	if (rlock == NULL)
 		return;
@@ -787,8 +790,8 @@ FreeRuleLock(RuleLock *rlock)
 static bool
 equalRuleLocks(RuleLock *rlock1, RuleLock *rlock2)
 {
-	int		i,
-			j;
+	int			i,
+				j;
 
 	if (rlock1 != NULL)
 	{
@@ -821,9 +824,9 @@ equalRuleLocks(RuleLock *rlock1, RuleLock *rlock2)
 				return false;
 			if (rule1->isInstead != rule2->isInstead)
 				return false;
-			if (! equal(rule1->qual, rule2->qual))
+			if (!equal(rule1->qual, rule2->qual))
 				return false;
-			if (! equal(rule1->actions, rule2->actions))
+			if (!equal(rule1->actions, rule2->actions))
 				return false;
 		}
 	}
@@ -852,7 +855,7 @@ equalRuleLocks(RuleLock *rlock1, RuleLock *rlock2)
  *	Form_pg_am			   rd_am;		 AM tuple
  *	Form_pg_class		   rd_rel;		 RELATION tuple
  *	Oid					   rd_id;		 relation's object id
- *	LockInfoData		   rd_lockInfo;	 lock manager's info
+ *	LockInfoData		   rd_lockInfo;  lock manager's info
  *	TupleDesc			   rd_att;		 tuple descriptor
  *
  *		Note: rd_ismem (rel is in-memory only) is currently unused
@@ -1309,7 +1312,7 @@ RelationNameGetRelation(const char *relationName)
 	 * ----------------
 	 */
 	buildinfo.infotype = INFO_RELNAME;
-	buildinfo.i.info_name = (char *)relationName;
+	buildinfo.i.info_name = (char *) relationName;
 
 	rd = RelationBuildDesc(buildinfo, NULL);
 	return rd;
@@ -1352,11 +1355,11 @@ RelationClearRelation(Relation relation, bool rebuildIt)
 	MemoryContext oldcxt;
 
 	/*
-	 * Make sure smgr and lower levels close the relation's files,
-	 * if they weren't closed already.  We do this unconditionally;
-	 * if the relation is not deleted, the next smgr access should
-	 * reopen the files automatically.  This ensures that the low-level
-	 * file access state is updated after, say, a vacuum truncation.
+	 * Make sure smgr and lower levels close the relation's files, if they
+	 * weren't closed already.  We do this unconditionally; if the
+	 * relation is not deleted, the next smgr access should reopen the
+	 * files automatically.  This ensures that the low-level file access
+	 * state is updated after, say, a vacuum truncation.
 	 *
 	 * NOTE: this call is a no-op if the relation's smgr file is already
 	 * closed or unlinked.
@@ -1364,15 +1367,16 @@ RelationClearRelation(Relation relation, bool rebuildIt)
 	smgrclose(DEFAULT_SMGR, relation);
 
 	/*
-	 * Never, never ever blow away a nailed-in system relation,
-	 * because we'd be unable to recover.
+	 * Never, never ever blow away a nailed-in system relation, because
+	 * we'd be unable to recover.
 	 */
 	if (relation->rd_isnailed)
 		return;
 
 	oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt);
 
-	/* Remove relation from hash tables
+	/*
+	 * Remove relation from hash tables
 	 *
 	 * Note: we might be reinserting it momentarily, but we must not have it
 	 * visible in the hash tables until it's valid again, so don't try to
@@ -1384,12 +1388,12 @@ RelationClearRelation(Relation relation, bool rebuildIt)
 	SystemCacheRelationFlushed(RelationGetRelid(relation));
 
 	/*
-	 * Free all the subsidiary data structures of the relcache entry.
-	 * We cannot free rd_att if we are trying to rebuild the entry,
-	 * however, because pointers to it may be cached in various places.
-	 * The trigger manager might also have pointers into the trigdesc,
-	 * and the rule manager might have pointers into the rewrite rules.
-	 * So to begin with, we can only get rid of these fields:
+	 * Free all the subsidiary data structures of the relcache entry. We
+	 * cannot free rd_att if we are trying to rebuild the entry, however,
+	 * because pointers to it may be cached in various places. The trigger
+	 * manager might also have pointers into the trigdesc, and the rule
+	 * manager might have pointers into the rewrite rules. So to begin
+	 * with, we can only get rid of these fields:
 	 */
 	if (relation->rd_am)
 		pfree(relation->rd_am);
@@ -1401,12 +1405,12 @@ RelationClearRelation(Relation relation, bool rebuildIt)
 		pfree(relation->rd_support);
 
 	/*
-	 * If we're really done with the relcache entry, blow it away.
-	 * But if someone is still using it, reconstruct the whole deal
-	 * without moving the physical RelationData record (so that the
-	 * someone's pointer is still valid).
+	 * If we're really done with the relcache entry, blow it away. But if
+	 * someone is still using it, reconstruct the whole deal without
+	 * moving the physical RelationData record (so that the someone's
+	 * pointer is still valid).
 	 */
-	if (! rebuildIt)
+	if (!rebuildIt)
 	{
 		/* ok to zap remaining substructure */
 		FreeTupleDesc(relation->rd_att);
@@ -1416,20 +1420,21 @@ RelationClearRelation(Relation relation, bool rebuildIt)
 	}
 	else
 	{
+
 		/*
 		 * When rebuilding an open relcache entry, must preserve ref count
 		 * and myxactonly flag.  Also attempt to preserve the tupledesc,
-		 * rewrite rules, and trigger substructures in place.
-		 * Furthermore we save/restore rd_nblocks (in case it is a local
-		 * relation) *and* call RelationGetNumberOfBlocks (in case it isn't).
+		 * rewrite rules, and trigger substructures in place. Furthermore
+		 * we save/restore rd_nblocks (in case it is a local relation)
+		 * *and* call RelationGetNumberOfBlocks (in case it isn't).
 		 */
-		uint16			old_refcnt = relation->rd_refcnt;
-		bool			old_myxactonly = relation->rd_myxactonly;
-		TupleDesc		old_att = relation->rd_att;
-		RuleLock	   *old_rules = relation->rd_rules;
-		TriggerDesc	   *old_trigdesc = relation->trigdesc;
-		int				old_nblocks = relation->rd_nblocks;
-		bool			relDescChanged = false;
+		uint16		old_refcnt = relation->rd_refcnt;
+		bool		old_myxactonly = relation->rd_myxactonly;
+		TupleDesc	old_att = relation->rd_att;
+		RuleLock   *old_rules = relation->rd_rules;
+		TriggerDesc *old_trigdesc = relation->trigdesc;
+		int			old_nblocks = relation->rd_nblocks;
+		bool		relDescChanged = false;
 		RelationBuildDescInfo buildinfo;
 
 		buildinfo.infotype = INFO_RELID;
@@ -1478,12 +1483,14 @@ RelationClearRelation(Relation relation, bool rebuildIt)
 			relDescChanged = true;
 		}
 		relation->rd_nblocks = old_nblocks;
-		/* this is kind of expensive, but I think we must do it in case
+
+		/*
+		 * this is kind of expensive, but I think we must do it in case
 		 * relation has been truncated...
 		 */
 		relation->rd_nblocks = RelationGetNumberOfBlocks(relation);
 
-		if (relDescChanged && ! RelationHasReferenceCountZero(relation))
+		if (relDescChanged && !RelationHasReferenceCountZero(relation))
 			elog(ERROR, "RelationClearRelation: relation %u modified while in use",
 				 buildinfo.i.info_id);
 	}
@@ -1514,6 +1521,7 @@ RelationFlushRelation(Relation *relationPtr,
 	{
 		if (skipLocalRelations)
 			return;				/* don't touch local rels if so commanded */
+
 		/*
 		 * Local rels should always be rebuilt, not flushed; the relcache
 		 * entry must live until RelationPurgeLocalRelation().
@@ -1522,10 +1530,11 @@ RelationFlushRelation(Relation *relationPtr,
 	}
 	else
 	{
+
 		/*
 		 * Nonlocal rels can be dropped from the relcache if not open.
 		 */
-		rebuildIt = ! RelationHasReferenceCountZero(relation);
+		rebuildIt = !RelationHasReferenceCountZero(relation);
 	}
 
 	RelationClearRelation(relation, rebuildIt);
@@ -1633,6 +1642,7 @@ RelationFlushIndexes(Relation *r,
 void
 RelationIdInvalidateRelationCacheByAccessMethodId(Oid accessMethodId)
 {
+
 	/*
 	 * 25 aug 1992:  mao commented out the ht walk below.  it should be
 	 * doing the right thing, in theory, but flushing reldescs for index
@@ -1641,13 +1651,14 @@ RelationIdInvalidateRelationCacheByAccessMethodId(Oid accessMethodId)
 	 * so i'm turning it off for now.  after the release is cut, i'll fix
 	 * this up.
 	 *
-	 * 20 nov 1999:  this code has still never done anything, so I'm
-	 * cutting the routine out of the system entirely.  tgl
+	 * 20 nov 1999:  this code has still never done anything, so I'm cutting
+	 * the routine out of the system entirely.	tgl
 	 */
 
 	HashTableWalk(RelationNameCache, (HashtFunc) RelationFlushIndexes,
 				  accessMethodId);
 }
+
 #endif
 
 /*
@@ -1756,7 +1767,7 @@ RelationPurgeLocalRelation(bool xactCommitted)
 
 		Assert(reln != NULL && reln->rd_myxactonly);
 
-		reln->rd_myxactonly = false; /* mark it not on list anymore */
+		reln->rd_myxactonly = false;	/* mark it not on list anymore */
 
 		newlyCreatedRelns = lnext(newlyCreatedRelns);
 		pfree(l);
@@ -1862,8 +1873,8 @@ AttrDefaultFetch(Relation relation)
 	HeapTupleData tuple;
 	HeapTuple	htup;
 	Form_pg_attrdef adform;
-	IndexScanDesc	sd = (IndexScanDesc) NULL;
-	HeapScanDesc	adscan = (HeapScanDesc) NULL;
+	IndexScanDesc sd = (IndexScanDesc) NULL;
+	HeapScanDesc adscan = (HeapScanDesc) NULL;
 	RetrieveIndexResult indexRes;
 	struct varlena *val;
 	bool		isnull;
@@ -1885,7 +1896,7 @@ AttrDefaultFetch(Relation relation)
 		sd = index_beginscan(irel, false, 1, &skey);
 	}
 	else
-		adscan = heap_beginscan(adrel, false, SnapshotNow, 1, &skey); 
+		adscan = heap_beginscan(adrel, false, SnapshotNow, 1, &skey);
 	tuple.t_datamcxt = NULL;
 	tuple.t_data = NULL;
 
@@ -1920,7 +1931,7 @@ AttrDefaultFetch(Relation relation)
 				continue;
 			if (attrdef[i].adbin != NULL)
 				elog(NOTICE, "AttrDefaultFetch: second record found for attr %s in rel %s",
-				NameStr(relation->rd_att->attrs[adform->adnum - 1]->attname),
+					 NameStr(relation->rd_att->attrs[adform->adnum - 1]->attname),
 					 RelationGetRelationName(relation));
 
 			val = (struct varlena *) fastgetattr(htup,
@@ -1928,7 +1939,7 @@ AttrDefaultFetch(Relation relation)
 												 adrel->rd_att, &isnull);
 			if (isnull)
 				elog(NOTICE, "AttrDefaultFetch: adbin IS NULL for attr %s in rel %s",
-				NameStr(relation->rd_att->attrs[adform->adnum - 1]->attname),
+					 NameStr(relation->rd_att->attrs[adform->adnum - 1]->attname),
 					 RelationGetRelationName(relation));
 			attrdef[i].adbin = textout(val);
 			break;
@@ -1962,12 +1973,12 @@ RelCheckFetch(Relation relation)
 	ConstrCheck *check = relation->rd_att->constr->check;
 	int			ncheck = relation->rd_att->constr->num_check;
 	Relation	rcrel;
-	Relation	irel = (Relation)NULL;
+	Relation	irel = (Relation) NULL;
 	ScanKeyData skey;
 	HeapTupleData tuple;
 	HeapTuple	htup;
-	IndexScanDesc	sd = (IndexScanDesc)NULL;
-	HeapScanDesc	rcscan = (HeapScanDesc)NULL;
+	IndexScanDesc sd = (IndexScanDesc) NULL;
+	HeapScanDesc rcscan = (HeapScanDesc) NULL;
 	RetrieveIndexResult indexRes;
 	Name		rcname;
 	struct varlena *val;
@@ -2271,9 +2282,9 @@ write_irels(void)
 	char		finalfilename[MAXPGPATH];
 
 	/*
-	 * We must write a temporary file and rename it into place.  Otherwise,
-	 * another backend starting at about the same time might crash trying to
-	 * read the partially-complete file.
+	 * We must write a temporary file and rename it into place. Otherwise,
+	 * another backend starting at about the same time might crash trying
+	 * to read the partially-complete file.
 	 */
 	snprintf(tempfilename, sizeof(tempfilename), "%s%c%s.%d",
 			 DatabasePath, SEP_CHAR, RELCACHE_INIT_FILENAME, MyProcPid);
@@ -2292,19 +2303,18 @@ write_irels(void)
 
 	/*
 	 * Build relation descriptors for the critical system indexes without
-	 * resort to the descriptor cache.  In order to do this, we set
-	 * ProcessingMode to Bootstrap.  The effect of this is to disable indexed
-	 * relation searches -- a necessary step, since we're trying to
-	 * instantiate the index relation descriptors here.  Once we have the
-	 * descriptors, nail them into cache so we never lose them.
+	 * resort to the descriptor cache.	In order to do this, we set
+	 * ProcessingMode to Bootstrap.  The effect of this is to disable
+	 * indexed relation searches -- a necessary step, since we're trying
+	 * to instantiate the index relation descriptors here.	Once we have
+	 * the descriptors, nail them into cache so we never lose them.
 	 */
 
-	/* Removed the following ProcessingMode change -- inoue
-	 * At this point
-	 * 1) Catalog Cache isn't initialized
-	 * 2) Relation Cache for the following critical indexes aren't built
-	oldmode = GetProcessingMode();
-	SetProcessingMode(BootstrapProcessing);
+	/*
+	 * Removed the following ProcessingMode change -- inoue At this point
+	 * 1) Catalog Cache isn't initialized 2) Relation Cache for the
+	 * following critical indexes aren't built oldmode =
+	 * GetProcessingMode(); SetProcessingMode(BootstrapProcessing);
 	 */
 
 	bi.infotype = INFO_RELNAME;
@@ -2321,8 +2331,10 @@ write_irels(void)
 	irel[2]->rd_isnailed = true;
 
 	criticalRelcacheBuild = true;
-	/* Removed the following ProcessingMode -- inoue 
-	SetProcessingMode(oldmode);
+
+	/*
+	 * Removed the following ProcessingMode -- inoue
+	 * SetProcessingMode(oldmode);
 	 */
 
 	/*
@@ -2411,9 +2423,9 @@ write_irels(void)
 
 	FileClose(fd);
 
-    /*
-     * And rename the temp file to its final name, deleting any previously-
-	 * existing init file.
-     */
-    rename(tempfilename, finalfilename);
+	/*
+	 * And rename the temp file to its final name, deleting any
+	 * previously- existing init file.
+	 */
+	rename(tempfilename, finalfilename);
 }
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c
index 087002ab76fe6a5a24f736aa2e9b5e665f14149f..5379873350bf4c8745e2d32b3702d8f440d6a34f 100644
--- a/src/backend/utils/cache/syscache.c
+++ b/src/backend/utils/cache/syscache.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.49 2000/02/18 09:28:56 inoue Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.50 2000/04/12 17:15:54 momjian Exp $
  *
  * NOTES
  *	  These routines allow the parser/planner/executor to perform
@@ -57,28 +57,28 @@ typedef HeapTuple (*ScanFunc) ();
 	the list sorted alphabetically and adjust the cache numbers
 	accordingly.
 
-	Add your entry to the cacheinfo[] array below.  All cache lists are
+	Add your entry to the cacheinfo[] array below.	All cache lists are
 	alphabetical, so add it in the proper place.  Specify the relation
-    name, number of arguments, argument names, size of tuple, index lookup
+	name, number of arguments, argument names, size of tuple, index lookup
 	function, and index name.
 
-    In include/catalog/indexing.h, add a define for the number of indexes
-    in the relation, add a define for the index name, add an extern
-    array to hold the index names, define the index lookup function
-    prototype, and use DECLARE_UNIQUE_INDEX to define the index.  Cache
-    lookups return only one row, so the index should be unique.
+	In include/catalog/indexing.h, add a define for the number of indexes
+	in the relation, add a define for the index name, add an extern
+	array to hold the index names, define the index lookup function
+	prototype, and use DECLARE_UNIQUE_INDEX to define the index.  Cache
+	lookups return only one row, so the index should be unique.
 
-    In backend/catalog/indexing.c, initialize the relation array with
-    the index names for the relation, fixed size of relation (or marking
-    first non-fixed length field), and create the index lookup function.
-    Pick one that takes similar arguments and use that one, but keep the
-    function names in the same order as the cache list for clarity.
+	In backend/catalog/indexing.c, initialize the relation array with
+	the index names for the relation, fixed size of relation (or marking
+	first non-fixed length field), and create the index lookup function.
+	Pick one that takes similar arguments and use that one, but keep the
+	function names in the same order as the cache list for clarity.
 
-    Finally, any place your relation gets heap_insert() or
+	Finally, any place your relation gets heap_insert() or
 	heap_update calls, include code to do a CatalogIndexInsert() to update
 	the system indexes.  The heap_* calls do not update indexes.
 
-    bjm 1999/11/22
+	bjm 1999/11/22
 
   ---------------------------------------------------------------------------
 */
@@ -394,10 +394,12 @@ static struct cachedesc cacheinfo[] = {
 	TypeOidIndexScan}
 };
 
-static struct catcache *SysCache[lengthof(cacheinfo)];
+static struct catcache *SysCache[
+								 lengthof(cacheinfo)];
 static int32 SysCacheSize = lengthof(cacheinfo);
-static bool  CacheInitialized = false;
-extern bool  IsCacheInitialized(void)
+static bool CacheInitialized = false;
+extern bool
+IsCacheInitialized(void)
 {
 	return CacheInitialized;
 }
@@ -520,7 +522,7 @@ SearchSysCacheTuple(int cacheId,/* cache selection code */
 	/* temp table name remapping */
 	if (cacheId == RELNAME)
 	{
-		char *nontemp_relname;
+		char	   *nontemp_relname;
 
 		if ((nontemp_relname =
 			 get_temp_rel_by_username(DatumGetPointer(key1))) != NULL)
@@ -549,7 +551,7 @@ SearchSysCacheTuple(int cacheId,/* cache selection code */
  *		SearchSysCacheTupleCopy(), extract a specific attribute.
  *
  * This is equivalent to using heap_getattr() on a tuple fetched
- * from a non-cached relation.  Usually, this is only used for attributes
+ * from a non-cached relation.	Usually, this is only used for attributes
  * that could be NULL or variable length; the fixed-size attributes in
  * a system table are accessed just by mapping the tuple onto the C struct
  * declarations from include/catalog/.
@@ -563,17 +565,18 @@ SysCacheGetAttr(int cacheId, HeapTuple tup,
 				AttrNumber attributeNumber,
 				bool *isnull)
 {
+
 	/*
-	 * We just need to get the TupleDesc out of the cache entry,
-	 * and then we can apply heap_getattr().  We expect that the cache
-	 * control data is currently valid --- if the caller just fetched
-	 * the tuple, then it should be.
+	 * We just need to get the TupleDesc out of the cache entry, and then
+	 * we can apply heap_getattr().  We expect that the cache control data
+	 * is currently valid --- if the caller just fetched the tuple, then
+	 * it should be.
 	 */
 	if (cacheId < 0 || cacheId >= SysCacheSize)
 		elog(ERROR, "SysCacheGetAttr: Bad cache id %d", cacheId);
-	if (! PointerIsValid(SysCache[cacheId]) ||
+	if (!PointerIsValid(SysCache[cacheId]) ||
 		SysCache[cacheId]->relationId == InvalidOid ||
-		! PointerIsValid(SysCache[cacheId]->cc_tupdesc))
+		!PointerIsValid(SysCache[cacheId]->cc_tupdesc))
 		elog(ERROR, "SysCacheGetAttr: missing cache data for id %d", cacheId);
 
 	return heap_getattr(tup, attributeNumber,
diff --git a/src/backend/utils/cache/temprel.c b/src/backend/utils/cache/temprel.c
index 0da4f3bd5e4757e286114680f39fdc8b3e2b9890..d5e7ba2dce9cdd2f95e229ed245fe731418c1577 100644
--- a/src/backend/utils/cache/temprel.c
+++ b/src/backend/utils/cache/temprel.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.20 2000/01/26 05:57:18 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.21 2000/04/12 17:15:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -64,7 +64,7 @@ create_temp_relation(const char *relname, HeapTuple pg_class_tuple)
 	/* save user-supplied name */
 	strcpy(temp_rel->user_relname, relname);
 	StrNCpy(temp_rel->relname, NameStr(((Form_pg_class)
-		GETSTRUCT(pg_class_tuple))->relname), NAMEDATALEN);
+					  GETSTRUCT(pg_class_tuple))->relname), NAMEDATALEN);
 	temp_rel->relid = pg_class_tuple->t_data->t_oid;
 	temp_rel->relkind = ((Form_pg_class) GETSTRUCT(pg_class_tuple))->relkind;
 	temp_rel->xid = GetCurrentTransactionId();
@@ -95,7 +95,7 @@ remove_all_temp_relations(void)
 
 		if (temp_rel->relkind != RELKIND_INDEX)
 		{
-			char	relname[NAMEDATALEN];
+			char		relname[NAMEDATALEN];
 
 			/* safe from deallocation */
 			strcpy(relname, temp_rel->user_relname);
@@ -118,7 +118,7 @@ remove_temp_relation(Oid relid)
 	MemoryContext oldcxt;
 	List	   *l,
 			   *prev;
-			   
+
 	oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt);
 
 	prev = NIL;
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 1a61d7e6d17828c628c51206df6d4c6f0a8ff3cd..8296b1d919fe0832ef04557a245244167f4183a1 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.55 2000/02/13 18:59:50 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.56 2000/04/12 17:15:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -40,7 +40,7 @@
 extern int	errno;
 extern int	sys_nerr;
 
-extern CommandDest	whereToSendOutput;
+extern CommandDest whereToSendOutput;
 
 #ifdef USE_SYSLOG
 /*
@@ -79,9 +79,10 @@ static int	ElogDebugIndentLevel = 0;
  *--------------------
  */
 void
-elog(int lev, const char *fmt, ...)
+elog(int lev, const char *fmt,...)
 {
 	va_list		ap;
+
 	/*
 	 * The expanded format and final output message are dynamically
 	 * allocated if necessary, but not if they fit in the "reasonable
@@ -95,6 +96,7 @@ elog(int lev, const char *fmt, ...)
 	char		msg_fixedbuf[256];
 	char	   *fmt_buf = fmt_fixedbuf;
 	char	   *msg_buf = msg_fixedbuf;
+
 	/* this buffer is only used if errno has a bogus value: */
 	char		errorstr_buf[32];
 	const char *errorstr;
@@ -103,8 +105,10 @@ elog(int lev, const char *fmt, ...)
 	char	   *bp;
 	int			indent = 0;
 	int			space_needed;
+
 #ifdef USE_SYSLOG
 	int			log_level;
+
 #endif
 	int			len;
 
@@ -160,10 +164,10 @@ elog(int lev, const char *fmt, ...)
 	}
 
 	/*
-	 * Set up the expanded format, consisting of the prefix string
-	 * plus input format, with any %m replaced by strerror() string
-	 * (since vsnprintf won't know what to do with %m).  To keep
-	 * space calculation simple, we only allow one %m.
+	 * Set up the expanded format, consisting of the prefix string plus
+	 * input format, with any %m replaced by strerror() string (since
+	 * vsnprintf won't know what to do with %m).  To keep space
+	 * calculation simple, we only allow one %m.
 	 */
 	space_needed = TIMESTAMP_SIZE + strlen(prefix) + indent + (lineno ? 24 : 0)
 		+ strlen(fmt) + strlen(errorstr) + 1;
@@ -175,7 +179,8 @@ elog(int lev, const char *fmt, ...)
 			/* We're up against it, convert to fatal out-of-memory error */
 			fmt_buf = fmt_fixedbuf;
 			lev = REALLYFATAL;
-			fmt = "elog: out of memory"; /* this must fit in fmt_fixedbuf! */
+			fmt = "elog: out of memory";		/* this must fit in
+												 * fmt_fixedbuf! */
 		}
 	}
 #ifdef ELOG_TIMESTAMPS
@@ -189,10 +194,11 @@ elog(int lev, const char *fmt, ...)
 		*bp++ = ' ';
 
 	/* If error was in CopyFrom() print the offending line number -- dz */
-	if (lineno) {
-	    sprintf(bp, "copy: line %d, ", lineno);
-	    bp = fmt_buf + strlen(fmt_buf);
-	    lineno = 0;
+	if (lineno)
+	{
+		sprintf(bp, "copy: line %d, ", lineno);
+		bp = fmt_buf + strlen(fmt_buf);
+		lineno = 0;
 	}
 
 	for (cp = fmt; *cp; cp++)
@@ -201,15 +207,19 @@ elog(int lev, const char *fmt, ...)
 		{
 			if (cp[1] == 'm')
 			{
-				/* XXX If there are any %'s in errorstr then vsnprintf
-				 * will do the Wrong Thing; do we need to cope?
-				 * Seems unlikely that % would appear in system errors.
+
+				/*
+				 * XXX If there are any %'s in errorstr then vsnprintf
+				 * will do the Wrong Thing; do we need to cope? Seems
+				 * unlikely that % would appear in system errors.
 				 */
 				strcpy(bp, errorstr);
-				/* copy the rest of fmt literally, since we can't
-				 * afford to insert another %m.
+
+				/*
+				 * copy the rest of fmt literally, since we can't afford
+				 * to insert another %m.
 				 */
-				strcat(bp, cp+2);
+				strcat(bp, cp + 2);
 				bp += strlen(bp);
 				break;
 			}
@@ -226,21 +236,22 @@ elog(int lev, const char *fmt, ...)
 	*bp = '\0';
 
 	/*
-	 * Now generate the actual output text using vsnprintf().
-	 * Be sure to leave space for \n added later as well as trailing null.
+	 * Now generate the actual output text using vsnprintf(). Be sure to
+	 * leave space for \n added later as well as trailing null.
 	 */
 	space_needed = sizeof(msg_fixedbuf);
 	for (;;)
 	{
-		int nprinted;
+		int			nprinted;
 
 		va_start(ap, fmt);
 		nprinted = vsnprintf(msg_buf, space_needed - 2, fmt_buf, ap);
 		va_end(ap);
+
 		/*
 		 * Note: some versions of vsnprintf return the number of chars
-		 * actually stored, but at least one returns -1 on failure.
-		 * Be conservative about believing whether the print worked.
+		 * actually stored, but at least one returns -1 on failure. Be
+		 * conservative about believing whether the print worked.
 		 */
 		if (nprinted >= 0 && nprinted < space_needed - 3)
 			break;
@@ -252,8 +263,8 @@ elog(int lev, const char *fmt, ...)
 		if (msg_buf == NULL)
 		{
 			/* We're up against it, convert to fatal out-of-memory error */
-            msg_buf = msg_fixedbuf;
-            lev = REALLYFATAL;
+			msg_buf = msg_fixedbuf;
+			lev = REALLYFATAL;
 #ifdef ELOG_TIMESTAMPS
 			strcpy(msg_buf, tprintf_timestamp());
 			strcat(msg_buf, "FATAL:  elog: out of memory");
@@ -307,7 +318,7 @@ elog(int lev, const char *fmt, ...)
 	 * then writing here can cause this backend to exit without warning
 	 * that is, write() does an exit(). In this case, our only hope of
 	 * finding out what's going on is if Err_file was set to some disk
-	 * log.  This is a major pain.  (It's probably also long-dead code...
+	 * log.  This is a major pain.	(It's probably also long-dead code...
 	 * does anyone still use ultrix?)
 	 */
 	if (lev > DEBUG && Err_file >= 0 &&
@@ -332,6 +343,7 @@ elog(int lev, const char *fmt, ...)
 			msgtype = 'N';
 		else
 		{
+
 			/*
 			 * Abort any COPY OUT in progress when an error is detected.
 			 * This hack is necessary because of poor design of copy
@@ -357,8 +369,10 @@ elog(int lev, const char *fmt, ...)
 
 	if (lev > DEBUG && whereToSendOutput != Remote)
 	{
-		/* We are running as an interactive backend, so just send
-		 * the message to stderr.
+
+		/*
+		 * We are running as an interactive backend, so just send the
+		 * message to stderr.
 		 */
 		fputs(msg_buf, stderr);
 	}
@@ -376,34 +390,37 @@ elog(int lev, const char *fmt, ...)
 	 */
 	if (lev == ERROR || lev == FATAL)
 	{
+
 		/*
 		 * If we have not yet entered the main backend loop (ie, we are in
 		 * the postmaster or in backend startup), then go directly to
 		 * proc_exit.  The same is true if anyone tries to report an error
-		 * after proc_exit has begun to run.  (It's proc_exit's responsibility
-		 * to see that this doesn't turn into infinite recursion!)  But in
-		 * the latter case, we exit with nonzero exit code to indicate that
-		 * something's pretty wrong.
+		 * after proc_exit has begun to run.  (It's proc_exit's
+		 * responsibility to see that this doesn't turn into infinite
+		 * recursion!)	But in the latter case, we exit with nonzero exit
+		 * code to indicate that something's pretty wrong.
 		 */
-		if (proc_exit_inprogress || ! Warn_restart_ready)
+		if (proc_exit_inprogress || !Warn_restart_ready)
 		{
 			fflush(stdout);
 			fflush(stderr);
-			ProcReleaseSpins(NULL); /* get rid of spinlocks we hold */
-			ProcReleaseLocks();		/* get rid of real locks we hold */
+			ProcReleaseSpins(NULL);		/* get rid of spinlocks we hold */
+			ProcReleaseLocks(); /* get rid of real locks we hold */
 			/* XXX shouldn't proc_exit be doing the above?? */
 			proc_exit((int) proc_exit_inprogress);
 		}
+
 		/*
 		 * Guard against infinite loop from elog() during error recovery.
 		 */
 		if (InError)
 			elog(REALLYFATAL, "elog: error during error recovery, giving up!");
 		InError = true;
+
 		/*
-		 * Otherwise we can return to the main loop in postgres.c.
-		 * In the FATAL case, postgres.c will call proc_exit, but not
-		 * till after completing a standard transaction-abort sequence.
+		 * Otherwise we can return to the main loop in postgres.c. In the
+		 * FATAL case, postgres.c will call proc_exit, but not till after
+		 * completing a standard transaction-abort sequence.
 		 */
 		ProcReleaseSpins(NULL); /* get rid of spinlocks we hold */
 		if (lev == FATAL)
@@ -413,19 +430,20 @@ elog(int lev, const char *fmt, ...)
 
 	if (lev > FATAL)
 	{
+
 		/*
-		 * Serious crash time. Postmaster will observe nonzero
-		 * process exit status and kill the other backends too.
+		 * Serious crash time. Postmaster will observe nonzero process
+		 * exit status and kill the other backends too.
 		 *
-		 * XXX: what if we are *in* the postmaster?  proc_exit()
-		 * won't kill our children...
+		 * XXX: what if we are *in* the postmaster?  proc_exit() won't kill
+		 * our children...
 		 */
 		fflush(stdout);
 		fflush(stderr);
 		proc_exit(lev);
 	}
 
-	/* We reach here if lev <= NOTICE.  OK to return to caller. */
+	/* We reach here if lev <= NOTICE.	OK to return to caller. */
 }
 
 #ifndef PG_STANDALONE
diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c
index 2e3750a712677ad7fc9495396cfc58cc2daf9447..a460fab05c2c5d28e40c13487bf0f9f43be16860 100644
--- a/src/backend/utils/fmgr/dfmgr.c
+++ b/src/backend/utils/fmgr/dfmgr.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.38 2000/01/26 05:57:22 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.39 2000/04/12 17:15:57 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -61,10 +61,10 @@ fmgr_dynamic(Oid procedureId, int *pronargs)
 
 	/*
 	 * The procedure isn't a builtin, so we'll have to do a catalog lookup
-	 * to find its pg_proc entry.  Moreover, since probin is varlena, we're
-	 * going to have to use heap_getattr, which means we need the reldesc,
-	 * which means we need to open the relation.  So we might as well do that
-	 * first and get the benefit of SI inval if needed.
+	 * to find its pg_proc entry.  Moreover, since probin is varlena,
+	 * we're going to have to use heap_getattr, which means we need the
+	 * reldesc, which means we need to open the relation.  So we might as
+	 * well do that first and get the benefit of SI inval if needed.
 	 */
 	rel = heap_openr(ProcedureRelationName, AccessShareLock);
 
@@ -123,7 +123,8 @@ fmgr_dynamic(Oid procedureId, int *pronargs)
 	user_fn = handle_load(probinstring, linksymbol);
 
 	pfree(probinstring);
-	if (prosrcstring) pfree(prosrcstring);
+	if (prosrcstring)
+		pfree(prosrcstring);
 
 	procedureId_save = procedureId;
 	user_fn_save = user_fn;
diff --git a/src/backend/utils/hash/dynahash.c b/src/backend/utils/hash/dynahash.c
index 871144bf76467fb48e7578caa4ee4da588c1b0e4..93707fcba91cbd30510a64fca58efb04895495c9 100644
--- a/src/backend/utils/hash/dynahash.c
+++ b/src/backend/utils/hash/dynahash.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/hash/dynahash.c,v 1.30 2000/03/17 02:36:28 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/hash/dynahash.c,v 1.31 2000/04/12 17:16:00 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -701,7 +701,7 @@ hash_search(HTAB *hashp,
 long *
 hash_seq(HTAB *hashp)
 {
-	static long	curBucket = 0;
+	static long curBucket = 0;
 	static BUCKET_INDEX curIndex;
 	ELEMENT    *curElem;
 	long		segment_num;
@@ -813,9 +813,10 @@ expand_table(HTAB *hashp)
 
 	/*
 	 * *Before* changing masks, find old bucket corresponding to same hash
-	 * values; values in that bucket may need to be relocated to new bucket.
-	 * Note that new_bucket is certainly larger than low_mask at this point,
-	 * so we can skip the first step of the regular hash mask calc.
+	 * values; values in that bucket may need to be relocated to new
+	 * bucket. Note that new_bucket is certainly larger than low_mask at
+	 * this point, so we can skip the first step of the regular hash mask
+	 * calc.
 	 */
 	old_bucket = (new_bucket & hctl->low_mask);
 
@@ -829,9 +830,9 @@ expand_table(HTAB *hashp)
 	}
 
 	/*
-	 * Relocate records to the new bucket.  NOTE: because of the way the
+	 * Relocate records to the new bucket.	NOTE: because of the way the
 	 * hash masking is done in call_hash, only one old bucket can need to
-	 * be split at this point.  With a different way of reducing the hash
+	 * be split at this point.	With a different way of reducing the hash
 	 * value, that might not be true!
 	 */
 	old_segnum = old_bucket >> hctl->sshift;
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 5170be2861548313dd5423e33362ae77e7a8b772..8c4642d1ee2da9db2506e78fe390dee3eade0430 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.41 2000/02/16 17:25:49 thomas Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.42 2000/04/12 17:16:02 momjian Exp $
  *
  * NOTES
  *	  Globals used all over the place should be declared here and not
@@ -93,7 +93,8 @@ char	   *IndexedCatalogNames[] = {
  * ps status buffer
  */
 #ifndef linux
-char	Ps_status_buffer[1024];
+char		Ps_status_buffer[1024];
+
 #endif
 
 /* ----------------
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
index 41b4020c713ce10f71bbeeb11dcfa23e731b6fcf..a1ba1e1ff9b17f46f442d1b48001c5ba95a74817 100644
--- a/src/backend/utils/init/miscinit.c
+++ b/src/backend/utils/init/miscinit.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.44 2000/02/18 09:28:58 inoue Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.45 2000/04/12 17:16:02 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -34,6 +34,7 @@
 #ifdef CYR_RECODE
 unsigned char RecodeForwTable[128];
 unsigned char RecodeBackTable[128];
+
 #endif
 
 ProcessingMode Mode = InitProcessing;
@@ -43,7 +44,7 @@ ProcessingMode Mode = InitProcessing;
  * ----------------------------------------------------------------
  */
 
-static bool	isIgnoringSystemIndexes = false;
+static bool isIgnoringSystemIndexes = false;
 
 /*
  * IsIgnoringSystemIndexes
@@ -74,24 +75,24 @@ IgnoreSystemIndexes(bool mode)
 void
 SetDatabasePath(const char *path)
 {
-    free(DatabasePath);
+	free(DatabasePath);
 	/* use strdup since this is done before memory contexts are set up */
-    if (path)
-    {
-        DatabasePath = strdup(path);
-        AssertState(DatabasePath);
-    }
+	if (path)
+	{
+		DatabasePath = strdup(path);
+		AssertState(DatabasePath);
+	}
 }
 
 void
 SetDatabaseName(const char *name)
 {
-    free(DatabaseName);
-    if (name)
-    {
-        DatabaseName = strdup(name);
-        AssertState(DatabaseName);
-    }
+	free(DatabaseName);
+	if (name)
+	{
+		DatabaseName = strdup(name);
+		AssertState(DatabaseName);
+	}
 }
 
 #ifndef MULTIBYTE
@@ -105,13 +106,15 @@ getdatabaseencoding()
 	return ("");
 }
 
-const char *pg_encoding_to_char(int encoding)
+const char *
+pg_encoding_to_char(int encoding)
 {
 	elog(ERROR, "MultiByte support must be enabled to use this function");
 	return ("");
 }
 
-int	pg_char_to_encoding(const char *encoding_string)
+int
+pg_char_to_encoding(const char *encoding_string)
 {
 	elog(ERROR, "MultiByte support must be enabled to use this function");
 	return (0);
@@ -332,7 +335,7 @@ SetUserId()
 	HeapTuple	userTup;
 	char	   *userName;
 
-	AssertState(!OidIsValid(UserId));/* only once */
+	AssertState(!OidIsValid(UserId));	/* only once */
 
 	/*
 	 * Don't do scans if we're bootstrapping, none of the system catalogs
@@ -361,10 +364,10 @@ SetUserId()
  *
  *	(1) postmaster starts. In this case pid > 0.
  *	(2) postgres starts in standalone mode. In this case
- *	    pid < 0
+ *		pid < 0
  *
  * to gain an interlock.
- * 
+ *
  *	SetPidFname(datadir)
  *		Remember the the pid file name. This is neccesary
  *		UnlinkPidFile() is called from proc_exit().
@@ -392,7 +395,8 @@ static char PidFile[MAXPGPATH];
 /*
  * Remove the pid file. This function is called from proc_exit.
  */
-void UnlinkPidFile(void)
+void
+UnlinkPidFile(void)
 {
 	unlink(PidFile);
 }
@@ -400,7 +404,8 @@ void UnlinkPidFile(void)
 /*
  * Set path to the pid file
  */
-void SetPidFname(char * datadir)
+void
+SetPidFname(char *datadir)
 {
 	snprintf(PidFile, sizeof(PidFile), "%s/%s", datadir, PIDFNAME);
 }
@@ -408,45 +413,50 @@ void SetPidFname(char * datadir)
 /*
  * Get path to the pid file
  */
-char *GetPidFname(void)
+char *
+GetPidFname(void)
 {
-	return(PidFile);
+	return (PidFile);
 }
 
 /*
  * Create the pid file
  */
-int SetPidFile(pid_t pid)
+int
+SetPidFile(pid_t pid)
 {
-	int fd;
-	char *pidfile;
-	char pidstr[32];
-	int len;
-	pid_t post_pid;
-	int is_postgres = 0;
+	int			fd;
+	char	   *pidfile;
+	char		pidstr[32];
+	int			len;
+	pid_t		post_pid;
+	int			is_postgres = 0;
 
 	/*
 	 * Creating pid file
 	 */
 	pidfile = GetPidFname();
 	fd = open(pidfile, O_RDWR | O_CREAT | O_EXCL, 0600);
-	if (fd < 0) {
+	if (fd < 0)
+	{
+
 		/*
-		 * Couldn't create the pid file. Probably
-		 * it already exists. Read the file to see if the process
-		 * actually exists
+		 * Couldn't create the pid file. Probably it already exists. Read
+		 * the file to see if the process actually exists
 		 */
 		fd = open(pidfile, O_RDONLY, 0600);
-		if (fd < 0) {
+		if (fd < 0)
+		{
 			fprintf(stderr, "Can't open pid file: %s\n", pidfile);
 			fprintf(stderr, "Please check the permission and try again.\n");
-			return(-1);
+			return (-1);
 		}
-		if ((len = read(fd, pidstr, sizeof(pidstr)-1)) < 0) {
+		if ((len = read(fd, pidstr, sizeof(pidstr) - 1)) < 0)
+		{
 			fprintf(stderr, "Can't read pid file: %s\n", pidfile);
 			fprintf(stderr, "Please check the permission and try again.\n");
 			close(fd);
-			return(-1);
+			return (-1);
 		}
 		close(fd);
 
@@ -454,56 +464,62 @@ int SetPidFile(pid_t pid)
 		 * Check to see if the process actually exists
 		 */
 		pidstr[len] = '\0';
-		post_pid = (pid_t)atoi(pidstr);
+		post_pid = (pid_t) atoi(pidstr);
 
 		/* if pid < 0, the pid is for postgres, not postmatser */
-		if (post_pid < 0) {
+		if (post_pid < 0)
+		{
 			is_postgres++;
 			post_pid = -post_pid;
 		}
 
-		if (post_pid == 0 || (post_pid > 0 && kill(post_pid, 0) < 0)) {
+		if (post_pid == 0 || (post_pid > 0 && kill(post_pid, 0) < 0))
+		{
+
 			/*
-			 * No, the process did not exist. Unlink
-			 * the file and try to create it
+			 * No, the process did not exist. Unlink the file and try to
+			 * create it
 			 */
-			if (unlink(pidfile) < 0) {
+			if (unlink(pidfile) < 0)
+			{
 				fprintf(stderr, "Can't remove pid file: %s\n", pidfile);
 				fprintf(stderr, "The file seems accidently left, but I couldn't remove it.\n");
 				fprintf(stderr, "Please remove the file by hand and try again.\n");
-				return(-1);
+				return (-1);
 			}
 			fd = open(pidfile, O_RDWR | O_CREAT | O_EXCL, 0600);
-			if (fd < 0) {
+			if (fd < 0)
+			{
 				fprintf(stderr, "Can't create pid file: %s\n", pidfile);
 				fprintf(stderr, "Please check the permission and try again.\n");
-				return(-1);
+				return (-1);
 			}
-		} else {
+		}
+		else
+		{
+
 			/*
 			 * Another postmaster is running
 			 */
 			fprintf(stderr, "Can't create pid file: %s\n", pidfile);
-			if (is_postgres) {
-			  fprintf(stderr, "Is another postgres (pid: %d) running?\n", post_pid);
-			}
+			if (is_postgres)
+				fprintf(stderr, "Is another postgres (pid: %d) running?\n", post_pid);
 			else
-			{
-			  fprintf(stderr, "Is another postmaster (pid: %s) running?\n", pidstr);
-			}
-			return(-1);
+				fprintf(stderr, "Is another postmaster (pid: %s) running?\n", pidstr);
+			return (-1);
 		}
 	}
 
 	sprintf(pidstr, "%d", pid);
-	if (write(fd, pidstr, strlen(pidstr)) != strlen(pidstr)) {
-		fprintf(stderr,"Write to pid file failed\n");
+	if (write(fd, pidstr, strlen(pidstr)) != strlen(pidstr))
+	{
+		fprintf(stderr, "Write to pid file failed\n");
 		fprintf(stderr, "Please check the permission and try again.\n");
 		close(fd);
 		unlink(pidfile);
-		return(-1);
+		return (-1);
 	}
 	close(fd);
 
-	return(0);
+	return (0);
 }
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index 597e6ced8b64cb889db47c11225c60dd049e92e1..c4675a6b57da7efb2ac1b9298c7f33a3254a9f63 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.56 2000/01/26 05:57:26 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.57 2000/04/12 17:16:02 momjian Exp $
  *
  *
  *-------------------------------------------------------------------------
@@ -77,12 +77,12 @@ ReverifyMyDatabase(const char *name)
 {
 	Relation	pgdbrel;
 	HeapScanDesc pgdbscan;
-	ScanKeyData	key;
+	ScanKeyData key;
 	HeapTuple	tup;
 
 	/*
-	 * Because we grab AccessShareLock here, we can be sure that
-	 * destroydb is not running in parallel with us (any more).
+	 * Because we grab AccessShareLock here, we can be sure that destroydb
+	 * is not running in parallel with us (any more).
 	 */
 	pgdbrel = heap_openr(DatabaseRelationName, AccessShareLock);
 
@@ -97,12 +97,12 @@ ReverifyMyDatabase(const char *name)
 	{
 		/* OOPS */
 		heap_close(pgdbrel, AccessShareLock);
+
 		/*
 		 * The only real problem I could have created is to load dirty
-		 * buffers for the dead database into shared buffer cache;
-		 * if I did, some other backend will eventually try to write
-		 * them and die in mdblindwrt.  Flush any such pages to forestall
-		 * trouble.
+		 * buffers for the dead database into shared buffer cache; if I
+		 * did, some other backend will eventually try to write them and
+		 * die in mdblindwrt.  Flush any such pages to forestall trouble.
 		 */
 		DropBuffers(MyDatabaseId);
 		/* Now I can commit hara-kiri with a clear conscience... */
@@ -112,15 +112,15 @@ ReverifyMyDatabase(const char *name)
 
 	/*
 	 * OK, we're golden.  Only other to-do item is to save the MULTIBYTE
-	 * encoding info out of the pg_database tuple.  Note we also set the
-	 * "template encoding", which is the default encoding for any
-	 * CREATE DATABASE commands executed in this backend; essentially,
-	 * you get the same encoding of the database you connected to as
-	 * the default.  (This replaces code that unreliably grabbed
-	 * template1's encoding out of pg_database.  We could do an extra
-	 * scan to find template1's tuple, but for 99.99% of all backend
-	 * startups it'd be wasted cycles --- and the 'createdb' script
-	 * connects to template1 anyway, so there's no difference.)
+	 * encoding info out of the pg_database tuple.	Note we also set the
+	 * "template encoding", which is the default encoding for any CREATE
+	 * DATABASE commands executed in this backend; essentially, you get
+	 * the same encoding of the database you connected to as the default.
+	 * (This replaces code that unreliably grabbed template1's encoding
+	 * out of pg_database.	We could do an extra scan to find template1's
+	 * tuple, but for 99.99% of all backend startups it'd be wasted cycles
+	 * --- and the 'createdb' script connects to template1 anyway, so
+	 * there's no difference.)
 	 */
 #ifdef MULTIBYTE
 	SetDatabaseEncoding(((Form_pg_database) GETSTRUCT(tup))->encoding);
@@ -250,7 +250,7 @@ InitPostgres(const char *dbname)
 		on_shmem_exit(FlushBufferPool, (caddr_t) NULL);
 #endif
 
-    SetDatabaseName(dbname);
+	SetDatabaseName(dbname);
 	/* ----------------
 	 *	initialize the database id used for system caches and lock tables
 	 * ----------------
@@ -262,56 +262,56 @@ InitPostgres(const char *dbname)
 	}
 	else
 	{
-        char *reason;
-        char *fullpath,
-              datpath[MAXPGPATH];
-
-        /* Verify if DataDir is ok */
-        if (access(DataDir, F_OK) == -1)
-            elog(FATAL, "Database system not found. Data directory '%s' does not exist.",
-                 DataDir);
-
-        ValidatePgVersion(DataDir, &reason);
-        if (reason != NULL)
-            elog(FATAL, reason);
-
-        /*-----------------
-         * Find oid and path of the database we're about to open. Since we're
-         * not yet up and running we have to use the hackish GetRawDatabaseInfo.
-         *
-         * OLD COMMENTS:
-         *		The database's oid forms half of the unique key for the system
-         *		caches and lock tables.  We therefore want it initialized before
-         *		we open any relations, since opening relations puts things in the
-         *		cache.	To get around this problem, this code opens and scans the
-         *		pg_database relation by hand.
-         */
-
-        GetRawDatabaseInfo(dbname, &MyDatabaseId, datpath);
-
-        if (!OidIsValid(MyDatabaseId))
-            elog(FATAL,
-                 "Database \"%s\" does not exist in the system catalog.",
-                 dbname);
-
-        fullpath = ExpandDatabasePath(datpath);
-        if (!fullpath)
-            elog(FATAL, "Database path could not be resolved.");
-
-        /* Verify the database path */
-
-        if (access(fullpath, F_OK) == -1)
-            elog(FATAL, "Database \"%s\" does not exist. The data directory '%s' is missing.",
-                 dbname, fullpath);
-
-        ValidatePgVersion(fullpath, &reason);
-        if (reason != NULL)
-            elog(FATAL, "%s", reason);
-
-        if(chdir(fullpath) == -1)
-            elog(FATAL, "Unable to change directory to '%s': %s", fullpath, strerror(errno));
-
-        SetDatabasePath(fullpath);
+		char	   *reason;
+		char	   *fullpath,
+					datpath[MAXPGPATH];
+
+		/* Verify if DataDir is ok */
+		if (access(DataDir, F_OK) == -1)
+			elog(FATAL, "Database system not found. Data directory '%s' does not exist.",
+				 DataDir);
+
+		ValidatePgVersion(DataDir, &reason);
+		if (reason != NULL)
+			elog(FATAL, reason);
+
+		/*-----------------
+		 * Find oid and path of the database we're about to open. Since we're
+		 * not yet up and running we have to use the hackish GetRawDatabaseInfo.
+		 *
+		 * OLD COMMENTS:
+		 *		The database's oid forms half of the unique key for the system
+		 *		caches and lock tables.  We therefore want it initialized before
+		 *		we open any relations, since opening relations puts things in the
+		 *		cache.	To get around this problem, this code opens and scans the
+		 *		pg_database relation by hand.
+		 */
+
+		GetRawDatabaseInfo(dbname, &MyDatabaseId, datpath);
+
+		if (!OidIsValid(MyDatabaseId))
+			elog(FATAL,
+				 "Database \"%s\" does not exist in the system catalog.",
+				 dbname);
+
+		fullpath = ExpandDatabasePath(datpath);
+		if (!fullpath)
+			elog(FATAL, "Database path could not be resolved.");
+
+		/* Verify the database path */
+
+		if (access(fullpath, F_OK) == -1)
+			elog(FATAL, "Database \"%s\" does not exist. The data directory '%s' is missing.",
+				 dbname, fullpath);
+
+		ValidatePgVersion(fullpath, &reason);
+		if (reason != NULL)
+			elog(FATAL, "%s", reason);
+
+		if (chdir(fullpath) == -1)
+			elog(FATAL, "Unable to change directory to '%s': %s", fullpath, strerror(errno));
+
+		SetDatabasePath(fullpath);
 	}
 
 	/*
@@ -319,8 +319,9 @@ InitPostgres(const char *dbname)
 	 */
 
 	/*
-	 * Initialize the transaction system and the relation descriptor cache.
-	 * Note we have to make certain the lock manager is off while we do this.
+	 * Initialize the transaction system and the relation descriptor
+	 * cache. Note we have to make certain the lock manager is off while
+	 * we do this.
 	 */
 	AmiTransactionOverride(IsBootstrapProcessingMode());
 	LockDisable(true);
@@ -344,10 +345,10 @@ InitPostgres(const char *dbname)
 	InitProcess(PostgresIpcKey);
 
 	/*
-	 * Initialize my entry in the shared-invalidation manager's
-	 * array of per-backend data.  (Formerly this came before
-	 * InitProcess, but now it must happen after, because it uses
-	 * MyProc.)  Once I have done this, I am visible to other backends!
+	 * Initialize my entry in the shared-invalidation manager's array of
+	 * per-backend data.  (Formerly this came before InitProcess, but now
+	 * it must happen after, because it uses MyProc.)  Once I have done
+	 * this, I am visible to other backends!
 	 *
 	 * Sets up MyBackendId, a unique backend identifier.
 	 */
@@ -361,8 +362,8 @@ InitPostgres(const char *dbname)
 	}
 
 	/*
-	 * Initialize the access methods.
-	 * Does not touch files (?) - thomas 1997-11-01
+	 * Initialize the access methods. Does not touch files (?) - thomas
+	 * 1997-11-01
 	 */
 	initam();
 
@@ -412,9 +413,9 @@ BaseInit(void)
 	EnableExceptionHandling(true);
 
 	/*
-	 * Memory system initialization - we may call palloc after 
-	 * EnableMemoryContext()).	Note that EnableMemoryContext() 
-	 * must happen before EnablePortalManager().
+	 * Memory system initialization - we may call palloc after
+	 * EnableMemoryContext()).	Note that EnableMemoryContext() must
+	 * happen before EnablePortalManager().
 	 */
 	EnableMemoryContext(true);	/* initializes the "top context" */
 	EnablePortalManager(true);	/* memory for portal/transaction stuff */
diff --git a/src/backend/utils/mb/conv.c b/src/backend/utils/mb/conv.c
index 80c1622947e66d87e90e499140dc9a65cf3b4a47..b274440e7f01236dbe8bd1f5d3ac86f4620da01e 100644
--- a/src/backend/utils/mb/conv.c
+++ b/src/backend/utils/mb/conv.c
@@ -4,7 +4,7 @@
  * Tatsuo Ishii
  * WIN1250 client encoding support contributed by Pavel Behal
  *
- * $Id: conv.c,v 1.13 2000/01/13 01:08:14 ishii Exp $
+ * $Id: conv.c,v 1.14 2000/04/12 17:16:06 momjian Exp $
  *
  *
  */
@@ -24,399 +24,1180 @@
 /*
  * conversion table between SJIS UDC (IBM kanji) and EUC_JP
  */
-static struct {
-  int sjis;	/* SJIS UDC (IBM kanji) */
-  int euc;	/* EUC_JP */
-} ibmkanji[] = {
-  {0xfa40, 0x8ff3f3},
-  {0xfa41, 0x8ff3f4},
-  {0xfa42, 0x8ff3f5},
-  {0xfa43, 0x8ff3f6},
-  {0xfa44, 0x8ff3f7},
-  {0xfa45, 0x8ff3f8},
-  {0xfa46, 0x8ff3f9},
-  {0xfa47, 0x8ff3fa},
-  {0xfa48, 0x8ff3fb},
-  {0xfa49, 0x8ff3fc},
-  {0xfa4a, 0x8ff3fd},
-  {0xfa4b, 0x8ff3fe},
-  {0xfa4c, 0x8ff4a1},
-  {0xfa4d, 0x8ff4a2},
-  {0xfa4e, 0x8ff4a3},
-  {0xfa4f, 0x8ff4a4},
-  {0xfa50, 0x8ff4a5},
-  {0xfa51, 0x8ff4a6},
-  {0xfa52, 0x8ff4a7},
-  {0xfa53, 0x8ff4a8},
-  {0xfa54, 0xa2cc},
-  {0xfa55, 0x8fa2c3},
-  {0xfa56, 0x8ff4a9},
-  {0xfa57, 0x8ff4aa},
-  {0xfa58, 0x8ff4ab},
-  {0xfa59, 0x8ff4ac},
-  {0xfa5a, 0x8ff4ad},
-  {0xfa5b, 0xa2e8},
-  {0xfa5c, 0x8fd4e3},
-  {0xfa5d, 0x8fdcdf},
-  {0xfa5e, 0x8fe4e9},
-  {0xfa5f, 0x8fe3f8},
-  {0xfa60, 0x8fd9a1},
-  {0xfa61, 0x8fb1bb},
-  {0xfa62, 0x8ff4ae},
-  {0xfa63, 0x8fc2ad},
-  {0xfa64, 0x8fc3fc},
-  {0xfa65, 0x8fe4d0},
-  {0xfa66, 0x8fc2bf},
-  {0xfa67, 0x8fbcf4},
-  {0xfa68, 0x8fb0a9},
-  {0xfa69, 0x8fb0c8},
-  {0xfa6a, 0x8ff4af},
-  {0xfa6b, 0x8fb0d2},
-  {0xfa6c, 0x8fb0d4},
-  {0xfa6d, 0x8fb0e3},
-  {0xfa6e, 0x8fb0ee},
-  {0xfa6f, 0x8fb1a7},
-  {0xfa70, 0x8fb1a3},
-  {0xfa71, 0x8fb1ac},
-  {0xfa72, 0x8fb1a9},
-  {0xfa73, 0x8fb1be},
-  {0xfa74, 0x8fb1df},
-  {0xfa75, 0x8fb1d8},
-  {0xfa76, 0x8fb1c8},
-  {0xfa77, 0x8fb1d7},
-  {0xfa78, 0x8fb1e3},
-  {0xfa79, 0x8fb1f4},
-  {0xfa7a, 0x8fb1e1},
-  {0xfa7b, 0x8fb2a3},
-  {0xfa7c, 0x8ff4b0},
-  {0xfa7d, 0x8fb2bb},
-  {0xfa7e, 0x8fb2e6},
-  {0xfa80, 0x8fb2ed},
-  {0xfa81, 0x8fb2f5},
-  {0xfa82, 0x8fb2fc},
-  {0xfa83, 0x8ff4b1},
-  {0xfa84, 0x8fb3b5},
-  {0xfa85, 0x8fb3d8},
-  {0xfa86, 0x8fb3db},
-  {0xfa87, 0x8fb3e5},
-  {0xfa88, 0x8fb3ee},
-  {0xfa89, 0x8fb3fb},
-  {0xfa8a, 0x8ff4b2},
-  {0xfa8b, 0x8ff4b3},
-  {0xfa8c, 0x8fb4c0},
-  {0xfa8d, 0x8fb4c7},
-  {0xfa8e, 0x8fb4d0},
-  {0xfa8f, 0x8fb4de},
-  {0xfa90, 0x8ff4b4},
-  {0xfa91, 0x8fb5aa},
-  {0xfa92, 0x8ff4b5},
-  {0xfa93, 0x8fb5af},
-  {0xfa94, 0x8fb5c4},
-  {0xfa95, 0x8fb5e8},
-  {0xfa96, 0x8ff4b6},
-  {0xfa97, 0x8fb7c2},
-  {0xfa98, 0x8fb7e4},
-  {0xfa99, 0x8fb7e8},
-  {0xfa9a, 0x8fb7e7},
-  {0xfa9b, 0x8ff4b7},
-  {0xfa9c, 0x8ff4b8},
-  {0xfa9d, 0x8ff4b9},
-  {0xfa9e, 0x8fb8ce},
-  {0xfa9f, 0x8fb8e1},
-  {0xfaa0, 0x8fb8f5},
-  {0xfaa1, 0x8fb8f7},
-  {0xfaa2, 0x8fb8f8},
-  {0xfaa3, 0x8fb8fc},
-  {0xfaa4, 0x8fb9af},
-  {0xfaa5, 0x8fb9b7},
-  {0xfaa6, 0x8fbabe},
-  {0xfaa7, 0x8fbadb},
-  {0xfaa8, 0x8fcdaa},
-  {0xfaa9, 0x8fbae1},
-  {0xfaaa, 0x8ff4ba},
-  {0xfaab, 0x8fbaeb},
-  {0xfaac, 0x8fbbb3},
-  {0xfaad, 0x8fbbb8},
-  {0xfaae, 0x8ff4bb},
-  {0xfaaf, 0x8fbbca},
-  {0xfab0, 0x8ff4bc},
-  {0xfab1, 0x8ff4bd},
-  {0xfab2, 0x8fbbd0},
-  {0xfab3, 0x8fbbde},
-  {0xfab4, 0x8fbbf4},
-  {0xfab5, 0x8fbbf5},
-  {0xfab6, 0x8fbbf9},
-  {0xfab7, 0x8fbce4},
-  {0xfab8, 0x8fbced},
-  {0xfab9, 0x8fbcfe},
-  {0xfaba, 0x8ff4be},
-  {0xfabb, 0x8fbdc2},
-  {0xfabc, 0x8fbde7},
-  {0xfabd, 0x8ff4bf},
-  {0xfabe, 0x8fbdf0},
-  {0xfabf, 0x8fbeb0},
-  {0xfac0, 0x8fbeac},
-  {0xfac1, 0x8ff4c0},
-  {0xfac2, 0x8fbeb3},
-  {0xfac3, 0x8fbebd},
-  {0xfac4, 0x8fbecd},
-  {0xfac5, 0x8fbec9},
-  {0xfac6, 0x8fbee4},
-  {0xfac7, 0x8fbfa8},
-  {0xfac8, 0x8fbfc9},
-  {0xfac9, 0x8fc0c4},
-  {0xfaca, 0x8fc0e4},
-  {0xfacb, 0x8fc0f4},
-  {0xfacc, 0x8fc1a6},
-  {0xfacd, 0x8ff4c1},
-  {0xface, 0x8fc1f5},
-  {0xfacf, 0x8fc1fc},
-  {0xfad0, 0x8ff4c2},
-  {0xfad1, 0x8fc1f8},
-  {0xfad2, 0x8fc2ab},
-  {0xfad3, 0x8fc2a1},
-  {0xfad4, 0x8fc2a5},
-  {0xfad5, 0x8ff4c3},
-  {0xfad6, 0x8fc2b8},
-  {0xfad7, 0x8fc2ba},
-  {0xfad8, 0x8ff4c4},
-  {0xfad9, 0x8fc2c4},
-  {0xfada, 0x8fc2d2},
-  {0xfadb, 0x8fc2d7},
-  {0xfadc, 0x8fc2db},
-  {0xfadd, 0x8fc2de},
-  {0xfade, 0x8fc2ed},
-  {0xfadf, 0x8fc2f0},
-  {0xfae0, 0x8ff4c5},
-  {0xfae1, 0x8fc3a1},
-  {0xfae2, 0x8fc3b5},
-  {0xfae3, 0x8fc3c9},
-  {0xfae4, 0x8fc3b9},
-  {0xfae5, 0x8ff4c6},
-  {0xfae6, 0x8fc3d8},
-  {0xfae7, 0x8fc3fe},
-  {0xfae8, 0x8ff4c7},
-  {0xfae9, 0x8fc4cc},
-  {0xfaea, 0x8ff4c8},
-  {0xfaeb, 0x8fc4d9},
-  {0xfaec, 0x8fc4ea},
-  {0xfaed, 0x8fc4fd},
-  {0xfaee, 0x8ff4c9},
-  {0xfaef, 0x8fc5a7},
-  {0xfaf0, 0x8fc5b5},
-  {0xfaf1, 0x8fc5b6},
-  {0xfaf2, 0x8ff4ca},
-  {0xfaf3, 0x8fc5d5},
-  {0xfaf4, 0x8fc6b8},
-  {0xfaf5, 0x8fc6d7},
-  {0xfaf6, 0x8fc6e0},
-  {0xfaf7, 0x8fc6ea},
-  {0xfaf8, 0x8fc6e3},
-  {0xfaf9, 0x8fc7a1},
-  {0xfafa, 0x8fc7ab},
-  {0xfafb, 0x8fc7c7},
-  {0xfafc, 0x8fc7c3},
-  {0xfb40, 0x8fc7cb},
-  {0xfb41, 0x8fc7cf},
-  {0xfb42, 0x8fc7d9},
-  {0xfb43, 0x8ff4cb},
-  {0xfb44, 0x8ff4cc},
-  {0xfb45, 0x8fc7e6},
-  {0xfb46, 0x8fc7ee},
-  {0xfb47, 0x8fc7fc},
-  {0xfb48, 0x8fc7eb},
-  {0xfb49, 0x8fc7f0},
-  {0xfb4a, 0x8fc8b1},
-  {0xfb4b, 0x8fc8e5},
-  {0xfb4c, 0x8fc8f8},
-  {0xfb4d, 0x8fc9a6},
-  {0xfb4e, 0x8fc9ab},
-  {0xfb4f, 0x8fc9ad},
-  {0xfb50, 0x8ff4cd},
-  {0xfb51, 0x8fc9ca},
-  {0xfb52, 0x8fc9d3},
-  {0xfb53, 0x8fc9e9},
-  {0xfb54, 0x8fc9e3},
-  {0xfb55, 0x8fc9fc},
-  {0xfb56, 0x8fc9f4},
-  {0xfb57, 0x8fc9f5},
-  {0xfb58, 0x8ff4ce},
-  {0xfb59, 0x8fcab3},
-  {0xfb5a, 0x8fcabd},
-  {0xfb5b, 0x8fcaef},
-  {0xfb5c, 0x8fcaf1},
-  {0xfb5d, 0x8fcbae},
-  {0xfb5e, 0x8ff4cf},
-  {0xfb5f, 0x8fcbca},
-  {0xfb60, 0x8fcbe6},
-  {0xfb61, 0x8fcbea},
-  {0xfb62, 0x8fcbf0},
-  {0xfb63, 0x8fcbf4},
-  {0xfb64, 0x8fcbee},
-  {0xfb65, 0x8fcca5},
-  {0xfb66, 0x8fcbf9},
-  {0xfb67, 0x8fccab},
-  {0xfb68, 0x8fccae},
-  {0xfb69, 0x8fccad},
-  {0xfb6a, 0x8fccb2},
-  {0xfb6b, 0x8fccc2},
-  {0xfb6c, 0x8fccd0},
-  {0xfb6d, 0x8fccd9},
-  {0xfb6e, 0x8ff4d0},
-  {0xfb6f, 0x8fcdbb},
-  {0xfb70, 0x8ff4d1},
-  {0xfb71, 0x8fcebb},
-  {0xfb72, 0x8ff4d2},
-  {0xfb73, 0x8fceba},
-  {0xfb74, 0x8fcec3},
-  {0xfb75, 0x8ff4d3},
-  {0xfb76, 0x8fcef2},
-  {0xfb77, 0x8fb3dd},
-  {0xfb78, 0x8fcfd5},
-  {0xfb79, 0x8fcfe2},
-  {0xfb7a, 0x8fcfe9},
-  {0xfb7b, 0x8fcfed},
-  {0xfb7c, 0x8ff4d4},
-  {0xfb7d, 0x8ff4d5},
-  {0xfb7e, 0x8ff4d6},
-  {0xfb80, 0x8ff4d7},
-  {0xfb81, 0x8fd0e5},
-  {0xfb82, 0x8ff4d8},
-  {0xfb83, 0x8fd0e9},
-  {0xfb84, 0x8fd1e8},
-  {0xfb85, 0x8ff4d9},
-  {0xfb86, 0x8ff4da},
-  {0xfb87, 0x8fd1ec},
-  {0xfb88, 0x8fd2bb},
-  {0xfb89, 0x8ff4db},
-  {0xfb8a, 0x8fd3e1},
-  {0xfb8b, 0x8fd3e8},
-  {0xfb8c, 0x8fd4a7},
-  {0xfb8d, 0x8ff4dc},
-  {0xfb8e, 0x8ff4dd},
-  {0xfb8f, 0x8fd4d4},
-  {0xfb90, 0x8fd4f2},
-  {0xfb91, 0x8fd5ae},
-  {0xfb92, 0x8ff4de},
-  {0xfb93, 0x8fd7de},
-  {0xfb94, 0x8ff4df},
-  {0xfb95, 0x8fd8a2},
-  {0xfb96, 0x8fd8b7},
-  {0xfb97, 0x8fd8c1},
-  {0xfb98, 0x8fd8d1},
-  {0xfb99, 0x8fd8f4},
-  {0xfb9a, 0x8fd9c6},
-  {0xfb9b, 0x8fd9c8},
-  {0xfb9c, 0x8fd9d1},
-  {0xfb9d, 0x8ff4e0},
-  {0xfb9e, 0x8ff4e1},
-  {0xfb9f, 0x8ff4e2},
-  {0xfba0, 0x8ff4e3},
-  {0xfba1, 0x8ff4e4},
-  {0xfba2, 0x8fdcd3},
-  {0xfba3, 0x8fddc8},
-  {0xfba4, 0x8fddd4},
-  {0xfba5, 0x8fddea},
-  {0xfba6, 0x8fddfa},
-  {0xfba7, 0x8fdea4},
-  {0xfba8, 0x8fdeb0},
-  {0xfba9, 0x8ff4e5},
-  {0xfbaa, 0x8fdeb5},
-  {0xfbab, 0x8fdecb},
-  {0xfbac, 0x8ff4e6},
-  {0xfbad, 0x8fdfb9},
-  {0xfbae, 0x8ff4e7},
-  {0xfbaf, 0x8fdfc3},
-  {0xfbb0, 0x8ff4e8},
-  {0xfbb1, 0x8ff4e9},
-  {0xfbb2, 0x8fe0d9},
-  {0xfbb3, 0x8ff4ea},
-  {0xfbb4, 0x8ff4eb},
-  {0xfbb5, 0x8fe1e2},
-  {0xfbb6, 0x8ff4ec},
-  {0xfbb7, 0x8ff4ed},
-  {0xfbb8, 0x8ff4ee},
-  {0xfbb9, 0x8fe2c7},
-  {0xfbba, 0x8fe3a8},
-  {0xfbbb, 0x8fe3a6},
-  {0xfbbc, 0x8fe3a9},
-  {0xfbbd, 0x8fe3af},
-  {0xfbbe, 0x8fe3b0},
-  {0xfbbf, 0x8fe3aa},
-  {0xfbc0, 0x8fe3ab},
-  {0xfbc1, 0x8fe3bc},
-  {0xfbc2, 0x8fe3c1},
-  {0xfbc3, 0x8fe3bf},
-  {0xfbc4, 0x8fe3d5},
-  {0xfbc5, 0x8fe3d8},
-  {0xfbc6, 0x8fe3d6},
-  {0xfbc7, 0x8fe3df},
-  {0xfbc8, 0x8fe3e3},
-  {0xfbc9, 0x8fe3e1},
-  {0xfbca, 0x8fe3d4},
-  {0xfbcb, 0x8fe3e9},
-  {0xfbcc, 0x8fe4a6},
-  {0xfbcd, 0x8fe3f1},
-  {0xfbce, 0x8fe3f2},
-  {0xfbcf, 0x8fe4cb},
-  {0xfbd0, 0x8fe4c1},
-  {0xfbd1, 0x8fe4c3},
-  {0xfbd2, 0x8fe4be},
-  {0xfbd3, 0x8ff4ef},
-  {0xfbd4, 0x8fe4c0},
-  {0xfbd5, 0x8fe4c7},
-  {0xfbd6, 0x8fe4bf},
-  {0xfbd7, 0x8fe4e0},
-  {0xfbd8, 0x8fe4de},
-  {0xfbd9, 0x8fe4d1},
-  {0xfbda, 0x8ff4f0},
-  {0xfbdb, 0x8fe4dc},
-  {0xfbdc, 0x8fe4d2},
-  {0xfbdd, 0x8fe4db},
-  {0xfbde, 0x8fe4d4},
-  {0xfbdf, 0x8fe4fa},
-  {0xfbe0, 0x8fe4ef},
-  {0xfbe1, 0x8fe5b3},
-  {0xfbe2, 0x8fe5bf},
-  {0xfbe3, 0x8fe5c9},
-  {0xfbe4, 0x8fe5d0},
-  {0xfbe5, 0x8fe5e2},
-  {0xfbe6, 0x8fe5ea},
-  {0xfbe7, 0x8fe5eb},
-  {0xfbe8, 0x8ff4f1},
-  {0xfbe9, 0x8ff4f2},
-  {0xfbea, 0x8ff4f3},
-  {0xfbeb, 0x8fe6e8},
-  {0xfbec, 0x8fe6ef},
-  {0xfbed, 0x8fe7ac},
-  {0xfbee, 0x8ff4f4},
-  {0xfbef, 0x8fe7ae},
-  {0xfbf0, 0x8ff4f5},
-  {0xfbf1, 0x8fe7b1},
-  {0xfbf2, 0x8ff4f6},
-  {0xfbf3, 0x8fe7b2},
-  {0xfbf4, 0x8fe8b1},
-  {0xfbf5, 0x8fe8b6},
-  {0xfbf6, 0x8ff4f7},
-  {0xfbf7, 0x8ff4f8},
-  {0xfbf8, 0x8fe8dd},
-  {0xfbf9, 0x8ff4f9},
-  {0xfbfa, 0x8ff4fa},
-  {0xfbfb, 0x8fe9d1},
-  {0xfbfc, 0x8ff4fb},
-  {0xfc40, 0x8fe9ed},
-  {0xfc41, 0x8feacd},
-  {0xfc42, 0x8ff4fc},
-  {0xfc43, 0x8feadb},
-  {0xfc44, 0x8feae6},
-  {0xfc45, 0x8feaea},
-  {0xfc46, 0x8feba5},
-  {0xfc47, 0x8febfb},
-  {0xfc48, 0x8febfa},
-  {0xfc49, 0x8ff4fd},
-  {0xfc4a, 0x8fecd6},
-  {0xfc4b, 0x8ff4fe},
-  {0xffff, 0xffff}	/* stop code */
+static struct
+{
+	int			sjis;			/* SJIS UDC (IBM kanji) */
+	int			euc;			/* EUC_JP */
+}			ibmkanji[] =
+
+{
+	{
+		0xfa40, 0x8ff3f3
+	},
+	{
+		0xfa41, 0x8ff3f4
+	},
+	{
+		0xfa42, 0x8ff3f5
+	},
+	{
+		0xfa43, 0x8ff3f6
+	},
+	{
+		0xfa44, 0x8ff3f7
+	},
+	{
+		0xfa45, 0x8ff3f8
+	},
+	{
+		0xfa46, 0x8ff3f9
+	},
+	{
+		0xfa47, 0x8ff3fa
+	},
+	{
+		0xfa48, 0x8ff3fb
+	},
+	{
+		0xfa49, 0x8ff3fc
+	},
+	{
+		0xfa4a, 0x8ff3fd
+	},
+	{
+		0xfa4b, 0x8ff3fe
+	},
+	{
+		0xfa4c, 0x8ff4a1
+	},
+	{
+		0xfa4d, 0x8ff4a2
+	},
+	{
+		0xfa4e, 0x8ff4a3
+	},
+	{
+		0xfa4f, 0x8ff4a4
+	},
+	{
+		0xfa50, 0x8ff4a5
+	},
+	{
+		0xfa51, 0x8ff4a6
+	},
+	{
+		0xfa52, 0x8ff4a7
+	},
+	{
+		0xfa53, 0x8ff4a8
+	},
+	{
+		0xfa54, 0xa2cc
+	},
+	{
+		0xfa55, 0x8fa2c3
+	},
+	{
+		0xfa56, 0x8ff4a9
+	},
+	{
+		0xfa57, 0x8ff4aa
+	},
+	{
+		0xfa58, 0x8ff4ab
+	},
+	{
+		0xfa59, 0x8ff4ac
+	},
+	{
+		0xfa5a, 0x8ff4ad
+	},
+	{
+		0xfa5b, 0xa2e8
+	},
+	{
+		0xfa5c, 0x8fd4e3
+	},
+	{
+		0xfa5d, 0x8fdcdf
+	},
+	{
+		0xfa5e, 0x8fe4e9
+	},
+	{
+		0xfa5f, 0x8fe3f8
+	},
+	{
+		0xfa60, 0x8fd9a1
+	},
+	{
+		0xfa61, 0x8fb1bb
+	},
+	{
+		0xfa62, 0x8ff4ae
+	},
+	{
+		0xfa63, 0x8fc2ad
+	},
+	{
+		0xfa64, 0x8fc3fc
+	},
+	{
+		0xfa65, 0x8fe4d0
+	},
+	{
+		0xfa66, 0x8fc2bf
+	},
+	{
+		0xfa67, 0x8fbcf4
+	},
+	{
+		0xfa68, 0x8fb0a9
+	},
+	{
+		0xfa69, 0x8fb0c8
+	},
+	{
+		0xfa6a, 0x8ff4af
+	},
+	{
+		0xfa6b, 0x8fb0d2
+	},
+	{
+		0xfa6c, 0x8fb0d4
+	},
+	{
+		0xfa6d, 0x8fb0e3
+	},
+	{
+		0xfa6e, 0x8fb0ee
+	},
+	{
+		0xfa6f, 0x8fb1a7
+	},
+	{
+		0xfa70, 0x8fb1a3
+	},
+	{
+		0xfa71, 0x8fb1ac
+	},
+	{
+		0xfa72, 0x8fb1a9
+	},
+	{
+		0xfa73, 0x8fb1be
+	},
+	{
+		0xfa74, 0x8fb1df
+	},
+	{
+		0xfa75, 0x8fb1d8
+	},
+	{
+		0xfa76, 0x8fb1c8
+	},
+	{
+		0xfa77, 0x8fb1d7
+	},
+	{
+		0xfa78, 0x8fb1e3
+	},
+	{
+		0xfa79, 0x8fb1f4
+	},
+	{
+		0xfa7a, 0x8fb1e1
+	},
+	{
+		0xfa7b, 0x8fb2a3
+	},
+	{
+		0xfa7c, 0x8ff4b0
+	},
+	{
+		0xfa7d, 0x8fb2bb
+	},
+	{
+		0xfa7e, 0x8fb2e6
+	},
+	{
+		0xfa80, 0x8fb2ed
+	},
+	{
+		0xfa81, 0x8fb2f5
+	},
+	{
+		0xfa82, 0x8fb2fc
+	},
+	{
+		0xfa83, 0x8ff4b1
+	},
+	{
+		0xfa84, 0x8fb3b5
+	},
+	{
+		0xfa85, 0x8fb3d8
+	},
+	{
+		0xfa86, 0x8fb3db
+	},
+	{
+		0xfa87, 0x8fb3e5
+	},
+	{
+		0xfa88, 0x8fb3ee
+	},
+	{
+		0xfa89, 0x8fb3fb
+	},
+	{
+		0xfa8a, 0x8ff4b2
+	},
+	{
+		0xfa8b, 0x8ff4b3
+	},
+	{
+		0xfa8c, 0x8fb4c0
+	},
+	{
+		0xfa8d, 0x8fb4c7
+	},
+	{
+		0xfa8e, 0x8fb4d0
+	},
+	{
+		0xfa8f, 0x8fb4de
+	},
+	{
+		0xfa90, 0x8ff4b4
+	},
+	{
+		0xfa91, 0x8fb5aa
+	},
+	{
+		0xfa92, 0x8ff4b5
+	},
+	{
+		0xfa93, 0x8fb5af
+	},
+	{
+		0xfa94, 0x8fb5c4
+	},
+	{
+		0xfa95, 0x8fb5e8
+	},
+	{
+		0xfa96, 0x8ff4b6
+	},
+	{
+		0xfa97, 0x8fb7c2
+	},
+	{
+		0xfa98, 0x8fb7e4
+	},
+	{
+		0xfa99, 0x8fb7e8
+	},
+	{
+		0xfa9a, 0x8fb7e7
+	},
+	{
+		0xfa9b, 0x8ff4b7
+	},
+	{
+		0xfa9c, 0x8ff4b8
+	},
+	{
+		0xfa9d, 0x8ff4b9
+	},
+	{
+		0xfa9e, 0x8fb8ce
+	},
+	{
+		0xfa9f, 0x8fb8e1
+	},
+	{
+		0xfaa0, 0x8fb8f5
+	},
+	{
+		0xfaa1, 0x8fb8f7
+	},
+	{
+		0xfaa2, 0x8fb8f8
+	},
+	{
+		0xfaa3, 0x8fb8fc
+	},
+	{
+		0xfaa4, 0x8fb9af
+	},
+	{
+		0xfaa5, 0x8fb9b7
+	},
+	{
+		0xfaa6, 0x8fbabe
+	},
+	{
+		0xfaa7, 0x8fbadb
+	},
+	{
+		0xfaa8, 0x8fcdaa
+	},
+	{
+		0xfaa9, 0x8fbae1
+	},
+	{
+		0xfaaa, 0x8ff4ba
+	},
+	{
+		0xfaab, 0x8fbaeb
+	},
+	{
+		0xfaac, 0x8fbbb3
+	},
+	{
+		0xfaad, 0x8fbbb8
+	},
+	{
+		0xfaae, 0x8ff4bb
+	},
+	{
+		0xfaaf, 0x8fbbca
+	},
+	{
+		0xfab0, 0x8ff4bc
+	},
+	{
+		0xfab1, 0x8ff4bd
+	},
+	{
+		0xfab2, 0x8fbbd0
+	},
+	{
+		0xfab3, 0x8fbbde
+	},
+	{
+		0xfab4, 0x8fbbf4
+	},
+	{
+		0xfab5, 0x8fbbf5
+	},
+	{
+		0xfab6, 0x8fbbf9
+	},
+	{
+		0xfab7, 0x8fbce4
+	},
+	{
+		0xfab8, 0x8fbced
+	},
+	{
+		0xfab9, 0x8fbcfe
+	},
+	{
+		0xfaba, 0x8ff4be
+	},
+	{
+		0xfabb, 0x8fbdc2
+	},
+	{
+		0xfabc, 0x8fbde7
+	},
+	{
+		0xfabd, 0x8ff4bf
+	},
+	{
+		0xfabe, 0x8fbdf0
+	},
+	{
+		0xfabf, 0x8fbeb0
+	},
+	{
+		0xfac0, 0x8fbeac
+	},
+	{
+		0xfac1, 0x8ff4c0
+	},
+	{
+		0xfac2, 0x8fbeb3
+	},
+	{
+		0xfac3, 0x8fbebd
+	},
+	{
+		0xfac4, 0x8fbecd
+	},
+	{
+		0xfac5, 0x8fbec9
+	},
+	{
+		0xfac6, 0x8fbee4
+	},
+	{
+		0xfac7, 0x8fbfa8
+	},
+	{
+		0xfac8, 0x8fbfc9
+	},
+	{
+		0xfac9, 0x8fc0c4
+	},
+	{
+		0xfaca, 0x8fc0e4
+	},
+	{
+		0xfacb, 0x8fc0f4
+	},
+	{
+		0xfacc, 0x8fc1a6
+	},
+	{
+		0xfacd, 0x8ff4c1
+	},
+	{
+		0xface, 0x8fc1f5
+	},
+	{
+		0xfacf, 0x8fc1fc
+	},
+	{
+		0xfad0, 0x8ff4c2
+	},
+	{
+		0xfad1, 0x8fc1f8
+	},
+	{
+		0xfad2, 0x8fc2ab
+	},
+	{
+		0xfad3, 0x8fc2a1
+	},
+	{
+		0xfad4, 0x8fc2a5
+	},
+	{
+		0xfad5, 0x8ff4c3
+	},
+	{
+		0xfad6, 0x8fc2b8
+	},
+	{
+		0xfad7, 0x8fc2ba
+	},
+	{
+		0xfad8, 0x8ff4c4
+	},
+	{
+		0xfad9, 0x8fc2c4
+	},
+	{
+		0xfada, 0x8fc2d2
+	},
+	{
+		0xfadb, 0x8fc2d7
+	},
+	{
+		0xfadc, 0x8fc2db
+	},
+	{
+		0xfadd, 0x8fc2de
+	},
+	{
+		0xfade, 0x8fc2ed
+	},
+	{
+		0xfadf, 0x8fc2f0
+	},
+	{
+		0xfae0, 0x8ff4c5
+	},
+	{
+		0xfae1, 0x8fc3a1
+	},
+	{
+		0xfae2, 0x8fc3b5
+	},
+	{
+		0xfae3, 0x8fc3c9
+	},
+	{
+		0xfae4, 0x8fc3b9
+	},
+	{
+		0xfae5, 0x8ff4c6
+	},
+	{
+		0xfae6, 0x8fc3d8
+	},
+	{
+		0xfae7, 0x8fc3fe
+	},
+	{
+		0xfae8, 0x8ff4c7
+	},
+	{
+		0xfae9, 0x8fc4cc
+	},
+	{
+		0xfaea, 0x8ff4c8
+	},
+	{
+		0xfaeb, 0x8fc4d9
+	},
+	{
+		0xfaec, 0x8fc4ea
+	},
+	{
+		0xfaed, 0x8fc4fd
+	},
+	{
+		0xfaee, 0x8ff4c9
+	},
+	{
+		0xfaef, 0x8fc5a7
+	},
+	{
+		0xfaf0, 0x8fc5b5
+	},
+	{
+		0xfaf1, 0x8fc5b6
+	},
+	{
+		0xfaf2, 0x8ff4ca
+	},
+	{
+		0xfaf3, 0x8fc5d5
+	},
+	{
+		0xfaf4, 0x8fc6b8
+	},
+	{
+		0xfaf5, 0x8fc6d7
+	},
+	{
+		0xfaf6, 0x8fc6e0
+	},
+	{
+		0xfaf7, 0x8fc6ea
+	},
+	{
+		0xfaf8, 0x8fc6e3
+	},
+	{
+		0xfaf9, 0x8fc7a1
+	},
+	{
+		0xfafa, 0x8fc7ab
+	},
+	{
+		0xfafb, 0x8fc7c7
+	},
+	{
+		0xfafc, 0x8fc7c3
+	},
+	{
+		0xfb40, 0x8fc7cb
+	},
+	{
+		0xfb41, 0x8fc7cf
+	},
+	{
+		0xfb42, 0x8fc7d9
+	},
+	{
+		0xfb43, 0x8ff4cb
+	},
+	{
+		0xfb44, 0x8ff4cc
+	},
+	{
+		0xfb45, 0x8fc7e6
+	},
+	{
+		0xfb46, 0x8fc7ee
+	},
+	{
+		0xfb47, 0x8fc7fc
+	},
+	{
+		0xfb48, 0x8fc7eb
+	},
+	{
+		0xfb49, 0x8fc7f0
+	},
+	{
+		0xfb4a, 0x8fc8b1
+	},
+	{
+		0xfb4b, 0x8fc8e5
+	},
+	{
+		0xfb4c, 0x8fc8f8
+	},
+	{
+		0xfb4d, 0x8fc9a6
+	},
+	{
+		0xfb4e, 0x8fc9ab
+	},
+	{
+		0xfb4f, 0x8fc9ad
+	},
+	{
+		0xfb50, 0x8ff4cd
+	},
+	{
+		0xfb51, 0x8fc9ca
+	},
+	{
+		0xfb52, 0x8fc9d3
+	},
+	{
+		0xfb53, 0x8fc9e9
+	},
+	{
+		0xfb54, 0x8fc9e3
+	},
+	{
+		0xfb55, 0x8fc9fc
+	},
+	{
+		0xfb56, 0x8fc9f4
+	},
+	{
+		0xfb57, 0x8fc9f5
+	},
+	{
+		0xfb58, 0x8ff4ce
+	},
+	{
+		0xfb59, 0x8fcab3
+	},
+	{
+		0xfb5a, 0x8fcabd
+	},
+	{
+		0xfb5b, 0x8fcaef
+	},
+	{
+		0xfb5c, 0x8fcaf1
+	},
+	{
+		0xfb5d, 0x8fcbae
+	},
+	{
+		0xfb5e, 0x8ff4cf
+	},
+	{
+		0xfb5f, 0x8fcbca
+	},
+	{
+		0xfb60, 0x8fcbe6
+	},
+	{
+		0xfb61, 0x8fcbea
+	},
+	{
+		0xfb62, 0x8fcbf0
+	},
+	{
+		0xfb63, 0x8fcbf4
+	},
+	{
+		0xfb64, 0x8fcbee
+	},
+	{
+		0xfb65, 0x8fcca5
+	},
+	{
+		0xfb66, 0x8fcbf9
+	},
+	{
+		0xfb67, 0x8fccab
+	},
+	{
+		0xfb68, 0x8fccae
+	},
+	{
+		0xfb69, 0x8fccad
+	},
+	{
+		0xfb6a, 0x8fccb2
+	},
+	{
+		0xfb6b, 0x8fccc2
+	},
+	{
+		0xfb6c, 0x8fccd0
+	},
+	{
+		0xfb6d, 0x8fccd9
+	},
+	{
+		0xfb6e, 0x8ff4d0
+	},
+	{
+		0xfb6f, 0x8fcdbb
+	},
+	{
+		0xfb70, 0x8ff4d1
+	},
+	{
+		0xfb71, 0x8fcebb
+	},
+	{
+		0xfb72, 0x8ff4d2
+	},
+	{
+		0xfb73, 0x8fceba
+	},
+	{
+		0xfb74, 0x8fcec3
+	},
+	{
+		0xfb75, 0x8ff4d3
+	},
+	{
+		0xfb76, 0x8fcef2
+	},
+	{
+		0xfb77, 0x8fb3dd
+	},
+	{
+		0xfb78, 0x8fcfd5
+	},
+	{
+		0xfb79, 0x8fcfe2
+	},
+	{
+		0xfb7a, 0x8fcfe9
+	},
+	{
+		0xfb7b, 0x8fcfed
+	},
+	{
+		0xfb7c, 0x8ff4d4
+	},
+	{
+		0xfb7d, 0x8ff4d5
+	},
+	{
+		0xfb7e, 0x8ff4d6
+	},
+	{
+		0xfb80, 0x8ff4d7
+	},
+	{
+		0xfb81, 0x8fd0e5
+	},
+	{
+		0xfb82, 0x8ff4d8
+	},
+	{
+		0xfb83, 0x8fd0e9
+	},
+	{
+		0xfb84, 0x8fd1e8
+	},
+	{
+		0xfb85, 0x8ff4d9
+	},
+	{
+		0xfb86, 0x8ff4da
+	},
+	{
+		0xfb87, 0x8fd1ec
+	},
+	{
+		0xfb88, 0x8fd2bb
+	},
+	{
+		0xfb89, 0x8ff4db
+	},
+	{
+		0xfb8a, 0x8fd3e1
+	},
+	{
+		0xfb8b, 0x8fd3e8
+	},
+	{
+		0xfb8c, 0x8fd4a7
+	},
+	{
+		0xfb8d, 0x8ff4dc
+	},
+	{
+		0xfb8e, 0x8ff4dd
+	},
+	{
+		0xfb8f, 0x8fd4d4
+	},
+	{
+		0xfb90, 0x8fd4f2
+	},
+	{
+		0xfb91, 0x8fd5ae
+	},
+	{
+		0xfb92, 0x8ff4de
+	},
+	{
+		0xfb93, 0x8fd7de
+	},
+	{
+		0xfb94, 0x8ff4df
+	},
+	{
+		0xfb95, 0x8fd8a2
+	},
+	{
+		0xfb96, 0x8fd8b7
+	},
+	{
+		0xfb97, 0x8fd8c1
+	},
+	{
+		0xfb98, 0x8fd8d1
+	},
+	{
+		0xfb99, 0x8fd8f4
+	},
+	{
+		0xfb9a, 0x8fd9c6
+	},
+	{
+		0xfb9b, 0x8fd9c8
+	},
+	{
+		0xfb9c, 0x8fd9d1
+	},
+	{
+		0xfb9d, 0x8ff4e0
+	},
+	{
+		0xfb9e, 0x8ff4e1
+	},
+	{
+		0xfb9f, 0x8ff4e2
+	},
+	{
+		0xfba0, 0x8ff4e3
+	},
+	{
+		0xfba1, 0x8ff4e4
+	},
+	{
+		0xfba2, 0x8fdcd3
+	},
+	{
+		0xfba3, 0x8fddc8
+	},
+	{
+		0xfba4, 0x8fddd4
+	},
+	{
+		0xfba5, 0x8fddea
+	},
+	{
+		0xfba6, 0x8fddfa
+	},
+	{
+		0xfba7, 0x8fdea4
+	},
+	{
+		0xfba8, 0x8fdeb0
+	},
+	{
+		0xfba9, 0x8ff4e5
+	},
+	{
+		0xfbaa, 0x8fdeb5
+	},
+	{
+		0xfbab, 0x8fdecb
+	},
+	{
+		0xfbac, 0x8ff4e6
+	},
+	{
+		0xfbad, 0x8fdfb9
+	},
+	{
+		0xfbae, 0x8ff4e7
+	},
+	{
+		0xfbaf, 0x8fdfc3
+	},
+	{
+		0xfbb0, 0x8ff4e8
+	},
+	{
+		0xfbb1, 0x8ff4e9
+	},
+	{
+		0xfbb2, 0x8fe0d9
+	},
+	{
+		0xfbb3, 0x8ff4ea
+	},
+	{
+		0xfbb4, 0x8ff4eb
+	},
+	{
+		0xfbb5, 0x8fe1e2
+	},
+	{
+		0xfbb6, 0x8ff4ec
+	},
+	{
+		0xfbb7, 0x8ff4ed
+	},
+	{
+		0xfbb8, 0x8ff4ee
+	},
+	{
+		0xfbb9, 0x8fe2c7
+	},
+	{
+		0xfbba, 0x8fe3a8
+	},
+	{
+		0xfbbb, 0x8fe3a6
+	},
+	{
+		0xfbbc, 0x8fe3a9
+	},
+	{
+		0xfbbd, 0x8fe3af
+	},
+	{
+		0xfbbe, 0x8fe3b0
+	},
+	{
+		0xfbbf, 0x8fe3aa
+	},
+	{
+		0xfbc0, 0x8fe3ab
+	},
+	{
+		0xfbc1, 0x8fe3bc
+	},
+	{
+		0xfbc2, 0x8fe3c1
+	},
+	{
+		0xfbc3, 0x8fe3bf
+	},
+	{
+		0xfbc4, 0x8fe3d5
+	},
+	{
+		0xfbc5, 0x8fe3d8
+	},
+	{
+		0xfbc6, 0x8fe3d6
+	},
+	{
+		0xfbc7, 0x8fe3df
+	},
+	{
+		0xfbc8, 0x8fe3e3
+	},
+	{
+		0xfbc9, 0x8fe3e1
+	},
+	{
+		0xfbca, 0x8fe3d4
+	},
+	{
+		0xfbcb, 0x8fe3e9
+	},
+	{
+		0xfbcc, 0x8fe4a6
+	},
+	{
+		0xfbcd, 0x8fe3f1
+	},
+	{
+		0xfbce, 0x8fe3f2
+	},
+	{
+		0xfbcf, 0x8fe4cb
+	},
+	{
+		0xfbd0, 0x8fe4c1
+	},
+	{
+		0xfbd1, 0x8fe4c3
+	},
+	{
+		0xfbd2, 0x8fe4be
+	},
+	{
+		0xfbd3, 0x8ff4ef
+	},
+	{
+		0xfbd4, 0x8fe4c0
+	},
+	{
+		0xfbd5, 0x8fe4c7
+	},
+	{
+		0xfbd6, 0x8fe4bf
+	},
+	{
+		0xfbd7, 0x8fe4e0
+	},
+	{
+		0xfbd8, 0x8fe4de
+	},
+	{
+		0xfbd9, 0x8fe4d1
+	},
+	{
+		0xfbda, 0x8ff4f0
+	},
+	{
+		0xfbdb, 0x8fe4dc
+	},
+	{
+		0xfbdc, 0x8fe4d2
+	},
+	{
+		0xfbdd, 0x8fe4db
+	},
+	{
+		0xfbde, 0x8fe4d4
+	},
+	{
+		0xfbdf, 0x8fe4fa
+	},
+	{
+		0xfbe0, 0x8fe4ef
+	},
+	{
+		0xfbe1, 0x8fe5b3
+	},
+	{
+		0xfbe2, 0x8fe5bf
+	},
+	{
+		0xfbe3, 0x8fe5c9
+	},
+	{
+		0xfbe4, 0x8fe5d0
+	},
+	{
+		0xfbe5, 0x8fe5e2
+	},
+	{
+		0xfbe6, 0x8fe5ea
+	},
+	{
+		0xfbe7, 0x8fe5eb
+	},
+	{
+		0xfbe8, 0x8ff4f1
+	},
+	{
+		0xfbe9, 0x8ff4f2
+	},
+	{
+		0xfbea, 0x8ff4f3
+	},
+	{
+		0xfbeb, 0x8fe6e8
+	},
+	{
+		0xfbec, 0x8fe6ef
+	},
+	{
+		0xfbed, 0x8fe7ac
+	},
+	{
+		0xfbee, 0x8ff4f4
+	},
+	{
+		0xfbef, 0x8fe7ae
+	},
+	{
+		0xfbf0, 0x8ff4f5
+	},
+	{
+		0xfbf1, 0x8fe7b1
+	},
+	{
+		0xfbf2, 0x8ff4f6
+	},
+	{
+		0xfbf3, 0x8fe7b2
+	},
+	{
+		0xfbf4, 0x8fe8b1
+	},
+	{
+		0xfbf5, 0x8fe8b6
+	},
+	{
+		0xfbf6, 0x8ff4f7
+	},
+	{
+		0xfbf7, 0x8ff4f8
+	},
+	{
+		0xfbf8, 0x8fe8dd
+	},
+	{
+		0xfbf9, 0x8ff4f9
+	},
+	{
+		0xfbfa, 0x8ff4fa
+	},
+	{
+		0xfbfb, 0x8fe9d1
+	},
+	{
+		0xfbfc, 0x8ff4fb
+	},
+	{
+		0xfc40, 0x8fe9ed
+	},
+	{
+		0xfc41, 0x8feacd
+	},
+	{
+		0xfc42, 0x8ff4fc
+	},
+	{
+		0xfc43, 0x8feadb
+	},
+	{
+		0xfc44, 0x8feae6
+	},
+	{
+		0xfc45, 0x8feaea
+	},
+	{
+		0xfc46, 0x8feba5
+	},
+	{
+		0xfc47, 0x8febfb
+	},
+	{
+		0xfc48, 0x8febfa
+	},
+	{
+		0xfc49, 0x8ff4fd
+	},
+	{
+		0xfc4a, 0x8fecd6
+	},
+	{
+		0xfc4b, 0x8ff4fe
+	},
+	{
+		0xffff, 0xffff
+	}							/* stop code */
 };
 
 /*
@@ -461,8 +1242,10 @@ sjis2mic(unsigned char *sjis, unsigned char *p, int len)
 		}
 		else if (c1 > 0x7f)
 		{
-			/* JIS X0208, X0212, user defined extended
-			   characters */
+
+			/*
+			 * JIS X0208, X0212, user defined extended characters
+			 */
 			c2 = *sjis++;
 			k = (c1 << 8) + c2;
 
@@ -479,15 +1262,15 @@ sjis2mic(unsigned char *sjis, unsigned char *p, int len)
 				/* NEC sentei IBM kanji */
 				*p++ = LC_JISX0208;
 				*p++ = PGEUCALTCODE >> 8;
-			        *p++ = PGEUCALTCODE & 0xff;
+				*p++ = PGEUCALTCODE & 0xff;
 			}
 			else if (k >= 0xf040 && k < 0xf540)
 			{
-			         /* UDC1
-				  * mapping to X0208 85 ku - 94 ku
-				  * JIS code 0x7521 - 0x7e7e
-				  * EUC 0xf5a1 - 0xfefe
-				  */
+
+				/*
+				 * UDC1 mapping to X0208 85 ku - 94 ku JIS code 0x7521 -
+				 * 0x7e7e EUC 0xf5a1 - 0xfefe
+				 */
 				len -= 2;
 				*p++ = LC_JISX0208;
 				c1 -= 0x6f;
@@ -496,11 +1279,11 @@ sjis2mic(unsigned char *sjis, unsigned char *p, int len)
 			}
 			else if (k >= 0xf540 && k < 0xfa40)
 			{
-			         /* UDC2
-				  * mapping to X0212 85 ku - 94 ku
-				  * JIS code 0x7521 - 0x7e7e
-				  * EUC 0x8ff5a1 - 0x8ffefe
-				  */
+
+				/*
+				 * UDC2 mapping to X0212 85 ku - 94 ku JIS code 0x7521 -
+				 * 0x7e7e EUC 0x8ff5a1 - 0x8ffefe
+				 */
 				len -= 2;
 				*p++ = LC_JISX0212;
 				c1 -= 0x74;
@@ -509,28 +1292,36 @@ sjis2mic(unsigned char *sjis, unsigned char *p, int len)
 			}
 			else if (k >= 0xfa40)
 			{
-				/* mapping IBM kanji to X0208 and X0212
+
+				/*
+				 * mapping IBM kanji to X0208 and X0212
 				 *
 				 */
-				int i,k2;
+				int			i,
+							k2;
+
 				len -= 2;
-				for (i=0;;i++) {
-				  k2 = ibmkanji[i].sjis;
-				  if (k2 == 0xffff)
-				      break;
-				  if (k2 == k) {
-				    k = ibmkanji[i].euc;
-				    if (k >= 0x8f0000)
-				      {
-				      *p++ = LC_JISX0212;
-				      *p++ = 0x80 | ((k & 0xff00) >> 8);
-				      *p++ = 0x80 | (k & 0xff);
-				    } else {
-				      *p++ = LC_JISX0208;
-				      *p++ = 0x80 | (k >> 8);
-				      *p++ = 0x80 | (k & 0xff);
-				    }
-				  }
+				for (i = 0;; i++)
+				{
+					k2 = ibmkanji[i].sjis;
+					if (k2 == 0xffff)
+						break;
+					if (k2 == k)
+					{
+						k = ibmkanji[i].euc;
+						if (k >= 0x8f0000)
+						{
+							*p++ = LC_JISX0212;
+							*p++ = 0x80 | ((k & 0xff00) >> 8);
+							*p++ = 0x80 | (k & 0xff);
+						}
+						else
+						{
+							*p++ = LC_JISX0208;
+							*p++ = 0x80 | (k >> 8);
+							*p++ = 0x80 | (k & 0xff);
+						}
+					}
 				}
 			}
 		}
@@ -571,14 +1362,14 @@ mic2sjis(unsigned char *mic, unsigned char *p, int len)
 				*p++ = ((c1 - 0xa1) >> 1) + ((c1 < 0xdf) ? 0x81 : 0xc1) + 0x6f;
 			}
 			else
-			{
 				*p++ = ((c1 - 0xa1) >> 1) + ((c1 < 0xdf) ? 0x81 : 0xc1);
-			}
 			*p++ = c2 - ((c1 & 1) ? ((c2 < 0xe0) ? 0x61 : 0x60) : 2);
 		}
 		else if (c1 == LC_JISX0212)
 		{
-			int i,k2;
+			int			i,
+						k2;
+
 			c1 = *mic++;
 			c2 = *mic++;
 			k = c1 << 8 | c2;
@@ -591,21 +1382,24 @@ mic2sjis(unsigned char *mic, unsigned char *p, int len)
 			}
 			else
 			{
-			  /* IBM kanji */
-			  for (i=0;;i++) {
-			    k2 = ibmkanji[i].euc & 0xffff;
-			    if (k2 == 0xffff) {
-			      *p++ = PGSJISALTCODE >> 8;
-			      *p++ = PGSJISALTCODE & 0xff;
-			      break;
-			    }
-			    if (k2 == k) {
-			      k = ibmkanji[i].sjis;
-			      *p++ = k >> 8;
-			      *p++ = k & 0xff;
-			      break;
-			    }
-			  }
+				/* IBM kanji */
+				for (i = 0;; i++)
+				{
+					k2 = ibmkanji[i].euc & 0xffff;
+					if (k2 == 0xffff)
+					{
+						*p++ = PGSJISALTCODE >> 8;
+						*p++ = PGSJISALTCODE & 0xff;
+						break;
+					}
+					if (k2 == k)
+					{
+						k = ibmkanji[i].sjis;
+						*p++ = k >> 8;
+						*p++ = k & 0xff;
+						break;
+					}
+				}
 			}
 		}
 		else if (c1 > 0x7f)
@@ -1081,6 +1875,7 @@ mic2latin4(unsigned char *mic, unsigned char *p, int len)
 {
 	mic2latin(mic, p, len, LC_ISO8859_4);
 }
+
 #ifdef NOT_USED
 static void
 latin52mic(unsigned char *l, unsigned char *p, int len)
@@ -1456,6 +2251,7 @@ mic2win1250(unsigned char *mic, unsigned char *p, int len)
 
 	mic2latin_with_table(mic, p, len, LC_ISO8859_2, iso88592_2_win1250);
 }
+
 /*-----------------------------------------------------------------*/
 
 pg_encoding_conv_tbl pg_conv_tbl[] = {
@@ -1483,45 +2279,63 @@ pg_encoding_conv_tbl pg_conv_tbl[] = {
 #ifdef DEBUGMAIN
 #include "utils/mcxt.h"
 /*
- *  testing for sjis2mic() and mic2sjis()
+ *	testing for sjis2mic() and mic2sjis()
  */
 
-int main()
+int
+main()
 {
-  unsigned char eucbuf[1024];
-  unsigned char sjisbuf[1024];
-  unsigned char sjis[] = {0x81, 0x40, 0xa1, 0xf0, 0x40, 0xf0, 0x9e, 0xf5, 0x40, 0xfa, 0x40, 0xfa, 0x54, 0xfa, 0x7b, 0x00};
-
-  int i;
-
-  sjis2mic(sjis, eucbuf, 1024);
-  for (i=0;i<1024;i++) {
-    if (eucbuf[i]) {
-      printf("%02x ", eucbuf[i]);
-    } else {
-      printf("\n");
-      break;
-    }
-  }
-
-  mic2sjis(eucbuf, sjisbuf, 1024);
-  for (i=0;i<1024;i++) {
-    if (sjisbuf[i]) {
-      printf("%02x ", sjisbuf[i]);
-    } else {
-      printf("\n");
-      break;
-    }
-  }
-
-  return(0);
+	unsigned char eucbuf[1024];
+	unsigned char sjisbuf[1024];
+	unsigned char sjis[] = {0x81, 0x40, 0xa1, 0xf0, 0x40, 0xf0, 0x9e, 0xf5, 0x40, 0xfa, 0x40, 0xfa, 0x54, 0xfa, 0x7b, 0x00};
+
+	int			i;
+
+	sjis2mic(sjis, eucbuf, 1024);
+	for (i = 0; i < 1024; i++)
+	{
+		if (eucbuf[i])
+			printf("%02x ", eucbuf[i]);
+		else
+		{
+			printf("\n");
+			break;
+		}
+	}
+
+	mic2sjis(eucbuf, sjisbuf, 1024);
+	for (i = 0; i < 1024; i++)
+	{
+		if (sjisbuf[i])
+			printf("%02x ", sjisbuf[i]);
+		else
+		{
+			printf("\n");
+			break;
+		}
+	}
+
+	return (0);
 }
 
-void elog(int lev, const char *fmt,...) {};
+void
+elog(int lev, const char *fmt,...)
+{
+};
 MemoryContext CurrentMemoryContext;
-Pointer MemoryContextAlloc(MemoryContext context, Size size) {};
-Pointer MemoryContextRealloc(MemoryContext context,
+Pointer
+MemoryContextAlloc(MemoryContext context, Size size)
+{
+};
+Pointer
+MemoryContextRealloc(MemoryContext context,
 					 Pointer pointer,
-					 Size size) {};
-void MemoryContextFree(MemoryContext context, Pointer pointer) {};
+					 Size size)
+{
+};
+void
+MemoryContextFree(MemoryContext context, Pointer pointer)
+{
+};
+
 #endif
diff --git a/src/backend/utils/mb/wchar.c b/src/backend/utils/mb/wchar.c
index e1a665ca847bf728c7b65c859e8acb4acf07b7f4..bc576a1789bdedd2fd6b8c85eb7768d6458b578c 100644
--- a/src/backend/utils/mb/wchar.c
+++ b/src/backend/utils/mb/wchar.c
@@ -1,7 +1,7 @@
 /*
  * conversion functions between pg_wchar and multi-byte streams.
  * Tatsuo Ishii
- * $Id: wchar.c,v 1.10 2000/01/25 02:12:27 ishii Exp $
+ * $Id: wchar.c,v 1.11 2000/04/12 17:16:06 momjian Exp $
  *
  * WIN1250 client encoding updated by Pavel Behal
  *
@@ -454,7 +454,7 @@ pg_wchar_tbl pg_wchar_table[] = {
 	{pg_latin12wchar_with_len, pg_latin1_mblen},		/* 31 */
 	{0, pg_sjis_mblen},			/* 32 */
 	{0, pg_big5_mblen},			/* 33 */
-	{pg_latin12wchar_with_len, pg_latin1_mblen}		/* 34 */
+	{pg_latin12wchar_with_len, pg_latin1_mblen} /* 34 */
 };
 
 /* returns the byte length of a word for mule internal code */
diff --git a/src/backend/utils/misc/database.c b/src/backend/utils/misc/database.c
index 05b32ac62e7acfa01b5420f855db0a55af4ca18f..64347f00fee7442ed281a6a39849a061b73fccfb 100644
--- a/src/backend/utils/misc/database.c
+++ b/src/backend/utils/misc/database.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.36 2000/03/08 01:46:47 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.37 2000/04/12 17:16:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -42,8 +42,8 @@ ExpandDatabasePath(const char *dbpath)
 	const char *cp;
 	int			len;
 
-    AssertArg(dbpath);
-    Assert(DataDir);
+	AssertArg(dbpath);
+	Assert(DataDir);
 
 	if (strlen(dbpath) >= MAXPGPATH)
 		return NULL;			/* ain't gonna fit nohow */
@@ -55,7 +55,7 @@ ExpandDatabasePath(const char *dbpath)
 		cp = strrchr(dbpath, SEP_CHAR);
 		len = cp - dbpath;
 		strncpy(buf, dbpath, len);
-		snprintf(&buf[len], MAXPGPATH-len, "%cbase%c%s",
+		snprintf(&buf[len], MAXPGPATH - len, "%cbase%c%s",
 				 SEP_CHAR, SEP_CHAR, (cp + 1));
 #else
 		return NULL;
@@ -64,7 +64,7 @@ ExpandDatabasePath(const char *dbpath)
 	/* path delimiter somewhere? then has leading environment variable */
 	else if ((cp = strchr(dbpath, SEP_CHAR)) != NULL)
 	{
-        const char	   *envvar;
+		const char *envvar;
 
 		len = cp - dbpath;
 		strncpy(buf, dbpath, len);
@@ -83,28 +83,33 @@ ExpandDatabasePath(const char *dbpath)
 				 DataDir, SEP_CHAR, SEP_CHAR, dbpath);
 	}
 
-    /* check for illegal characters in dbpath 
-     * these should really throw an error, shouldn't they? or else all callers 
-     * need to test for NULL */
-    for(cp = buf; *cp; cp++)
-    {
-        /* The following characters will not be allowed anywhere in the database
-           path. (Do not include the slash  or '.' here.) */
-        char illegal_dbpath_chars[] =
-            "\001\002\003\004\005\006\007\010"
-            "\011\012\013\014\015\016\017\020"
-            "\021\022\023\024\025\026\027\030"
-            "\031\032\033\034\035\036\037"
-            "'`";
-
-        const char *cx;
-        for (cx = illegal_dbpath_chars; *cx; cx++)
-            if (*cp == *cx)
-                return NULL;
-       /* don't allow access to parent dirs */
-       if (strncmp(cp, "/../", 4) == 0 )
-               return NULL ; 
-    }
+	/*
+	 * check for illegal characters in dbpath these should really throw an
+	 * error, shouldn't they? or else all callers need to test for NULL
+	 */
+	for (cp = buf; *cp; cp++)
+	{
+
+		/*
+		 * The following characters will not be allowed anywhere in the
+		 * database path. (Do not include the slash  or '.' here.)
+		 */
+		char		illegal_dbpath_chars[] =
+		"\001\002\003\004\005\006\007\010"
+		"\011\012\013\014\015\016\017\020"
+		"\021\022\023\024\025\026\027\030"
+		"\031\032\033\034\035\036\037"
+		"'`";
+
+		const char *cx;
+
+		for (cx = illegal_dbpath_chars; *cx; cx++)
+			if (*cp == *cx)
+				return NULL;
+		/* don't allow access to parent dirs */
+		if (strncmp(cp, "/../", 4) == 0)
+			return NULL;
+	}
 
 	return pstrdup(buf);
 }	/* ExpandDatabasePath() */
@@ -197,18 +202,18 @@ GetRawDatabaseInfo(const char *name, Oid *db_id, char *path)
 			 * the log relation by hand, too.  Instead we take the
 			 * conservative assumption that if someone tried to delete it,
 			 * it's gone.  The other side of the coin is that we might
-			 * accept a tuple that was stored and never committed.  All in
-			 * all, this code is pretty shaky.  We will cross-check our
+			 * accept a tuple that was stored and never committed.	All in
+			 * all, this code is pretty shaky.	We will cross-check our
 			 * result in ReverifyMyDatabase() in postinit.c.
 			 *
-			 * NOTE: if a bogus tuple in pg_database prevents connection
-			 * to a valid database, a fix is to connect to another database
-			 * and do "select * from pg_database".  That should cause
+			 * NOTE: if a bogus tuple in pg_database prevents connection to a
+			 * valid database, a fix is to connect to another database and
+			 * do "select * from pg_database".	That should cause
 			 * committed and dead tuples to be marked with correct states.
 			 *
 			 * XXX wouldn't it be better to let new backends read the
-			 * database OID from a flat file, handled the same way
-			 * we handle the password relation?
+			 * database OID from a flat file, handled the same way we
+			 * handle the password relation?
 			 */
 			if (TransactionIdIsValid((TransactionId) tup.t_data->t_xmax))
 				continue;
diff --git a/src/backend/utils/misc/trace.c b/src/backend/utils/misc/trace.c
index b2ff231d03859c0a015bd348c87555993fb1a7da..69634e1f3f4df22c0a117a6d8ed22be45d0cd79a 100644
--- a/src/backend/utils/misc/trace.c
+++ b/src/backend/utils/misc/trace.c
@@ -50,7 +50,8 @@
  * Trace option names, must match the constants in trace_opts[].
  */
 static char *opt_names[] = {
-	"all",						/* 0=trace some, 1=trace all, -1=trace none */
+	"all",						/* 0=trace some, 1=trace all, -1=trace
+								 * none */
 	"verbose",
 	"query",
 	"plan",
@@ -78,7 +79,7 @@ static char *opt_names[] = {
 	"hostlookup",				/* enable hostname lookup in ps_status */
 	"showportnumber",			/* show port number in ps_status */
 
-	/* NUM_PG_OPTIONS */		/* must be the last item of enum */
+	/* NUM_PG_OPTIONS *//* must be the last item of enum */
 };
 
 /*
@@ -95,8 +96,10 @@ tprintf(int flag, const char *fmt,...)
 {
 	va_list		ap;
 	char		line[TRACEMSG_MAXLEN + TIMESTAMP_SIZE + 1];
+
 #ifdef USE_SYSLOG
 	int			log_level;
+
 #endif
 
 	if ((flag == TRACE_ALL) || (pg_options[TRACE_ALL] > 0))
@@ -161,6 +164,7 @@ tprintf1(const char *fmt,...)
 
 	return 1;
 }
+
 #endif
 
 /*
@@ -212,6 +216,7 @@ write_syslog(int level, char *line)
 		syslog(level, "%s", line);
 	}
 }
+
 #endif
 
 #ifdef ELOG_TIMESTAMPS
@@ -222,7 +227,7 @@ char *
 tprintf_timestamp()
 {
 	struct timeval tv;
-	struct timezone tz = { 0, 0 };
+	struct timezone tz = {0, 0};
 	struct tm  *time;
 	time_t		tm;
 	static char timestamp[32],
@@ -236,10 +241,11 @@ tprintf_timestamp()
 	sprintf(timestamp, "%02d%02d%02d.%02d:%02d:%02d.%03d %7s ",
 			time->tm_year % 100, time->tm_mon + 1, time->tm_mday,
 			time->tm_hour, time->tm_min, time->tm_sec,
-			(int) (tv.tv_usec/1000), pid);
+			(int) (tv.tv_usec / 1000), pid);
 
 	return timestamp;
 }
+
 #endif
 
 #ifdef NOT_USED
@@ -260,6 +266,7 @@ set_option_flag(int flag, int value)
 	pg_options[flag] = value;
 	return value;
 }
+
 #endif
 
 /*
@@ -409,13 +416,12 @@ read_pg_options(SIGNAL_ARGS)
 void
 show_options(void)
 {
-	int		i;
+	int			i;
 
-	for (i=0; i<NUM_PG_OPTIONS; i++) {
+	for (i = 0; i < NUM_PG_OPTIONS; i++)
 		elog(NOTICE, "%s=%d", opt_names[i], pg_options[i]);
-	}
 }
-  
+
 /*
  * Local variables:
  *	tab-width: 4
diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c
index 5220ec2d412f3bf16b852a6e0b970943e6daf990..4bc96c5a2aa61e667761c11b99a3c258e84cb558 100644
--- a/src/backend/utils/mmgr/aset.c
+++ b/src/backend/utils/mmgr/aset.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.25 2000/03/08 23:42:58 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.26 2000/04/12 17:16:09 momjian Exp $
  *
  * NOTE:
  *	This is a new (Feb. 05, 1999) implementation of the allocation set
@@ -43,7 +43,7 @@
 /*--------------------
  * Chunk freelist k holds chunks of size 1 << (k + ALLOC_MINBITS),
  * for k = 0 .. ALLOCSET_NUM_FREELISTS-2.
- * The last freelist holds all larger free chunks.  Those chunks come in
+ * The last freelist holds all larger free chunks.	Those chunks come in
  * varying sizes depending on the request size, whereas smaller chunks are
  * coerced to powers of 2 to improve their "recyclability".
  *
@@ -261,9 +261,9 @@ AllocSetAlloc(AllocSet set, Size size)
 	Assert(chunk_size >= size);
 
 	/*
-	 * If there is enough room in the active allocation block, *and*
-	 * the chunk is less than ALLOC_BIGCHUNK_LIMIT, put the chunk
-	 * into the active allocation block.
+	 * If there is enough room in the active allocation block, *and* the
+	 * chunk is less than ALLOC_BIGCHUNK_LIMIT, put the chunk into the
+	 * active allocation block.
 	 */
 	if ((block = set->blocks) != NULL)
 	{
@@ -400,8 +400,10 @@ AllocSetFree(AllocSet set, AllocPointer pointer)
 
 	if (chunk->size >= ALLOC_BIGCHUNK_LIMIT)
 	{
-		/* Big chunks are certain to have been allocated as single-chunk
-		 * blocks.  Find the containing block and return it to malloc().
+
+		/*
+		 * Big chunks are certain to have been allocated as single-chunk
+		 * blocks.	Find the containing block and return it to malloc().
 		 */
 		AllocBlock	block = set->blocks;
 		AllocBlock	prevblock = NULL;
@@ -471,10 +473,12 @@ AllocSetRealloc(AllocSet set, AllocPointer pointer, Size size)
 
 	if (oldsize >= ALLOC_BIGCHUNK_LIMIT)
 	{
+
 		/*
-		 * If the chunk is already >= bigchunk limit, then it must have been
-		 * allocated as a single-chunk block.  Find the containing block and
-		 * use realloc() to make it bigger with minimum space wastage.
+		 * If the chunk is already >= bigchunk limit, then it must have
+		 * been allocated as a single-chunk block.	Find the containing
+		 * block and use realloc() to make it bigger with minimum space
+		 * wastage.
 		 */
 		AllocChunk	chunk = AllocPointerGetChunk(pointer);
 		AllocBlock	block = set->blocks;
diff --git a/src/backend/utils/mmgr/oset.c b/src/backend/utils/mmgr/oset.c
index 0bb046653f5023e9cbe5dfb6e01872dd765af7a8..86487ab07d328303d5f6a307258324e6682efa6b 100644
--- a/src/backend/utils/mmgr/oset.c
+++ b/src/backend/utils/mmgr/oset.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/mmgr/Attic/oset.c,v 1.16 2000/01/26 05:57:31 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/mmgr/Attic/oset.c,v 1.17 2000/04/12 17:16:10 momjian Exp $
  *
  * NOTE
  *	  XXX This is a preliminary implementation which lacks fail-fast
@@ -59,6 +59,7 @@ OrderedSetContains(OrderedSet set, OrderedElem elem)
 {
 	return (bool) (elem->set == set && (elem->next || elem->prev));
 }
+
 #endif
 
 /*
diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c
index 83bb7b099a789cb885b5f5f64e54c7a7345770c9..71e94b7096d3f612630601f2453602004b6c950b 100644
--- a/src/backend/utils/mmgr/portalmem.c
+++ b/src/backend/utils/mmgr/portalmem.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.35 2000/03/17 02:36:29 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.36 2000/04/12 17:16:10 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -411,8 +411,8 @@ PortalNameIsSpecial(char *pname)
 {
 	if (strcmp(pname, VACPNAME) == 0)
 		return true;
-	if (strcmp(pname, TRUNCPNAME) == 0) 
-	        return true;
+	if (strcmp(pname, TRUNCPNAME) == 0)
+		return true;
 	return false;
 }
 
diff --git a/src/backend/utils/sort/logtape.c b/src/backend/utils/sort/logtape.c
index e6bfbf80b426ea09f05749ccc8285d105eb6f2c3..654bae71be4c4585d59b986bc980f64b86fad2ba 100644
--- a/src/backend/utils/sort/logtape.c
+++ b/src/backend/utils/sort/logtape.c
@@ -7,14 +7,14 @@
  * tuplesort.c).  Merging is an ideal algorithm for tape devices, but if
  * we implement it on disk by creating a separate file for each "tape",
  * there is an annoying problem: the peak space usage is at least twice
- * the volume of actual data to be sorted.  (This must be so because each
+ * the volume of actual data to be sorted.	(This must be so because each
  * datum will appear in both the input and output tapes of the final
- * merge pass.  For seven-tape polyphase merge, which is otherwise a
+ * merge pass.	For seven-tape polyphase merge, which is otherwise a
  * pretty good algorithm, peak usage is more like 4x actual data volume.)
  *
  * We can work around this problem by recognizing that any one tape
  * dataset (with the possible exception of the final output) is written
- * and read exactly once in a perfectly sequential manner.  Therefore,
+ * and read exactly once in a perfectly sequential manner.	Therefore,
  * a datum once read will not be required again, and we can recycle its
  * space for use by the new tape dataset(s) being generated.  In this way,
  * the total space usage is essentially just the actual data volume, plus
@@ -59,12 +59,12 @@
  * is aborted by elog(ERROR).  To avoid confusion, the caller should take
  * care that all calls for a single LogicalTapeSet are made in the same
  * palloc context.
- * 
+ *
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/sort/logtape.c,v 1.4 2000/03/17 02:36:30 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/sort/logtape.c,v 1.5 2000/04/12 17:16:11 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -78,7 +78,7 @@
  * Block indexes are "long"s, so we can fit this many per indirect block.
  * NB: we assume this is an exact fit!
  */
-#define BLOCKS_PER_INDIR_BLOCK  ((int) (BLCKSZ / sizeof(long)))
+#define BLOCKS_PER_INDIR_BLOCK	((int) (BLCKSZ / sizeof(long)))
 
 /*
  * We use a struct like this for each active indirection level of each
@@ -91,8 +91,10 @@
 typedef struct IndirectBlock
 {
 	int			nextSlot;		/* next pointer slot to write or read */
-	struct IndirectBlock *nextup; /* parent indirect level, or NULL if top */
-	long		ptrs[BLOCKS_PER_INDIR_BLOCK]; /* indexes of contained blocks */
+	struct IndirectBlock *nextup;		/* parent indirect level, or NULL
+										 * if top */
+	long		ptrs[BLOCKS_PER_INDIR_BLOCK];	/* indexes of contained
+												 * blocks */
 } IndirectBlock;
 
 /*
@@ -105,23 +107,26 @@ typedef struct LogicalTape
 {
 	IndirectBlock *indirect;	/* bottom of my indirect-block hierarchy */
 	bool		writing;		/* T while in write phase */
-	bool		frozen;			/* T if blocks should not be freed when read */
+	bool		frozen;			/* T if blocks should not be freed when
+								 * read */
 	bool		dirty;			/* does buffer need to be written? */
+
 	/*
 	 * The total data volume in the logical tape is numFullBlocks * BLCKSZ
-	 * + lastBlockBytes.  BUT: we do not update lastBlockBytes during writing,
-	 * only at completion of a write phase.
+	 * + lastBlockBytes.  BUT: we do not update lastBlockBytes during
+	 * writing, only at completion of a write phase.
 	 */
 	long		numFullBlocks;	/* number of complete blocks in log tape */
-	int			lastBlockBytes;	/* valid bytes in last (incomplete) block */
+	int			lastBlockBytes; /* valid bytes in last (incomplete) block */
+
 	/*
 	 * Buffer for current data block.  Note we don't bother to store the
 	 * actual file block number of the data block (during the write phase
-	 * it hasn't been assigned yet, and during read we don't care anymore).
-	 * But we do need the relative block number so we can detect end-of-tape
-	 * while reading.
+	 * it hasn't been assigned yet, and during read we don't care
+	 * anymore). But we do need the relative block number so we can detect
+	 * end-of-tape while reading.
 	 */
-	long		curBlockNumber;	/* this block's logical blk# within tape */
+	long		curBlockNumber; /* this block's logical blk# within tape */
 	int			pos;			/* next read/write position in buffer */
 	int			nbytes;			/* total # of valid bytes in buffer */
 	char		buffer[BLCKSZ];
@@ -135,17 +140,21 @@ typedef struct LogicalTape
  */
 struct LogicalTapeSet
 {
-	BufFile	   *pfile;			/* underlying file for whole tape set */
+	BufFile    *pfile;			/* underlying file for whole tape set */
 	long		nFileBlocks;	/* # of blocks used in underlying file */
+
 	/*
-	 * We store the numbers of recycled-and-available blocks in freeBlocks[].
-	 * When there are no such blocks, we extend the underlying file.  Note
-	 * that the block numbers in freeBlocks are always in *decreasing* order,
-	 * so that removing the last entry gives us the lowest free block.
+	 * We store the numbers of recycled-and-available blocks in
+	 * freeBlocks[]. When there are no such blocks, we extend the
+	 * underlying file.  Note that the block numbers in freeBlocks are
+	 * always in *decreasing* order, so that removing the last entry gives
+	 * us the lowest free block.
 	 */
 	long	   *freeBlocks;		/* resizable array */
 	int			nFreeBlocks;	/* # of currently free blocks */
-	int			freeBlocksLen;	/* current allocated length of freeBlocks[] */
+	int			freeBlocksLen;	/* current allocated length of
+								 * freeBlocks[] */
+
 	/*
 	 * tapes[] is declared size 1 since C wants a fixed size, but actually
 	 * it is of length nTapes.
@@ -159,17 +168,17 @@ static void ltsReadBlock(LogicalTapeSet *lts, long blocknum, void *buffer);
 static long ltsGetFreeBlock(LogicalTapeSet *lts);
 static void ltsReleaseBlock(LogicalTapeSet *lts, long blocknum);
 static void ltsRecordBlockNum(LogicalTapeSet *lts, IndirectBlock *indirect,
-							  long blocknum);
+				  long blocknum);
 static long ltsRewindIndirectBlock(LogicalTapeSet *lts,
-								   IndirectBlock *indirect,
-								   bool freezing);
+					   IndirectBlock *indirect,
+					   bool freezing);
 static long ltsRewindFrozenIndirectBlock(LogicalTapeSet *lts,
-										 IndirectBlock *indirect);
+							 IndirectBlock *indirect);
 static long ltsRecallNextBlockNum(LogicalTapeSet *lts,
-								  IndirectBlock *indirect,
-								  bool frozen);
+					  IndirectBlock *indirect,
+					  bool frozen);
 static long ltsRecallPrevBlockNum(LogicalTapeSet *lts,
-								  IndirectBlock *indirect);
+					  IndirectBlock *indirect);
 static void ltsDumpBuffer(LogicalTapeSet *lts, LogicalTape *lt);
 
 
@@ -194,7 +203,7 @@ ltsWriteBlock(LogicalTapeSet *lts, long blocknum, void *buffer)
 /*
  * Read a block-sized buffer from the specified block of the underlying file.
  *
- * No need for an error return convention; we elog() on any error.  This
+ * No need for an error return convention; we elog() on any error.	This
  * module should never attempt to read a block it doesn't know is there.
  */
 static void
@@ -215,9 +224,11 @@ ltsReadBlock(LogicalTapeSet *lts, long blocknum, void *buffer)
 static long
 ltsGetFreeBlock(LogicalTapeSet *lts)
 {
-	/* If there are multiple free blocks, we select the one appearing last
-	 * in freeBlocks[].  If there are none, assign the next block at the end
-	 * of the file.
+
+	/*
+	 * If there are multiple free blocks, we select the one appearing last
+	 * in freeBlocks[].  If there are none, assign the next block at the
+	 * end of the file.
 	 */
 	if (lts->nFreeBlocks > 0)
 		return lts->freeBlocks[--lts->nFreeBlocks];
@@ -231,8 +242,8 @@ ltsGetFreeBlock(LogicalTapeSet *lts)
 static void
 ltsReleaseBlock(LogicalTapeSet *lts, long blocknum)
 {
-	int		ndx;
-	long   *ptr;
+	int			ndx;
+	long	   *ptr;
 
 	/*
 	 * Enlarge freeBlocks array if full.
@@ -241,13 +252,14 @@ ltsReleaseBlock(LogicalTapeSet *lts, long blocknum)
 	{
 		lts->freeBlocksLen *= 2;
 		lts->freeBlocks = (long *) repalloc(lts->freeBlocks,
-											lts->freeBlocksLen * sizeof(long));
+									  lts->freeBlocksLen * sizeof(long));
 	}
+
 	/*
 	 * Insert blocknum into array, preserving decreasing order (so that
-	 * ltsGetFreeBlock returns the lowest available block number).
-	 * This could get fairly slow if there were many free blocks, but
-	 * we don't expect there to be very many at one time.
+	 * ltsGetFreeBlock returns the lowest available block number). This
+	 * could get fairly slow if there were many free blocks, but we don't
+	 * expect there to be very many at one time.
 	 */
 	ndx = lts->nFreeBlocks++;
 	ptr = lts->freeBlocks + ndx;
@@ -274,12 +286,13 @@ ltsRecordBlockNum(LogicalTapeSet *lts, IndirectBlock *indirect,
 {
 	if (indirect->nextSlot >= BLOCKS_PER_INDIR_BLOCK)
 	{
+
 		/*
 		 * This indirect block is full, so dump it out and recursively
-		 * save its address in the next indirection level.  Create a
-		 * new indirection level if there wasn't one before.
+		 * save its address in the next indirection level.	Create a new
+		 * indirection level if there wasn't one before.
 		 */
-		long	indirblock = ltsGetFreeBlock(lts);
+		long		indirblock = ltsGetFreeBlock(lts);
 
 		ltsWriteBlock(lts, indirblock, (void *) indirect->ptrs);
 		if (indirect->nextup == NULL)
@@ -289,6 +302,7 @@ ltsRecordBlockNum(LogicalTapeSet *lts, IndirectBlock *indirect,
 			indirect->nextup->nextup = NULL;
 		}
 		ltsRecordBlockNum(lts, indirect->nextup, indirblock);
+
 		/*
 		 * Reset to fill another indirect block at this level.
 		 */
@@ -299,7 +313,7 @@ ltsRecordBlockNum(LogicalTapeSet *lts, IndirectBlock *indirect,
 
 /*
  * Reset a logical tape's indirect-block hierarchy after a write pass
- * to prepare for reading.  We dump out partly-filled blocks except
+ * to prepare for reading.	We dump out partly-filled blocks except
  * at the top of the hierarchy, and we rewind each level to the start.
  * This call returns the first data block number, or -1L if the tape
  * is empty.
@@ -315,22 +329,24 @@ ltsRewindIndirectBlock(LogicalTapeSet *lts,
 	/* Insert sentinel if block is not full */
 	if (indirect->nextSlot < BLOCKS_PER_INDIR_BLOCK)
 		indirect->ptrs[indirect->nextSlot] = -1L;
+
 	/*
 	 * If block is not topmost, write it out, and recurse to obtain
-	 * address of first block in this hierarchy level.  Read that one in.
+	 * address of first block in this hierarchy level.	Read that one in.
 	 */
 	if (indirect->nextup != NULL)
 	{
-		long	indirblock = ltsGetFreeBlock(lts);
+		long		indirblock = ltsGetFreeBlock(lts);
 
 		ltsWriteBlock(lts, indirblock, (void *) indirect->ptrs);
 		ltsRecordBlockNum(lts, indirect->nextup, indirblock);
 		indirblock = ltsRewindIndirectBlock(lts, indirect->nextup, freezing);
 		Assert(indirblock != -1L);
 		ltsReadBlock(lts, indirblock, (void *) indirect->ptrs);
-		if (! freezing)
+		if (!freezing)
 			ltsReleaseBlock(lts, indirblock);
 	}
+
 	/*
 	 * Reset my next-block pointer, and then fetch a block number if any.
 	 */
@@ -349,18 +365,20 @@ static long
 ltsRewindFrozenIndirectBlock(LogicalTapeSet *lts,
 							 IndirectBlock *indirect)
 {
+
 	/*
-	 * If block is not topmost, recurse to obtain
-	 * address of first block in this hierarchy level.  Read that one in.
+	 * If block is not topmost, recurse to obtain address of first block
+	 * in this hierarchy level.  Read that one in.
 	 */
 	if (indirect->nextup != NULL)
 	{
-		long	indirblock;
+		long		indirblock;
 
 		indirblock = ltsRewindFrozenIndirectBlock(lts, indirect->nextup);
 		Assert(indirblock != -1L);
 		ltsReadBlock(lts, indirblock, (void *) indirect->ptrs);
 	}
+
 	/*
 	 * Reset my next-block pointer, and then fetch a block number if any.
 	 */
@@ -384,7 +402,7 @@ ltsRecallNextBlockNum(LogicalTapeSet *lts,
 	if (indirect->nextSlot >= BLOCKS_PER_INDIR_BLOCK ||
 		indirect->ptrs[indirect->nextSlot] == -1L)
 	{
-		long	indirblock;
+		long		indirblock;
 
 		if (indirect->nextup == NULL)
 			return -1L;			/* nothing left at this level */
@@ -392,7 +410,7 @@ ltsRecallNextBlockNum(LogicalTapeSet *lts,
 		if (indirblock == -1L)
 			return -1L;			/* nothing left at this level */
 		ltsReadBlock(lts, indirblock, (void *) indirect->ptrs);
-		if (! frozen)
+		if (!frozen)
 			ltsReleaseBlock(lts, indirblock);
 		indirect->nextSlot = 0;
 	}
@@ -416,7 +434,7 @@ ltsRecallPrevBlockNum(LogicalTapeSet *lts,
 {
 	if (indirect->nextSlot <= 1)
 	{
-		long	indirblock;
+		long		indirblock;
 
 		if (indirect->nextup == NULL)
 			return -1L;			/* nothing left at this level */
@@ -424,13 +442,15 @@ ltsRecallPrevBlockNum(LogicalTapeSet *lts,
 		if (indirblock == -1L)
 			return -1L;			/* nothing left at this level */
 		ltsReadBlock(lts, indirblock, (void *) indirect->ptrs);
-		/* The previous block would only have been written out if full,
-		 * so we need not search it for a -1 sentinel.
+
+		/*
+		 * The previous block would only have been written out if full, so
+		 * we need not search it for a -1 sentinel.
 		 */
-		indirect->nextSlot = BLOCKS_PER_INDIR_BLOCK+1;
+		indirect->nextSlot = BLOCKS_PER_INDIR_BLOCK + 1;
 	}
 	indirect->nextSlot--;
-	return indirect->ptrs[indirect->nextSlot-1];
+	return indirect->ptrs[indirect->nextSlot - 1];
 }
 
 
@@ -443,8 +463,8 @@ LogicalTapeSet *
 LogicalTapeSetCreate(int ntapes)
 {
 	LogicalTapeSet *lts;
-	LogicalTape	   *lt;
-	int				i;
+	LogicalTape *lt;
+	int			i;
 
 	/*
 	 * Create top-level struct.  First LogicalTape pointer is already
@@ -452,13 +472,14 @@ LogicalTapeSetCreate(int ntapes)
 	 */
 	Assert(ntapes > 0);
 	lts = (LogicalTapeSet *) palloc(sizeof(LogicalTapeSet) +
-									(ntapes-1) * sizeof(LogicalTape *));
+									(ntapes - 1) *sizeof(LogicalTape *));
 	lts->pfile = BufFileCreateTemp();
 	lts->nFileBlocks = 0L;
 	lts->freeBlocksLen = 32;	/* reasonable initial guess */
 	lts->freeBlocks = (long *) palloc(lts->freeBlocksLen * sizeof(long));
 	lts->nFreeBlocks = 0;
 	lts->nTapes = ntapes;
+
 	/*
 	 * Create per-tape structs, including first-level indirect blocks.
 	 */
@@ -484,12 +505,13 @@ LogicalTapeSetCreate(int ntapes)
 /*
  * Close a logical tape set and release all resources.
  */
-void LogicalTapeSetClose(LogicalTapeSet *lts)
+void
+LogicalTapeSetClose(LogicalTapeSet *lts)
 {
-	LogicalTape	   *lt;
-	IndirectBlock  *ib,
-				   *nextib;
-	int				i;
+	LogicalTape *lt;
+	IndirectBlock *ib,
+			   *nextib;
+	int			i;
 
 	BufFileClose(lts->pfile);
 	for (i = 0; i < lts->nTapes; i++)
@@ -512,7 +534,7 @@ void LogicalTapeSetClose(LogicalTapeSet *lts)
 static void
 ltsDumpBuffer(LogicalTapeSet *lts, LogicalTape *lt)
 {
-	long	datablock = ltsGetFreeBlock(lts);
+	long		datablock = ltsGetFreeBlock(lts);
 
 	Assert(lt->dirty);
 	ltsWriteBlock(lts, datablock, (void *) lt->buffer);
@@ -530,8 +552,8 @@ void
 LogicalTapeWrite(LogicalTapeSet *lts, int tapenum,
 				 void *ptr, size_t size)
 {
-	LogicalTape	   *lt;
-	size_t			nthistime;
+	LogicalTape *lt;
+	size_t		nthistime;
 
 	Assert(tapenum >= 0 && tapenum < lts->nTapes);
 	lt = lts->tapes[tapenum];
@@ -543,9 +565,7 @@ LogicalTapeWrite(LogicalTapeSet *lts, int tapenum,
 		{
 			/* Buffer full, dump it out */
 			if (lt->dirty)
-			{
 				ltsDumpBuffer(lts, lt);
-			}
 			else
 			{
 				/* Hmm, went directly from reading to writing? */
@@ -582,20 +602,21 @@ LogicalTapeWrite(LogicalTapeSet *lts, int tapenum,
 void
 LogicalTapeRewind(LogicalTapeSet *lts, int tapenum, bool forWrite)
 {
-	LogicalTape	   *lt;
-	long			datablocknum;
+	LogicalTape *lt;
+	long		datablocknum;
 
 	Assert(tapenum >= 0 && tapenum < lts->nTapes);
 	lt = lts->tapes[tapenum];
 
-	if (! forWrite)
+	if (!forWrite)
 	{
 		if (lt->writing)
 		{
+
 			/*
 			 * Completion of a write phase.  Flush last partial data
-			 * block, flush any partial indirect blocks, rewind for
-			 * normal (destructive) read.
+			 * block, flush any partial indirect blocks, rewind for normal
+			 * (destructive) read.
 			 */
 			if (lt->dirty)
 				ltsDumpBuffer(lts, lt);
@@ -605,6 +626,7 @@ LogicalTapeRewind(LogicalTapeSet *lts, int tapenum, bool forWrite)
 		}
 		else
 		{
+
 			/*
 			 * This is only OK if tape is frozen; we rewind for (another)
 			 * read pass.
@@ -619,7 +641,7 @@ LogicalTapeRewind(LogicalTapeSet *lts, int tapenum, bool forWrite)
 		if (datablocknum != -1L)
 		{
 			ltsReadBlock(lts, datablocknum, (void *) lt->buffer);
-			if (! lt->frozen)
+			if (!lt->frozen)
 				ltsReleaseBlock(lts, datablocknum);
 			lt->nbytes = (lt->curBlockNumber < lt->numFullBlocks) ?
 				BLCKSZ : lt->lastBlockBytes;
@@ -627,18 +649,19 @@ LogicalTapeRewind(LogicalTapeSet *lts, int tapenum, bool forWrite)
 	}
 	else
 	{
+
 		/*
-		 * Completion of a read phase.  Rewind and prepare for write.
+		 * Completion of a read phase.	Rewind and prepare for write.
 		 *
-		 * NOTE: we assume the caller has read the tape to the end;
-		 * otherwise untouched data and indirect blocks will not have
-		 * been freed.  We could add more code to free any unread blocks,
-		 * but in current usage of this module it'd be useless code.
+		 * NOTE: we assume the caller has read the tape to the end; otherwise
+		 * untouched data and indirect blocks will not have been freed. We
+		 * could add more code to free any unread blocks, but in current
+		 * usage of this module it'd be useless code.
 		 */
-		IndirectBlock  *ib,
-					   *nextib;
+		IndirectBlock *ib,
+				   *nextib;
 
-		Assert(! lt->writing && ! lt->frozen);
+		Assert(!lt->writing && !lt->frozen);
 		/* Must truncate the indirect-block hierarchy down to one level. */
 		for (ib = lt->indirect->nextup; ib != NULL; ib = nextib)
 		{
@@ -666,28 +689,28 @@ size_t
 LogicalTapeRead(LogicalTapeSet *lts, int tapenum,
 				void *ptr, size_t size)
 {
-	LogicalTape	   *lt;
-	size_t			nread = 0;
-	size_t			nthistime;
+	LogicalTape *lt;
+	size_t		nread = 0;
+	size_t		nthistime;
 
 	Assert(tapenum >= 0 && tapenum < lts->nTapes);
 	lt = lts->tapes[tapenum];
-	Assert(! lt->writing);
+	Assert(!lt->writing);
 
 	while (size > 0)
 	{
 		if (lt->pos >= lt->nbytes)
 		{
 			/* Try to load more data into buffer. */
-			long	datablocknum = ltsRecallNextBlockNum(lts, lt->indirect,
-														 lt->frozen);
+			long		datablocknum = ltsRecallNextBlockNum(lts, lt->indirect,
+															 lt->frozen);
 
 			if (datablocknum == -1L)
 				break;			/* EOF */
 			lt->curBlockNumber++;
 			lt->pos = 0;
 			ltsReadBlock(lts, datablocknum, (void *) lt->buffer);
-			if (! lt->frozen)
+			if (!lt->frozen)
 				ltsReleaseBlock(lts, datablocknum);
 			lt->nbytes = (lt->curBlockNumber < lt->numFullBlocks) ?
 				BLCKSZ : lt->lastBlockBytes;
@@ -719,23 +742,22 @@ LogicalTapeRead(LogicalTapeSet *lts, int tapenum,
  *
  * This *must* be called just at the end of a write pass, before the
  * tape is rewound (after rewind is too late!).  It performs a rewind
- * and switch to read mode "for free".  An immediately following rewind-
+ * and switch to read mode "for free".	An immediately following rewind-
  * for-read call is OK but not necessary.
  */
 void
 LogicalTapeFreeze(LogicalTapeSet *lts, int tapenum)
 {
-	LogicalTape	   *lt;
-	long			datablocknum;
+	LogicalTape *lt;
+	long		datablocknum;
 
 	Assert(tapenum >= 0 && tapenum < lts->nTapes);
 	lt = lts->tapes[tapenum];
 	Assert(lt->writing);
 
 	/*
-	 * Completion of a write phase.  Flush last partial data
-	 * block, flush any partial indirect blocks, rewind for
-	 * nondestructive read.
+	 * Completion of a write phase.  Flush last partial data block, flush
+	 * any partial indirect blocks, rewind for nondestructive read.
 	 */
 	if (lt->dirty)
 		ltsDumpBuffer(lts, lt);
@@ -756,7 +778,7 @@ LogicalTapeFreeze(LogicalTapeSet *lts, int tapenum)
 }
 
 /*
- * Backspace the tape a given number of bytes.  (We also support a more
+ * Backspace the tape a given number of bytes.	(We also support a more
  * general seek interface, see below.)
  *
  * *Only* a frozen-for-read tape can be backed up; we don't support
@@ -769,9 +791,9 @@ LogicalTapeFreeze(LogicalTapeSet *lts, int tapenum)
 bool
 LogicalTapeBackspace(LogicalTapeSet *lts, int tapenum, size_t size)
 {
-	LogicalTape	   *lt;
-	long			nblocks;
-	int				newpos;
+	LogicalTape *lt;
+	long		nblocks;
+	int			newpos;
 
 	Assert(tapenum >= 0 && tapenum < lts->nTapes);
 	lt = lts->tapes[tapenum];
@@ -785,6 +807,7 @@ LogicalTapeBackspace(LogicalTapeSet *lts, int tapenum, size_t size)
 		lt->pos -= (int) size;
 		return true;
 	}
+
 	/*
 	 * Not-so-easy case.  Figure out whether it's possible at all.
 	 */
@@ -800,14 +823,15 @@ LogicalTapeBackspace(LogicalTapeSet *lts, int tapenum, size_t size)
 		newpos = 0;
 	if (nblocks > lt->curBlockNumber)
 		return false;			/* a seek too far... */
+
 	/*
-	 * OK, we need to back up nblocks blocks.  This implementation
-	 * would be pretty inefficient for long seeks, but we really
-	 * aren't expecting that (a seek over one tuple is typical).
+	 * OK, we need to back up nblocks blocks.  This implementation would
+	 * be pretty inefficient for long seeks, but we really aren't
+	 * expecting that (a seek over one tuple is typical).
 	 */
 	while (nblocks-- > 0)
 	{
-		long	datablocknum = ltsRecallPrevBlockNum(lts, lt->indirect);
+		long		datablocknum = ltsRecallPrevBlockNum(lts, lt->indirect);
 
 		if (datablocknum == -1L)
 			elog(ERROR, "LogicalTapeBackspace: unexpected end of tape");
@@ -834,7 +858,7 @@ bool
 LogicalTapeSeek(LogicalTapeSet *lts, int tapenum,
 				long blocknum, int offset)
 {
-	LogicalTape	   *lt;
+	LogicalTape *lt;
 
 	Assert(tapenum >= 0 && tapenum < lts->nTapes);
 	lt = lts->tapes[tapenum];
@@ -849,20 +873,22 @@ LogicalTapeSeek(LogicalTapeSet *lts, int tapenum,
 		lt->pos = offset;
 		return true;
 	}
+
 	/*
 	 * Not-so-easy case.  Figure out whether it's possible at all.
 	 */
 	if (blocknum < 0 || blocknum > lt->numFullBlocks ||
 		(blocknum == lt->numFullBlocks && offset > lt->lastBlockBytes))
 		return false;
+
 	/*
-	 * OK, advance or back up to the target block.  This implementation
-	 * would be pretty inefficient for long seeks, but we really
-	 * aren't expecting that (a seek over one tuple is typical).
+	 * OK, advance or back up to the target block.	This implementation
+	 * would be pretty inefficient for long seeks, but we really aren't
+	 * expecting that (a seek over one tuple is typical).
 	 */
 	while (lt->curBlockNumber > blocknum)
 	{
-		long	datablocknum = ltsRecallPrevBlockNum(lts, lt->indirect);
+		long		datablocknum = ltsRecallPrevBlockNum(lts, lt->indirect);
 
 		if (datablocknum == -1L)
 			elog(ERROR, "LogicalTapeSeek: unexpected end of tape");
@@ -871,8 +897,8 @@ LogicalTapeSeek(LogicalTapeSet *lts, int tapenum,
 	}
 	while (lt->curBlockNumber < blocknum)
 	{
-		long	datablocknum = ltsRecallNextBlockNum(lts, lt->indirect,
-													 lt->frozen);
+		long		datablocknum = ltsRecallNextBlockNum(lts, lt->indirect,
+														 lt->frozen);
 
 		if (datablocknum == -1L)
 			elog(ERROR, "LogicalTapeSeek: unexpected end of tape");
@@ -889,13 +915,13 @@ LogicalTapeSeek(LogicalTapeSet *lts, int tapenum,
  * Obtain current position in a form suitable for a later LogicalTapeSeek.
  *
  * NOTE: it'd be OK to do this during write phase with intention of using
- * the position for a seek after freezing.  Not clear if anyone needs that.
+ * the position for a seek after freezing.	Not clear if anyone needs that.
  */
 void
 LogicalTapeTell(LogicalTapeSet *lts, int tapenum,
 				long *blocknum, int *offset)
 {
-	LogicalTape	   *lt;
+	LogicalTape *lt;
 
 	Assert(tapenum >= 0 && tapenum < lts->nTapes);
 	lt = lts->tapes[tapenum];
diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c
index 852e5cf41b37a951c8857517c1a709c734a5cd4a..154efd1080e4ff1fe85f38eacc55e0875456b779 100644
--- a/src/backend/utils/sort/tuplesort.c
+++ b/src/backend/utils/sort/tuplesort.c
@@ -6,7 +6,7 @@
  * This module handles sorting of heap tuples, index tuples, or single
  * Datums (and could easily support other kinds of sortable objects,
  * if necessary).  It works efficiently for both small and large amounts
- * of data.  Small amounts are sorted in-memory using qsort().  Large
+ * of data.  Small amounts are sorted in-memory using qsort().	Large
  * amounts are sorted using temporary files and a standard external sort
  * algorithm.
  *
@@ -31,7 +31,7 @@
  * no more records of the prior run are left in the heap.
  *
  * The (approximate) amount of memory allowed for any one sort operation
- * is given in kilobytes by the external variable SortMem.  Initially,
+ * is given in kilobytes by the external variable SortMem.	Initially,
  * we absorb tuples and simply store them in an unsorted array as long as
  * we haven't exceeded SortMem.  If we reach the end of the input without
  * exceeding SortMem, we sort the array using qsort() and subsequently return
@@ -40,7 +40,7 @@
  * into sorted runs in temporary tapes, emitting just enough tuples at each
  * step to get back within the SortMem limit.  Whenever the run number at
  * the top of the heap changes, we begin a new run with a new output tape
- * (selected per Algorithm D).  After the end of the input is reached,
+ * (selected per Algorithm D).	After the end of the input is reached,
  * we dump out remaining tuples in memory into a final run (or two),
  * then merge the runs using Algorithm D.
  *
@@ -57,17 +57,17 @@
  * access at all, defeating the read-ahead methods used by most Unix kernels.
  * Worse, the output tape gets written into a very random sequence of blocks
  * of the temp file, ensuring that things will be even worse when it comes
- * time to read that tape.  A straightforward merge pass thus ends up doing a
+ * time to read that tape.	A straightforward merge pass thus ends up doing a
  * lot of waiting for disk seeks.  We can improve matters by prereading from
  * each source tape sequentially, loading about SortMem/M bytes from each tape
  * in turn.  Then we run the merge algorithm, writing but not reading until
- * one of the preloaded tuple series runs out.  Then we switch back to preread
+ * one of the preloaded tuple series runs out.	Then we switch back to preread
  * mode, fill memory again, and repeat.  This approach helps to localize both
  * read and write accesses.
  *
  * When the caller requests random access to the sort result, we form
  * the final sorted run on a logical tape which is then "frozen", so
- * that we can access it randomly.  When the caller does not need random
+ * that we can access it randomly.	When the caller does not need random
  * access, we return from tuplesort_performsort() as soon as we are down
  * to one run per logical tape.  The final merge is then performed
  * on-the-fly as the caller repeatedly calls tuplesort_gettuple; this
@@ -78,7 +78,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.8 2000/03/17 02:36:31 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.9 2000/04/12 17:16:12 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -99,18 +99,19 @@
  */
 typedef enum
 {
-	TSS_INITIAL,		/* Loading tuples; still within memory limit */
-	TSS_BUILDRUNS,		/* Loading tuples; writing to tape */
-	TSS_SORTEDINMEM,	/* Sort completed entirely in memory */
-	TSS_SORTEDONTAPE,	/* Sort completed, final run is on tape */
-	TSS_FINALMERGE		/* Performing final merge on-the-fly */
+	TSS_INITIAL,				/* Loading tuples; still within memory
+								 * limit */
+	TSS_BUILDRUNS,				/* Loading tuples; writing to tape */
+	TSS_SORTEDINMEM,			/* Sort completed entirely in memory */
+	TSS_SORTEDONTAPE,			/* Sort completed, final run is on tape */
+	TSS_FINALMERGE				/* Performing final merge on-the-fly */
 } TupSortStatus;
 
 /*
  * We use a seven-tape polyphase merge, which is the "sweet spot" on the
  * tapes-to-passes curve according to Knuth's figure 70 (section 5.4.2).
  */
-#define MAXTAPES		7				/* Knuth's T */
+#define MAXTAPES		7		/* Knuth's T */
 #define TAPERANGE		(MAXTAPES-1)	/* Knuth's P */
 
 /*
@@ -121,54 +122,59 @@ struct Tuplesortstate
 	TupSortStatus status;		/* enumerated value as shown above */
 	bool		randomAccess;	/* did caller request random access? */
 	long		availMem;		/* remaining memory available, in bytes */
-	LogicalTapeSet *tapeset;	/* logtape.c object for tapes in a temp file */
+	LogicalTapeSet *tapeset;	/* logtape.c object for tapes in a temp
+								 * file */
 
 	/*
-	 * These function pointers decouple the routines that must know what kind
-	 * of tuple we are sorting from the routines that don't need to know it.
-	 * They are set up by the tuplesort_begin_xxx routines.
+	 * These function pointers decouple the routines that must know what
+	 * kind of tuple we are sorting from the routines that don't need to
+	 * know it. They are set up by the tuplesort_begin_xxx routines.
 	 *
-	 * Function to compare two tuples; result is per qsort() convention,
-	 * ie, <0, 0, >0 according as a<b, a=b, a>b.
+	 * Function to compare two tuples; result is per qsort() convention, ie,
+	 * <0, 0, >0 according as a<b, a=b, a>b.
 	 */
-	int (*comparetup) (Tuplesortstate *state, const void *a, const void *b);
+	int			(*comparetup) (Tuplesortstate *state, const void *a, const void *b);
+
 	/*
-	 * Function to copy a supplied input tuple into palloc'd space.
-	 * (NB: we assume that a single pfree() is enough to release the tuple
+	 * Function to copy a supplied input tuple into palloc'd space. (NB:
+	 * we assume that a single pfree() is enough to release the tuple
 	 * later, so the representation must be "flat" in one palloc chunk.)
 	 * state->availMem must be decreased by the amount of space used.
 	 */
-	void * (*copytup) (Tuplesortstate *state, void *tup);
+	void	   *(*copytup) (Tuplesortstate *state, void *tup);
+
 	/*
-	 * Function to write a stored tuple onto tape.  The representation of
-	 * the tuple on tape need not be the same as it is in memory; requirements
-	 * on the tape representation are given below.  After writing the tuple,
-	 * pfree() it, and increase state->availMem by the amount of memory space
-	 * thereby released.
+	 * Function to write a stored tuple onto tape.	The representation of
+	 * the tuple on tape need not be the same as it is in memory;
+	 * requirements on the tape representation are given below.  After
+	 * writing the tuple, pfree() it, and increase state->availMem by the
+	 * amount of memory space thereby released.
 	 */
-	void (*writetup) (Tuplesortstate *state, int tapenum, void *tup);
+	void		(*writetup) (Tuplesortstate *state, int tapenum, void *tup);
+
 	/*
-	 * Function to read a stored tuple from tape back into memory.
-	 * 'len' is the already-read length of the stored tuple.  Create and
-	 * return a palloc'd copy, and decrease state->availMem by the amount
-	 * of memory space consumed.
+	 * Function to read a stored tuple from tape back into memory. 'len'
+	 * is the already-read length of the stored tuple.	Create and return
+	 * a palloc'd copy, and decrease state->availMem by the amount of
+	 * memory space consumed.
 	 */
-	void * (*readtup) (Tuplesortstate *state, int tapenum, unsigned int len);
+	void	   *(*readtup) (Tuplesortstate *state, int tapenum, unsigned int len);
+
 	/*
-	 * Obtain memory space occupied by a stored tuple.  (This routine is
+	 * Obtain memory space occupied by a stored tuple.	(This routine is
 	 * only needed in the FINALMERGE case, since copytup, writetup, and
 	 * readtup are expected to adjust availMem appropriately.)
 	 */
 	unsigned int (*tuplesize) (Tuplesortstate *state, void *tup);
 
 	/*
-	 * This array holds pointers to tuples in sort memory.  If we are in
+	 * This array holds pointers to tuples in sort memory.	If we are in
 	 * state INITIAL, the tuples are in no particular order; if we are in
 	 * state SORTEDINMEM, the tuples are in final sorted order; in states
 	 * BUILDRUNS and FINALMERGE, the tuples are organized in "heap" order
-	 * per Algorithm H.  (Note that memtupcount only counts the tuples that
-	 * are part of the heap --- during merge passes, memtuples[] entries
-	 * beyond TAPERANGE are never in the heap and are used to hold
+	 * per Algorithm H.  (Note that memtupcount only counts the tuples
+	 * that are part of the heap --- during merge passes, memtuples[]
+	 * entries beyond TAPERANGE are never in the heap and are used to hold
 	 * pre-read tuples.)  In state SORTEDONTAPE, the array is not used.
 	 */
 	void	  **memtuples;		/* array of pointers to palloc'd tuples */
@@ -176,19 +182,21 @@ struct Tuplesortstate
 	int			memtupsize;		/* allocated length of memtuples array */
 
 	/*
-	 * While building initial runs, this array holds the run number for each
-	 * tuple in memtuples[].  During merge passes, we re-use it to hold the
-	 * input tape number that each tuple in the heap was read from, or to hold
-	 * the index of the next tuple pre-read from the same tape in the case of
-	 * pre-read entries.  This array is never allocated unless we need to use
-	 * tapes.  Whenever it is allocated, it has the same length as
-	 * memtuples[].
+	 * While building initial runs, this array holds the run number for
+	 * each tuple in memtuples[].  During merge passes, we re-use it to
+	 * hold the input tape number that each tuple in the heap was read
+	 * from, or to hold the index of the next tuple pre-read from the same
+	 * tape in the case of pre-read entries.  This array is never
+	 * allocated unless we need to use tapes.  Whenever it is allocated,
+	 * it has the same length as memtuples[].
 	 */
-	int		   *memtupindex;	/* index value associated with memtuples[i] */
+	int		   *memtupindex;	/* index value associated with
+								 * memtuples[i] */
 
 	/*
 	 * While building initial runs, this is the current output run number
-	 * (starting at 0).  Afterwards, it is the number of initial runs we made.
+	 * (starting at 0).  Afterwards, it is the number of initial runs we
+	 * made.
 	 */
 	int			currentRun;
 
@@ -199,20 +207,24 @@ struct Tuplesortstate
 	 * index of the next pre-read tuple (next to be loaded into the heap)
 	 * for tape i, or 0 if we are out of pre-read tuples.  mergelast[i]
 	 * similarly points to the last pre-read tuple from each tape.
-	 * mergeavailmem[i] is the amount of unused space allocated for tape i.
-	 * mergefreelist and mergefirstfree keep track of unused locations
+	 * mergeavailmem[i] is the amount of unused space allocated for tape
+	 * i. mergefreelist and mergefirstfree keep track of unused locations
 	 * in the memtuples[] array.  memtupindex[] links together pre-read
-	 * tuples for each tape as well as recycled locations in mergefreelist.
-	 * It is OK to use 0 as a null link in these lists, because memtuples[0]
-	 * is part of the merge heap and is never a pre-read tuple.
+	 * tuples for each tape as well as recycled locations in
+	 * mergefreelist. It is OK to use 0 as a null link in these lists,
+	 * because memtuples[0] is part of the merge heap and is never a
+	 * pre-read tuple.
 	 */
-	bool		mergeactive[MAXTAPES]; /* Active input run source? */
-	int			mergenext[MAXTAPES]; /* first preread tuple for each source */
-	int			mergelast[MAXTAPES]; /* last preread tuple for each source */
-	long		mergeavailmem[MAXTAPES]; /* availMem for prereading tapes */
+	bool		mergeactive[MAXTAPES];	/* Active input run source? */
+	int			mergenext[MAXTAPES];	/* first preread tuple for each
+										 * source */
+	int			mergelast[MAXTAPES];	/* last preread tuple for each
+										 * source */
+	long		mergeavailmem[MAXTAPES];		/* availMem for prereading
+												 * tapes */
 	long		spacePerTape;	/* actual per-tape target usage */
 	int			mergefreelist;	/* head of freelist of recycled slots */
-	int			mergefirstfree;	/* first slot never used in this merge */
+	int			mergefirstfree; /* first slot never used in this merge */
 
 	/*
 	 * Variables for Algorithm D.  Note that destTape is a "logical" tape
@@ -221,10 +233,12 @@ struct Tuplesortstate
 	 */
 	int			Level;			/* Knuth's l */
 	int			destTape;		/* current output tape (Knuth's j, less 1) */
-	int			tp_fib[MAXTAPES]; /* Target Fibonacci run counts (A[]) */
-	int			tp_runs[MAXTAPES];	/* # of real runs on each tape */
-	int			tp_dummy[MAXTAPES];	/* # of dummy runs for each tape (D[]) */
-	int			tp_tapenum[MAXTAPES]; /* Actual tape numbers (TAPE[]) */
+	int			tp_fib[MAXTAPES];		/* Target Fibonacci run counts
+										 * (A[]) */
+	int			tp_runs[MAXTAPES];		/* # of real runs on each tape */
+	int			tp_dummy[MAXTAPES];		/* # of dummy runs for each tape
+										 * (D[]) */
+	int			tp_tapenum[MAXTAPES];	/* Actual tape numbers (TAPE[]) */
 
 	/*
 	 * These variables are used after completion of sorting to keep track
@@ -237,12 +251,13 @@ struct Tuplesortstate
 
 	/* markpos_xxx holds marked position for mark and restore */
 	long		markpos_block;	/* tape block# (only used if SORTEDONTAPE) */
-	int			markpos_offset;	/* saved "current", or offset in tape block */
+	int			markpos_offset; /* saved "current", or offset in tape
+								 * block */
 	bool		markpos_eof;	/* saved "eof_reached" */
 
 	/*
-	 * These variables are specific to the HeapTuple case; they are set
-	 * by tuplesort_begin_heap and used only by the HeapTuple routines.
+	 * These variables are specific to the HeapTuple case; they are set by
+	 * tuplesort_begin_heap and used only by the HeapTuple routines.
 	 */
 	TupleDesc	tupDesc;
 	int			nKeys;
@@ -257,8 +272,8 @@ struct Tuplesortstate
 	bool		enforceUnique;	/* complain if we find duplicate tuples */
 
 	/*
-	 * These variables are specific to the Datum case; they are set
-	 * by tuplesort_begin_datum and used only by the DatumTuple routines.
+	 * These variables are specific to the Datum case; they are set by
+	 * tuplesort_begin_datum and used only by the DatumTuple routines.
 	 */
 	Oid			datumType;
 	Oid			sortOperator;
@@ -271,7 +286,7 @@ struct Tuplesortstate
 #define COMPARETUP(state,a,b)	((*(state)->comparetup) (state, a, b))
 #define COPYTUP(state,tup)	((*(state)->copytup) (state, tup))
 #define WRITETUP(state,tape,tup)	((*(state)->writetup) (state, tape, tup))
-#define READTUP(state,tape,len)	((*(state)->readtup) (state, tape, len))
+#define READTUP(state,tape,len) ((*(state)->readtup) (state, tape, len))
 #define TUPLESIZE(state,tup)	((*(state)->tuplesize) (state, tup))
 #define LACKMEM(state)		((state)->availMem < 0)
 #define USEMEM(state,amt)	((state)->availMem -= (amt))
@@ -290,7 +305,7 @@ struct Tuplesortstate
  * If state->randomAccess is true, then the stored representation of the
  * tuple must be followed by another "unsigned int" that is a copy of the
  * length --- so the total tape space used is actually sizeof(unsigned int)
- * more than the stored length value.  This allows read-backwards.  When
+ * more than the stored length value.  This allows read-backwards.	When
  * randomAccess is not true, the write/read routines may omit the extra
  * length word.
  *
@@ -300,7 +315,7 @@ struct Tuplesortstate
  * the back length word (if present).
  *
  * The write/read routines can make use of the tuple description data
- * stored in the Tuplesortstate record, if needed.  They are also expected
+ * stored in the Tuplesortstate record, if needed.	They are also expected
  * to adjust state->availMem by the amount of memory space (not tape space!)
  * released or consumed.  There is no error return from either writetup
  * or readtup; they should elog() on failure.
@@ -311,7 +326,7 @@ struct Tuplesortstate
  * We count space requested for tuples against the SortMem limit.
  * Fixed-size space (primarily the LogicalTapeSet I/O buffers) is not
  * counted, nor do we count the variable-size memtuples and memtupindex
- * arrays.  (Even though those could grow pretty large, they should be
+ * arrays.	(Even though those could grow pretty large, they should be
  * small compared to the tuples proper, so this is not unreasonable.)
  *
  * The major deficiency in this approach is that it ignores palloc overhead.
@@ -360,37 +375,37 @@ static void beginmerge(Tuplesortstate *state);
 static void mergepreread(Tuplesortstate *state);
 static void dumptuples(Tuplesortstate *state, bool alltuples);
 static void tuplesort_heap_insert(Tuplesortstate *state, void *tuple,
-								  int tupleindex, bool checkIndex);
+					  int tupleindex, bool checkIndex);
 static void tuplesort_heap_siftup(Tuplesortstate *state, bool checkIndex);
 static unsigned int getlen(Tuplesortstate *state, int tapenum, bool eofOK);
 static void markrunend(Tuplesortstate *state, int tapenum);
-static int qsort_comparetup(const void *a, const void *b);
+static int	qsort_comparetup(const void *a, const void *b);
 static int comparetup_heap(Tuplesortstate *state,
-						   const void *a, const void *b);
+				const void *a, const void *b);
 static void *copytup_heap(Tuplesortstate *state, void *tup);
 static void writetup_heap(Tuplesortstate *state, int tapenum, void *tup);
 static void *readtup_heap(Tuplesortstate *state, int tapenum,
-						  unsigned int len);
+			 unsigned int len);
 static unsigned int tuplesize_heap(Tuplesortstate *state, void *tup);
 static int comparetup_index(Tuplesortstate *state,
-							const void *a, const void *b);
+				 const void *a, const void *b);
 static void *copytup_index(Tuplesortstate *state, void *tup);
 static void writetup_index(Tuplesortstate *state, int tapenum, void *tup);
 static void *readtup_index(Tuplesortstate *state, int tapenum,
-						   unsigned int len);
+			  unsigned int len);
 static unsigned int tuplesize_index(Tuplesortstate *state, void *tup);
 static int comparetup_datum(Tuplesortstate *state,
-							const void *a, const void *b);
+				 const void *a, const void *b);
 static void *copytup_datum(Tuplesortstate *state, void *tup);
 static void writetup_datum(Tuplesortstate *state, int tapenum, void *tup);
 static void *readtup_datum(Tuplesortstate *state, int tapenum,
-						   unsigned int len);
+			  unsigned int len);
 static unsigned int tuplesize_datum(Tuplesortstate *state, void *tup);
 
 /*
  * Since qsort(3) will not pass any context info to qsort_comparetup(),
  * we have to use this ugly static variable.  It is set to point to the
- * active Tuplesortstate object just before calling qsort.  It should
+ * active Tuplesortstate object just before calling qsort.	It should
  * not be used directly by anything except qsort_comparetup().
  */
 static Tuplesortstate *qsort_tuplesortstate;
@@ -403,7 +418,7 @@ static Tuplesortstate *qsort_tuplesortstate;
  *
  * After calling tuplesort_begin, the caller should call tuplesort_puttuple
  * zero or more times, then call tuplesort_performsort when all the tuples
- * have been supplied.  After performsort, retrieve the tuples in sorted
+ * have been supplied.	After performsort, retrieve the tuples in sorted
  * order by calling tuplesort_gettuple until it returns NULL.  (If random
  * access was requested, rescan, markpos, and restorepos can also be called.)
  * For Datum sorts, putdatum/getdatum are used instead of puttuple/gettuple.
@@ -434,7 +449,8 @@ tuplesort_begin_common(bool randomAccess)
 
 	/* Algorithm D variables will be initialized by inittapes, if needed */
 
-	state->result_tape = -1;	/* flag that result tape has not been formed */
+	state->result_tape = -1;	/* flag that result tape has not been
+								 * formed */
 
 	return state;
 }
@@ -490,7 +506,7 @@ tuplesort_begin_datum(Oid datumType,
 					  bool randomAccess)
 {
 	Tuplesortstate *state = tuplesort_begin_common(randomAccess);
-	Type			typeInfo;
+	Type		typeInfo;
 
 	state->comparetup = comparetup_datum;
 	state->copytup = copytup_datum;
@@ -518,7 +534,7 @@ tuplesort_begin_datum(Oid datumType,
 void
 tuplesort_end(Tuplesortstate *state)
 {
-	int		i;
+	int			i;
 
 	if (state->tapeset)
 		LogicalTapeSetClose(state->tapeset);
@@ -540,6 +556,7 @@ tuplesort_end(Tuplesortstate *state)
 void
 tuplesort_puttuple(Tuplesortstate *state, void *tuple)
 {
+
 	/*
 	 * Copy the given tuple into memory we control, and decrease availMem.
 	 * Then call the code shared with the Datum case.
@@ -557,7 +574,7 @@ tuplesort_puttuple(Tuplesortstate *state, void *tuple)
 void
 tuplesort_putdatum(Tuplesortstate *state, Datum val, bool isNull)
 {
-	DatumTuple	   *tuple;
+	DatumTuple *tuple;
 
 	/*
 	 * Build pseudo-tuple carrying the datum, and decrease availMem.
@@ -571,9 +588,9 @@ tuplesort_putdatum(Tuplesortstate *state, Datum val, bool isNull)
 	}
 	else
 	{
-		int		datalen = state->datumTypeLen;
-		int		tuplelen;
-		char   *newVal;
+		int			datalen = state->datumTypeLen;
+		int			tuplelen;
+		char	   *newVal;
 
 		if (datalen == -1)		/* variable length type? */
 			datalen = VARSIZE((struct varlena *) DatumGetPointer(val));
@@ -598,7 +615,8 @@ puttuple_common(Tuplesortstate *state, void *tuple)
 {
 	switch (state->status)
 	{
-		case TSS_INITIAL:
+			case TSS_INITIAL:
+
 			/*
 			 * Save the copied tuple into the unsorted array.
 			 */
@@ -611,41 +629,47 @@ puttuple_common(Tuplesortstate *state, void *tuple)
 							 state->memtupsize * sizeof(void *));
 			}
 			state->memtuples[state->memtupcount++] = tuple;
+
 			/*
 			 * Done if we still fit in available memory.
 			 */
-			if (! LACKMEM(state))
+			if (!LACKMEM(state))
 				return;
+
 			/*
 			 * Nope; time to switch to tape-based operation.
 			 */
 			inittapes(state);
+
 			/*
 			 * Dump tuples until we are back under the limit.
 			 */
 			dumptuples(state, false);
 			break;
 		case TSS_BUILDRUNS:
+
 			/*
 			 * Insert the copied tuple into the heap, with run number
 			 * currentRun if it can go into the current run, else run
 			 * number currentRun+1.  The tuple can go into the current run
-			 * if it is >= the first not-yet-output tuple.  (Actually,
-			 * it could go into the current run if it is >= the most recently
+			 * if it is >= the first not-yet-output tuple.	(Actually, it
+			 * could go into the current run if it is >= the most recently
 			 * output tuple ... but that would require keeping around the
-			 * tuple we last output, and it's simplest to let writetup free
-			 * each tuple as soon as it's written.)
+			 * tuple we last output, and it's simplest to let writetup
+			 * free each tuple as soon as it's written.)
 			 *
-			 * Note there will always be at least one tuple in the heap
-			 * at this point; see dumptuples.
+			 * Note there will always be at least one tuple in the heap at
+			 * this point; see dumptuples.
 			 */
 			Assert(state->memtupcount > 0);
 			if (COMPARETUP(state, tuple, state->memtuples[0]) >= 0)
 				tuplesort_heap_insert(state, tuple, state->currentRun, true);
 			else
-				tuplesort_heap_insert(state, tuple, state->currentRun+1, true);
+				tuplesort_heap_insert(state, tuple, state->currentRun + 1, true);
+
 			/*
-			 * If we are over the memory limit, dump tuples till we're under.
+			 * If we are over the memory limit, dump tuples till we're
+			 * under.
 			 */
 			dumptuples(state, false);
 			break;
@@ -663,7 +687,8 @@ tuplesort_performsort(Tuplesortstate *state)
 {
 	switch (state->status)
 	{
-		case TSS_INITIAL:
+			case TSS_INITIAL:
+
 			/*
 			 * We were able to accumulate all the tuples within the
 			 * allowed amount of memory.  Just qsort 'em and we're done.
@@ -681,8 +706,9 @@ tuplesort_performsort(Tuplesortstate *state)
 			state->status = TSS_SORTEDINMEM;
 			break;
 		case TSS_BUILDRUNS:
+
 			/*
-			 * Finish tape-based sort.  First, flush all tuples remaining
+			 * Finish tape-based sort.	First, flush all tuples remaining
 			 * in memory out to tape; then merge until we have a single
 			 * remaining run (or, if !randomAccess, one run per tape).
 			 * Note that mergeruns sets the correct state->status.
@@ -702,15 +728,15 @@ tuplesort_performsort(Tuplesortstate *state)
 
 /*
  * Fetch the next tuple in either forward or back direction.
- * Returns NULL if no more tuples.  If should_free is set, the
+ * Returns NULL if no more tuples.	If should_free is set, the
  * caller must pfree the returned tuple when done with it.
  */
 void *
 tuplesort_gettuple(Tuplesortstate *state, bool forward,
 				   bool *should_free)
 {
-	unsigned int	tuplen;
-	void		   *tup;
+	unsigned int tuplen;
+	void	   *tup;
 
 	switch (state->status)
 	{
@@ -728,15 +754,16 @@ tuplesort_gettuple(Tuplesortstate *state, bool forward,
 			{
 				if (state->current <= 0)
 					return NULL;
+
 				/*
-				 * if all tuples are fetched already then we return last tuple,
-				 * else - tuple before last returned.
+				 * if all tuples are fetched already then we return last
+				 * tuple, else - tuple before last returned.
 				 */
 				if (state->eof_reached)
 					state->eof_reached = false;
 				else
 				{
-					state->current--; /* last returned tuple */
+					state->current--;	/* last returned tuple */
 					if (state->current <= 0)
 						return NULL;
 				}
@@ -762,65 +789,74 @@ tuplesort_gettuple(Tuplesortstate *state, bool forward,
 					return NULL;
 				}
 			}
-			/* Backward.
+
+			/*
+			 * Backward.
 			 *
 			 * if all tuples are fetched already then we return last tuple,
 			 * else - tuple before last returned.
 			 */
 			if (state->eof_reached)
 			{
+
 				/*
-				 * Seek position is pointing just past the zero tuplen
-				 * at the end of file; back up to fetch last tuple's ending
-				 * length word.  If seek fails we must have a completely empty
-				 * file.
+				 * Seek position is pointing just past the zero tuplen at
+				 * the end of file; back up to fetch last tuple's ending
+				 * length word.  If seek fails we must have a completely
+				 * empty file.
 				 */
-				if (! LogicalTapeBackspace(state->tapeset,
-										   state->result_tape,
-										   2 * sizeof(unsigned int)))
+				if (!LogicalTapeBackspace(state->tapeset,
+										  state->result_tape,
+										  2 * sizeof(unsigned int)))
 					return NULL;
 				state->eof_reached = false;
 			}
 			else
 			{
+
 				/*
-				 * Back up and fetch previously-returned tuple's ending length
-				 * word.  If seek fails, assume we are at start of file.
+				 * Back up and fetch previously-returned tuple's ending
+				 * length word.  If seek fails, assume we are at start of
+				 * file.
 				 */
-				if (! LogicalTapeBackspace(state->tapeset,
-										   state->result_tape,
-										   sizeof(unsigned int)))
+				if (!LogicalTapeBackspace(state->tapeset,
+										  state->result_tape,
+										  sizeof(unsigned int)))
 					return NULL;
 				tuplen = getlen(state, state->result_tape, false);
+
 				/*
 				 * Back up to get ending length word of tuple before it.
 				 */
-				if (! LogicalTapeBackspace(state->tapeset,
-										   state->result_tape,
-										   tuplen + 2 * sizeof(unsigned int)))
+				if (!LogicalTapeBackspace(state->tapeset,
+										  state->result_tape,
+									  tuplen + 2 * sizeof(unsigned int)))
 				{
-					/* If that fails, presumably the prev tuple is the first
-					 * in the file.  Back up so that it becomes next to read
-					 * in forward direction (not obviously right, but that is
-					 * what in-memory case does).
+
+					/*
+					 * If that fails, presumably the prev tuple is the
+					 * first in the file.  Back up so that it becomes next
+					 * to read in forward direction (not obviously right,
+					 * but that is what in-memory case does).
 					 */
-					if (! LogicalTapeBackspace(state->tapeset,
-											   state->result_tape,
-											   tuplen + sizeof(unsigned int)))
+					if (!LogicalTapeBackspace(state->tapeset,
+											  state->result_tape,
+										  tuplen + sizeof(unsigned int)))
 						elog(ERROR, "tuplesort_gettuple: bogus tuple len in backward scan");
 					return NULL;
 				}
 			}
 
 			tuplen = getlen(state, state->result_tape, false);
+
 			/*
-			 * Now we have the length of the prior tuple, back up and read it.
-			 * Note: READTUP expects we are positioned after the initial
-			 * length word of the tuple, so back up to that point.
+			 * Now we have the length of the prior tuple, back up and read
+			 * it. Note: READTUP expects we are positioned after the
+			 * initial length word of the tuple, so back up to that point.
 			 */
-			if (! LogicalTapeBackspace(state->tapeset,
-									   state->result_tape,
-									   tuplen))
+			if (!LogicalTapeBackspace(state->tapeset,
+									  state->result_tape,
+									  tuplen))
 				elog(ERROR, "tuplesort_gettuple: bogus tuple len in backward scan");
 			tup = READTUP(state, state->result_tape, tuplen);
 			return tup;
@@ -828,15 +864,16 @@ tuplesort_gettuple(Tuplesortstate *state, bool forward,
 		case TSS_FINALMERGE:
 			Assert(forward);
 			*should_free = true;
+
 			/*
 			 * This code should match the inner loop of mergeonerun().
 			 */
 			if (state->memtupcount > 0)
 			{
-				int				srcTape = state->memtupindex[0];
-				unsigned int	tuplen;
-				int				tupIndex;
-				void		   *newtup;
+				int			srcTape = state->memtupindex[0];
+				unsigned int tuplen;
+				int			tupIndex;
+				void	   *newtup;
 
 				tup = state->memtuples[0];
 				/* returned tuple is no longer counted in our memory space */
@@ -846,9 +883,17 @@ tuplesort_gettuple(Tuplesortstate *state, bool forward,
 				tuplesort_heap_siftup(state, false);
 				if ((tupIndex = state->mergenext[srcTape]) == 0)
 				{
-					/* out of preloaded data on this tape, try to read more */
+
+					/*
+					 * out of preloaded data on this tape, try to read
+					 * more
+					 */
 					mergepreread(state);
-					/* if still no data, we've reached end of run on this tape */
+
+					/*
+					 * if still no data, we've reached end of run on this
+					 * tape
+					 */
 					if ((tupIndex = state->mergenext[srcTape]) == 0)
 						return tup;
 				}
@@ -881,8 +926,8 @@ bool
 tuplesort_getdatum(Tuplesortstate *state, bool forward,
 				   Datum *val, bool *isNull)
 {
-	DatumTuple	   *tuple;
-	bool			should_free;
+	DatumTuple *tuple;
+	bool		should_free;
 
 	tuple = (DatumTuple *) tuplesort_gettuple(state, forward, &should_free);
 
@@ -896,8 +941,8 @@ tuplesort_getdatum(Tuplesortstate *state, bool forward,
 	}
 	else
 	{
-		int		datalen = state->datumTypeLen;
-		char   *newVal;
+		int			datalen = state->datumTypeLen;
+		char	   *newVal;
 
 		if (datalen == -1)		/* variable length type? */
 			datalen = VARSIZE((struct varlena *) DatumGetPointer(tuple->val));
@@ -933,15 +978,15 @@ inittapes(Tuplesortstate *state)
 	state->memtupindex = (int *) palloc(state->memtupsize * sizeof(int));
 
 	/*
-	 * Convert the unsorted contents of memtuples[] into a heap.
-	 * Each tuple is marked as belonging to run number zero.
+	 * Convert the unsorted contents of memtuples[] into a heap. Each
+	 * tuple is marked as belonging to run number zero.
 	 *
-	 * NOTE: we pass false for checkIndex since there's no point in
-	 * comparing indexes in this step, even though we do intend the
-	 * indexes to be part of the sort key...
+	 * NOTE: we pass false for checkIndex since there's no point in comparing
+	 * indexes in this step, even though we do intend the indexes to be
+	 * part of the sort key...
 	 */
 	ntuples = state->memtupcount;
-	state->memtupcount = 0;			/* make the heap empty */
+	state->memtupcount = 0;		/* make the heap empty */
 	for (j = 0; j < ntuples; j++)
 		tuplesort_heap_insert(state, state->memtuples[j], 0, false);
 	Assert(state->memtupcount == ntuples);
@@ -976,11 +1021,11 @@ inittapes(Tuplesortstate *state)
 static void
 selectnewtape(Tuplesortstate *state)
 {
-	int		j;
-	int		a;
+	int			j;
+	int			a;
 
 	/* Step D3: advance j (destTape) */
-	if (state->tp_dummy[state->destTape] < state->tp_dummy[state->destTape+1])
+	if (state->tp_dummy[state->destTape] < state->tp_dummy[state->destTape + 1])
 	{
 		state->destTape++;
 		return;
@@ -996,8 +1041,8 @@ selectnewtape(Tuplesortstate *state)
 	a = state->tp_fib[0];
 	for (j = 0; j < TAPERANGE; j++)
 	{
-		state->tp_dummy[j] = a + state->tp_fib[j+1] - state->tp_fib[j];
-		state->tp_fib[j] = a + state->tp_fib[j+1];
+		state->tp_dummy[j] = a + state->tp_fib[j + 1] - state->tp_fib[j];
+		state->tp_fib[j] = a + state->tp_fib[j + 1];
 	}
 	state->destTape = 0;
 }
@@ -1011,17 +1056,18 @@ selectnewtape(Tuplesortstate *state)
 static void
 mergeruns(Tuplesortstate *state)
 {
-	int		tapenum,
-			svTape,
-			svRuns,
-			svDummy;
+	int			tapenum,
+				svTape,
+				svRuns,
+				svDummy;
 
 	Assert(state->status == TSS_BUILDRUNS);
 	Assert(state->memtupcount == 0);
+
 	/*
-	 * If we produced only one initial run (quite likely if the total
-	 * data volume is between 1X and 2X SortMem), we can just use that
-	 * tape as the finished output, rather than doing a useless merge.
+	 * If we produced only one initial run (quite likely if the total data
+	 * volume is between 1X and 2X SortMem), we can just use that tape as
+	 * the finished output, rather than doing a useless merge.
 	 */
 	if (state->currentRun == 1)
 	{
@@ -1039,10 +1085,10 @@ mergeruns(Tuplesortstate *state)
 	for (;;)
 	{
 		/* Step D5: merge runs onto tape[T] until tape[P] is empty */
-		while (state->tp_runs[TAPERANGE-1] || state->tp_dummy[TAPERANGE-1])
+		while (state->tp_runs[TAPERANGE - 1] || state->tp_dummy[TAPERANGE - 1])
 		{
-			bool	allDummy = true;
-			bool	allOneRun = true;
+			bool		allDummy = true;
+			bool		allOneRun = true;
 
 			for (tapenum = 0; tapenum < TAPERANGE; tapenum++)
 			{
@@ -1051,28 +1097,27 @@ mergeruns(Tuplesortstate *state)
 				if (state->tp_runs[tapenum] + state->tp_dummy[tapenum] != 1)
 					allOneRun = false;
 			}
+
 			/*
 			 * If we don't have to produce a materialized sorted tape,
 			 * quit as soon as we're down to one real/dummy run per tape.
 			 */
-			if (! state->randomAccess && allOneRun)
+			if (!state->randomAccess && allOneRun)
 			{
-				Assert(! allDummy);
+				Assert(!allDummy);
 				/* Initialize for the final merge pass */
 				beginmerge(state);
 				state->status = TSS_FINALMERGE;
 				return;
 			}
 			if (allDummy)
-			{	
+			{
 				state->tp_dummy[TAPERANGE]++;
 				for (tapenum = 0; tapenum < TAPERANGE; tapenum++)
 					state->tp_dummy[tapenum]--;
 			}
 			else
-			{
 				mergeonerun(state);
-			}
 		}
 		/* Step D6: decrease level */
 		if (--state->Level == 0)
@@ -1081,30 +1126,35 @@ mergeruns(Tuplesortstate *state)
 		LogicalTapeRewind(state->tapeset, state->tp_tapenum[TAPERANGE],
 						  false);
 		/* rewind used-up input tape P, and prepare it for write pass */
-		LogicalTapeRewind(state->tapeset, state->tp_tapenum[TAPERANGE-1],
+		LogicalTapeRewind(state->tapeset, state->tp_tapenum[TAPERANGE - 1],
 						  true);
-		state->tp_runs[TAPERANGE-1] = 0;
-		/* reassign tape units per step D6; note we no longer care about A[] */
+		state->tp_runs[TAPERANGE - 1] = 0;
+
+		/*
+		 * reassign tape units per step D6; note we no longer care about
+		 * A[]
+		 */
 		svTape = state->tp_tapenum[TAPERANGE];
 		svDummy = state->tp_dummy[TAPERANGE];
 		svRuns = state->tp_runs[TAPERANGE];
 		for (tapenum = TAPERANGE; tapenum > 0; tapenum--)
 		{
-			state->tp_tapenum[tapenum] = state->tp_tapenum[tapenum-1];
-			state->tp_dummy[tapenum] = state->tp_dummy[tapenum-1];
-			state->tp_runs[tapenum] = state->tp_runs[tapenum-1];
+			state->tp_tapenum[tapenum] = state->tp_tapenum[tapenum - 1];
+			state->tp_dummy[tapenum] = state->tp_dummy[tapenum - 1];
+			state->tp_runs[tapenum] = state->tp_runs[tapenum - 1];
 		}
 		state->tp_tapenum[0] = svTape;
 		state->tp_dummy[0] = svDummy;
 		state->tp_runs[0] = svRuns;
 	}
+
 	/*
-	 * Done.  Knuth says that the result is on TAPE[1], but since we exited
-	 * the loop without performing the last iteration of step D6, we have not
-	 * rearranged the tape unit assignment, and therefore the result is on
-	 * TAPE[T].  We need to do it this way so that we can freeze the final
-	 * output tape while rewinding it.  The last iteration of step D6 would
-	 * be a waste of cycles anyway...
+	 * Done.  Knuth says that the result is on TAPE[1], but since we
+	 * exited the loop without performing the last iteration of step D6,
+	 * we have not rearranged the tape unit assignment, and therefore the
+	 * result is on TAPE[T].  We need to do it this way so that we can
+	 * freeze the final output tape while rewinding it.  The last
+	 * iteration of step D6 would be a waste of cycles anyway...
 	 */
 	state->result_tape = state->tp_tapenum[TAPERANGE];
 	LogicalTapeFreeze(state->tapeset, state->result_tape);
@@ -1120,23 +1170,24 @@ mergeruns(Tuplesortstate *state)
 static void
 mergeonerun(Tuplesortstate *state)
 {
-	int				destTape = state->tp_tapenum[TAPERANGE];
-	int				srcTape;
-	int				tupIndex;
-	void		   *tup;
-	long			priorAvail,
-					spaceFreed;
+	int			destTape = state->tp_tapenum[TAPERANGE];
+	int			srcTape;
+	int			tupIndex;
+	void	   *tup;
+	long		priorAvail,
+				spaceFreed;
 
 	/*
 	 * Start the merge by loading one tuple from each active source tape
-	 * into the heap.  We can also decrease the input run/dummy run counts.
+	 * into the heap.  We can also decrease the input run/dummy run
+	 * counts.
 	 */
 	beginmerge(state);
 
 	/*
 	 * Execute merge by repeatedly extracting lowest tuple in heap,
-	 * writing it out, and replacing it with next tuple from same tape
-	 * (if there is another one).
+	 * writing it out, and replacing it with next tuple from same tape (if
+	 * there is another one).
 	 */
 	while (state->memtupcount > 0)
 	{
@@ -1166,9 +1217,10 @@ mergeonerun(Tuplesortstate *state)
 		state->mergefreelist = tupIndex;
 		tuplesort_heap_insert(state, tup, srcTape, false);
 	}
+
 	/*
-	 * When the heap empties, we're done.  Write an end-of-run marker
-	 * on the output tape, and increment its count of real runs.
+	 * When the heap empties, we're done.  Write an end-of-run marker on
+	 * the output tape, and increment its count of real runs.
 	 */
 	markrunend(state, destTape);
 	state->tp_runs[TAPERANGE]++;
@@ -1178,16 +1230,16 @@ mergeonerun(Tuplesortstate *state)
  * beginmerge - initialize for a merge pass
  *
  * We decrease the counts of real and dummy runs for each tape, and mark
- * which tapes contain active input runs in mergeactive[].  Then, load
+ * which tapes contain active input runs in mergeactive[].	Then, load
  * as many tuples as we can from each active input tape, and finally
  * fill the merge heap with the first tuple from each active tape.
  */
 static void
 beginmerge(Tuplesortstate *state)
 {
-	int				activeTapes;
-	int				tapenum;
-	int				srcTape;
+	int			activeTapes;
+	int			tapenum;
+	int			srcTape;
 
 	/* Heap should be empty here */
 	Assert(state->memtupcount == 0);
@@ -1198,16 +1250,15 @@ beginmerge(Tuplesortstate *state)
 	memset(state->mergelast, 0, sizeof(state->mergelast));
 	memset(state->mergeavailmem, 0, sizeof(state->mergeavailmem));
 	state->mergefreelist = 0;	/* nothing in the freelist */
-	state->mergefirstfree = MAXTAPES; /* first slot available for preread */
+	state->mergefirstfree = MAXTAPES;	/* first slot available for
+										 * preread */
 
 	/* Adjust run counts and mark the active tapes */
 	activeTapes = 0;
 	for (tapenum = 0; tapenum < TAPERANGE; tapenum++)
 	{
 		if (state->tp_dummy[tapenum] > 0)
-		{
 			state->tp_dummy[tapenum]--;
-		}
 		else
 		{
 			Assert(state->tp_runs[tapenum] > 0);
@@ -1219,8 +1270,8 @@ beginmerge(Tuplesortstate *state)
 	}
 
 	/*
-	 * Initialize space allocation to let each active input tape have
-	 * an equal share of preread space.
+	 * Initialize space allocation to let each active input tape have an
+	 * equal share of preread space.
 	 */
 	Assert(activeTapes > 0);
 	state->spacePerTape = state->availMem / activeTapes;
@@ -1261,39 +1312,41 @@ beginmerge(Tuplesortstate *state)
  * This routine exists to improve sequentiality of reads during a merge pass,
  * as explained in the header comments of this file.  Load tuples from each
  * active source tape until the tape's run is exhausted or it has used up
- * its fair share of available memory.  In any case, we guarantee that there
+ * its fair share of available memory.	In any case, we guarantee that there
  * is at one preread tuple available from each unexhausted input tape.
  */
 static void
 mergepreread(Tuplesortstate *state)
 {
-	int				srcTape;
-	unsigned int	tuplen;
-	void		   *tup;
-	int				tupIndex;
-	long			priorAvail,
-					spaceUsed;
+	int			srcTape;
+	unsigned int tuplen;
+	void	   *tup;
+	int			tupIndex;
+	long		priorAvail,
+				spaceUsed;
 
 	for (srcTape = 0; srcTape < MAXTAPES; srcTape++)
 	{
-		if (! state->mergeactive[srcTape])
+		if (!state->mergeactive[srcTape])
 			continue;
+
 		/*
-		 * Skip reading from any tape that still has at least half
-		 * of its target memory filled with tuples (threshold fraction
-		 * may need adjustment?).  This avoids reading just a few tuples
-		 * when the incoming runs are not being consumed evenly.
+		 * Skip reading from any tape that still has at least half of its
+		 * target memory filled with tuples (threshold fraction may need
+		 * adjustment?).  This avoids reading just a few tuples when the
+		 * incoming runs are not being consumed evenly.
 		 */
 		if (state->mergenext[srcTape] != 0 &&
 			state->mergeavailmem[srcTape] <= state->spacePerTape / 2)
 			continue;
+
 		/*
-		 * Read tuples from this tape until it has used up its free memory,
-		 * but ensure that we have at least one.
+		 * Read tuples from this tape until it has used up its free
+		 * memory, but ensure that we have at least one.
 		 */
 		priorAvail = state->availMem;
 		state->availMem = state->mergeavailmem[srcTape];
-		while (! LACKMEM(state) || state->mergenext[srcTape] == 0)
+		while (!LACKMEM(state) || state->mergenext[srcTape] == 0)
 		{
 			/* read next tuple, if any */
 			if ((tuplen = getlen(state, srcTape, true)) == 0)
@@ -1359,17 +1412,19 @@ dumptuples(Tuplesortstate *state, bool alltuples)
 	while (alltuples ||
 		   (LACKMEM(state) && state->memtupcount > 1))
 	{
+
 		/*
-		 * Dump the heap's frontmost entry, and sift up to remove it
-		 * from the heap.
+		 * Dump the heap's frontmost entry, and sift up to remove it from
+		 * the heap.
 		 */
 		Assert(state->memtupcount > 0);
 		WRITETUP(state, state->tp_tapenum[state->destTape],
 				 state->memtuples[0]);
 		tuplesort_heap_siftup(state, true);
+
 		/*
-		 * If the heap is empty *or* top run number has changed,
-		 * we've finished the current run.
+		 * If the heap is empty *or* top run number has changed, we've
+		 * finished the current run.
 		 */
 		if (state->memtupcount == 0 ||
 			state->currentRun != state->memtupindex[0])
@@ -1377,7 +1432,8 @@ dumptuples(Tuplesortstate *state, bool alltuples)
 			markrunend(state, state->tp_tapenum[state->destTape]);
 			state->currentRun++;
 			state->tp_runs[state->destTape]++;
-			state->tp_dummy[state->destTape]--;	/* per Alg D step D2 */
+			state->tp_dummy[state->destTape]--; /* per Alg D step D2 */
+
 			/*
 			 * Done if heap is empty, else prepare for new run.
 			 */
@@ -1437,8 +1493,8 @@ tuplesort_markpos(Tuplesortstate *state)
 		case TSS_SORTEDONTAPE:
 			LogicalTapeTell(state->tapeset,
 							state->result_tape,
-							& state->markpos_block,
-							& state->markpos_offset);
+							&state->markpos_block,
+							&state->markpos_offset);
 			state->markpos_eof = state->eof_reached;
 			break;
 		default:
@@ -1448,7 +1504,7 @@ tuplesort_markpos(Tuplesortstate *state)
 }
 
 /*
- * tuplesort_restorepos	- restores current position in merged sort file to
+ * tuplesort_restorepos - restores current position in merged sort file to
  *						  last saved position
  */
 void
@@ -1463,10 +1519,10 @@ tuplesort_restorepos(Tuplesortstate *state)
 			state->eof_reached = state->markpos_eof;
 			break;
 		case TSS_SORTEDONTAPE:
-			if (! LogicalTapeSeek(state->tapeset,
-								  state->result_tape,
-								  state->markpos_block,
-								  state->markpos_offset))
+			if (!LogicalTapeSeek(state->tapeset,
+								 state->result_tape,
+								 state->markpos_block,
+								 state->markpos_offset))
 				elog(ERROR, "tuplesort_restorepos failed");
 			state->eof_reached = state->markpos_eof;
 			break;
@@ -1497,9 +1553,9 @@ static void
 tuplesort_heap_insert(Tuplesortstate *state, void *tuple,
 					  int tupleindex, bool checkIndex)
 {
-	void  **memtuples;
-	int	   *memtupindex;
-	int		j;
+	void	  **memtuples;
+	int		   *memtupindex;
+	int			j;
 
 	/*
 	 * Make sure memtuples[] can handle another entry.
@@ -1516,14 +1572,15 @@ tuplesort_heap_insert(Tuplesortstate *state, void *tuple,
 	}
 	memtuples = state->memtuples;
 	memtupindex = state->memtupindex;
+
 	/*
-	 * Sift-up the new entry, per Knuth 5.2.3 exercise 16.
-	 * Note that Knuth is using 1-based array indexes, not 0-based.
+	 * Sift-up the new entry, per Knuth 5.2.3 exercise 16. Note that Knuth
+	 * is using 1-based array indexes, not 0-based.
 	 */
 	j = state->memtupcount++;
 	while (j > 0)
 	{
-		int		i = (j-1) >> 1;
+		int			i = (j - 1) >> 1;
 
 		if (HEAPCOMPARE(tuple, tupleindex,
 						memtuples[i], memtupindex[i]) >= 0)
@@ -1543,12 +1600,12 @@ tuplesort_heap_insert(Tuplesortstate *state, void *tuple,
 static void
 tuplesort_heap_siftup(Tuplesortstate *state, bool checkIndex)
 {
-	void  **memtuples = state->memtuples;
-	int	   *memtupindex = state->memtupindex;
-	void   *tuple;
-	int		tupindex,
-			i,
-			n;
+	void	  **memtuples = state->memtuples;
+	int		   *memtupindex = state->memtupindex;
+	void	   *tuple;
+	int			tupindex,
+				i,
+				n;
 
 	if (--state->memtupcount <= 0)
 		return;
@@ -1556,15 +1613,15 @@ tuplesort_heap_siftup(Tuplesortstate *state, bool checkIndex)
 	tuple = memtuples[n];		/* tuple that must be reinserted */
 	tupindex = memtupindex[n];
 	i = 0;						/* i is where the "hole" is */
-    for (;;)
+	for (;;)
 	{
-		int		j = 2*i + 1;
+		int			j = 2 * i + 1;
 
 		if (j >= n)
 			break;
-		if (j+1 < n &&
+		if (j + 1 < n &&
 			HEAPCOMPARE(memtuples[j], memtupindex[j],
-						memtuples[j+1], memtupindex[j+1]) > 0)
+						memtuples[j + 1], memtupindex[j + 1]) > 0)
 			j++;
 		if (HEAPCOMPARE(tuple, tupindex,
 						memtuples[j], memtupindex[j]) <= 0)
@@ -1572,8 +1629,8 @@ tuplesort_heap_siftup(Tuplesortstate *state, bool checkIndex)
 		memtuples[i] = memtuples[j];
 		memtupindex[i] = memtupindex[j];
 		i = j;
-    }
-    memtuples[i] = tuple;
+	}
+	memtuples[i] = tuple;
 	memtupindex[i] = tupindex;
 }
 
@@ -1585,7 +1642,7 @@ tuplesort_heap_siftup(Tuplesortstate *state, bool checkIndex)
 static unsigned int
 getlen(Tuplesortstate *state, int tapenum, bool eofOK)
 {
-	unsigned int	len;
+	unsigned int len;
 
 	if (LogicalTapeRead(state->tapeset, tapenum, (void *) &len,
 						sizeof(len)) != sizeof(len))
@@ -1598,7 +1655,7 @@ getlen(Tuplesortstate *state, int tapenum, bool eofOK)
 static void
 markrunend(Tuplesortstate *state, int tapenum)
 {
-	unsigned int	len = 0;
+	unsigned int len = 0;
 
 	LogicalTapeWrite(state->tapeset, tapenum, (void *) &len, sizeof(len));
 }
@@ -1613,7 +1670,7 @@ qsort_comparetup(const void *a, const void *b)
 {
 	/* The passed pointers are pointers to void * ... */
 
-	return COMPARETUP(qsort_tuplesortstate, * (void **) a, * (void **) b);
+	return COMPARETUP(qsort_tuplesortstate, *(void **) a, *(void **) b);
 }
 
 
@@ -1651,14 +1708,14 @@ comparetup_heap(Tuplesortstate *state, const void *a, const void *b)
 			return -1;
 		else if (scanKey->sk_flags & SK_COMMUTE)
 		{
-			if (!(result = - (int) (*fmgr_faddr(&scanKey->sk_func)) (rattr, lattr)))
+			if (!(result = -(int) (*fmgr_faddr(&scanKey->sk_func)) (rattr, lattr)))
 				result = (int) (*fmgr_faddr(&scanKey->sk_func)) (lattr, rattr);
 			if (result)
 				return result;
 		}
 		else
 		{
-			if (!(result = - (int) (*fmgr_faddr(&scanKey->sk_func)) (lattr, rattr)))
+			if (!(result = -(int) (*fmgr_faddr(&scanKey->sk_func)) (lattr, rattr)))
 				result = (int) (*fmgr_faddr(&scanKey->sk_func)) (rattr, lattr);
 			if (result)
 				return result;
@@ -1684,17 +1741,17 @@ copytup_heap(Tuplesortstate *state, void *tup)
 static void
 writetup_heap(Tuplesortstate *state, int tapenum, void *tup)
 {
-	HeapTuple		tuple = (HeapTuple) tup;
-	unsigned int	tuplen;
+	HeapTuple	tuple = (HeapTuple) tup;
+	unsigned int tuplen;
 
 	tuplen = tuple->t_len + sizeof(tuplen);
 	LogicalTapeWrite(state->tapeset, tapenum,
-					 (void*) &tuplen, sizeof(tuplen));
+					 (void *) &tuplen, sizeof(tuplen));
 	LogicalTapeWrite(state->tapeset, tapenum,
-					 (void*) tuple->t_data, tuple->t_len);
+					 (void *) tuple->t_data, tuple->t_len);
 	if (state->randomAccess)	/* need trailing length word? */
 		LogicalTapeWrite(state->tapeset, tapenum,
-						 (void*) &tuplen, sizeof(tuplen));
+						 (void *) &tuplen, sizeof(tuplen));
 
 	FREEMEM(state, HEAPTUPLESIZE + tuple->t_len);
 	heap_freetuple(tuple);
@@ -1703,8 +1760,8 @@ writetup_heap(Tuplesortstate *state, int tapenum, void *tup)
 static void *
 readtup_heap(Tuplesortstate *state, int tapenum, unsigned int len)
 {
-	unsigned int	tuplen = len - sizeof(unsigned int) + HEAPTUPLESIZE;
-	HeapTuple		tuple = (HeapTuple) palloc(tuplen);
+	unsigned int tuplen = len - sizeof(unsigned int) + HEAPTUPLESIZE;
+	HeapTuple	tuple = (HeapTuple) palloc(tuplen);
 
 	USEMEM(state, tuplen);
 	/* reconstruct the HeapTupleData portion */
@@ -1736,7 +1793,7 @@ tuplesize_heap(Tuplesortstate *state, void *tup)
  * Routines specialized for IndexTuple case
  *
  * NOTE: actually, these are specialized for the btree case; it's not
- * clear whether you could use them for a non-btree index.  Possibly
+ * clear whether you could use them for a non-btree index.	Possibly
  * you'd need to make another set of routines if you needed to sort
  * according to another kind of index.
  */
@@ -1744,9 +1801,10 @@ tuplesize_heap(Tuplesortstate *state, void *tup)
 static int
 comparetup_index(Tuplesortstate *state, const void *a, const void *b)
 {
+
 	/*
-	 * This is almost the same as _bt_tuplecompare(), but we need to
-	 * keep track of whether any null fields are present.
+	 * This is almost the same as _bt_tuplecompare(), but we need to keep
+	 * track of whether any null fields are present.
 	 */
 	IndexTuple	tuple1 = (IndexTuple) a;
 	IndexTuple	tuple2 = (IndexTuple) b;
@@ -1793,7 +1851,8 @@ comparetup_index(Tuplesortstate *state, const void *a, const void *b)
 		}
 
 		if (compare != 0)
-			return (int) compare; /* done when we find unequal attributes */
+			return (int) compare;		/* done when we find unequal
+										 * attributes */
 	}
 
 	/*
@@ -1801,9 +1860,9 @@ comparetup_index(Tuplesortstate *state, const void *a, const void *b)
 	 * tuples are detected (unless there was at least one NULL field).
 	 *
 	 * It is sufficient to make the test here, because if two tuples are
-	 * equal they *must* get compared at some stage of the sort --- otherwise
-	 * the sort algorithm wouldn't have checked whether one must appear
-	 * before the other.
+	 * equal they *must* get compared at some stage of the sort ---
+	 * otherwise the sort algorithm wouldn't have checked whether one must
+	 * appear before the other.
 	 */
 	if (state->enforceUnique && !equal_hasnull)
 		elog(ERROR, "Cannot create unique index. Table contains non-unique values");
@@ -1814,9 +1873,9 @@ comparetup_index(Tuplesortstate *state, const void *a, const void *b)
 static void *
 copytup_index(Tuplesortstate *state, void *tup)
 {
-	IndexTuple		tuple = (IndexTuple) tup;
-	unsigned int	tuplen = IndexTupleSize(tuple);
-	IndexTuple		newtuple;
+	IndexTuple	tuple = (IndexTuple) tup;
+	unsigned int tuplen = IndexTupleSize(tuple);
+	IndexTuple	newtuple;
 
 	USEMEM(state, tuplen);
 	newtuple = (IndexTuple) palloc(tuplen);
@@ -1828,17 +1887,17 @@ copytup_index(Tuplesortstate *state, void *tup)
 static void
 writetup_index(Tuplesortstate *state, int tapenum, void *tup)
 {
-	IndexTuple		tuple = (IndexTuple) tup;
-	unsigned int	tuplen;
+	IndexTuple	tuple = (IndexTuple) tup;
+	unsigned int tuplen;
 
 	tuplen = IndexTupleSize(tuple) + sizeof(tuplen);
 	LogicalTapeWrite(state->tapeset, tapenum,
-					 (void*) &tuplen, sizeof(tuplen));
+					 (void *) &tuplen, sizeof(tuplen));
 	LogicalTapeWrite(state->tapeset, tapenum,
-					 (void*) tuple, IndexTupleSize(tuple));
+					 (void *) tuple, IndexTupleSize(tuple));
 	if (state->randomAccess)	/* need trailing length word? */
 		LogicalTapeWrite(state->tapeset, tapenum,
-						 (void*) &tuplen, sizeof(tuplen));
+						 (void *) &tuplen, sizeof(tuplen));
 
 	FREEMEM(state, IndexTupleSize(tuple));
 	pfree(tuple);
@@ -1847,8 +1906,8 @@ writetup_index(Tuplesortstate *state, int tapenum, void *tup)
 static void *
 readtup_index(Tuplesortstate *state, int tapenum, unsigned int len)
 {
-	unsigned int	tuplen = len - sizeof(unsigned int);
-	IndexTuple		tuple = (IndexTuple) palloc(tuplen);
+	unsigned int tuplen = len - sizeof(unsigned int);
+	IndexTuple	tuple = (IndexTuple) palloc(tuplen);
 
 	USEMEM(state, tuplen);
 	if (LogicalTapeRead(state->tapeset, tapenum, (void *) tuple,
@@ -1864,8 +1923,8 @@ readtup_index(Tuplesortstate *state, int tapenum, unsigned int len)
 static unsigned int
 tuplesize_index(Tuplesortstate *state, void *tup)
 {
-	IndexTuple		tuple = (IndexTuple) tup;
-	unsigned int	tuplen = IndexTupleSize(tuple);
+	IndexTuple	tuple = (IndexTuple) tup;
+	unsigned int tuplen = IndexTupleSize(tuple);
 
 	return tuplen;
 }
@@ -1891,10 +1950,10 @@ comparetup_datum(Tuplesortstate *state, const void *a, const void *b)
 		return -1;
 	else
 	{
-		int		result;
+		int			result;
 
-		if (!(result = - (int) (*fmgr_faddr(&state->sortOpFn)) (ltup->val,
-																rtup->val)))
+		if (!(result = -(int) (*fmgr_faddr(&state->sortOpFn)) (ltup->val,
+															 rtup->val)))
 			result = (int) (*fmgr_faddr(&state->sortOpFn)) (rtup->val,
 															ltup->val);
 		return result;
@@ -1912,17 +1971,17 @@ copytup_datum(Tuplesortstate *state, void *tup)
 static void
 writetup_datum(Tuplesortstate *state, int tapenum, void *tup)
 {
-	DatumTuple	   *tuple = (DatumTuple *) tup;
-	unsigned int	tuplen = tuplesize_datum(state, tup);
-	unsigned int	writtenlen = tuplen + sizeof(unsigned int);
+	DatumTuple *tuple = (DatumTuple *) tup;
+	unsigned int tuplen = tuplesize_datum(state, tup);
+	unsigned int writtenlen = tuplen + sizeof(unsigned int);
 
 	LogicalTapeWrite(state->tapeset, tapenum,
-					 (void*) &writtenlen, sizeof(writtenlen));
+					 (void *) &writtenlen, sizeof(writtenlen));
 	LogicalTapeWrite(state->tapeset, tapenum,
-					 (void*) tuple, tuplen);
+					 (void *) tuple, tuplen);
 	if (state->randomAccess)	/* need trailing length word? */
 		LogicalTapeWrite(state->tapeset, tapenum,
-						 (void*) &writtenlen, sizeof(writtenlen));
+						 (void *) &writtenlen, sizeof(writtenlen));
 
 	FREEMEM(state, tuplen);
 	pfree(tuple);
@@ -1931,8 +1990,8 @@ writetup_datum(Tuplesortstate *state, int tapenum, void *tup)
 static void *
 readtup_datum(Tuplesortstate *state, int tapenum, unsigned int len)
 {
-	unsigned int	tuplen = len - sizeof(unsigned int);
-	DatumTuple	   *tuple = (DatumTuple *) palloc(tuplen);
+	unsigned int tuplen = len - sizeof(unsigned int);
+	DatumTuple *tuple = (DatumTuple *) palloc(tuplen);
 
 	USEMEM(state, tuplen);
 	if (LogicalTapeRead(state->tapeset, tapenum, (void *) tuple,
@@ -1952,16 +2011,14 @@ readtup_datum(Tuplesortstate *state, int tapenum, unsigned int len)
 static unsigned int
 tuplesize_datum(Tuplesortstate *state, void *tup)
 {
-	DatumTuple	   *tuple = (DatumTuple *) tup;
+	DatumTuple *tuple = (DatumTuple *) tup;
 
 	if (tuple->isNull || state->datumTypeByVal)
-	{
 		return (unsigned int) sizeof(DatumTuple);
-	}
 	else
 	{
-		int		datalen = state->datumTypeLen;
-		int		tuplelen;
+		int			datalen = state->datumTypeLen;
+		int			tuplelen;
 
 		if (datalen == -1)		/* variable length type? */
 			datalen = VARSIZE((struct varlena *) DatumGetPointer(tuple->val));
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
index 59312a93f6b6dd4d987f509626298e5d8d2d3cec..458f871e7ab654fec54d2e6a410a756e114ecc9e 100644
--- a/src/bin/pg_dump/common.c
+++ b/src/bin/pg_dump/common.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.40 2000/01/26 05:57:38 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.41 2000/04/12 17:16:14 momjian Exp $
  *
  * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
  *
@@ -190,7 +190,7 @@ parseNumericArray(const char *str, char **array, int arraysize)
 		}
 		else
 		{
-			if (!isdigit(s) || j >= sizeof(temp)-1)
+			if (!isdigit(s) || j >= sizeof(temp) - 1)
 			{
 				fprintf(stderr, "parseNumericArray: bogus number\n");
 				exit(2);
@@ -514,15 +514,15 @@ fmtId(const char *rawid, bool force_quotes)
 {
 	static PQExpBuffer id_return = NULL;
 	const char *cp;
-	
+
 	if (!force_quotes)
 	{
-		if (! islower(*rawid))
+		if (!islower(*rawid))
 			force_quotes = true;
 		else
 			for (cp = rawid; *cp; cp++)
 			{
-				if (! (islower(*cp) || isdigit(*cp) || (*cp == '_')))
+				if (!(islower(*cp) || isdigit(*cp) || (*cp == '_')))
 				{
 					force_quotes = true;
 					break;
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 1ca50728365f4bc6cb91f050a3e3ff15be6c9b57..dd1760a9cea7f9b550d6e3a748125375b07100bd 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -22,7 +22,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.145 2000/04/04 05:22:46 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.146 2000/04/12 17:16:14 momjian Exp $
  *
  * Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
  *
@@ -128,59 +128,59 @@ static void
 help(const char *progname)
 {
 	printf("%s dumps a database as a text file.\n\n", progname);
-    puts(  "Usage:");
-    printf("  %s [options] dbname\n\n", progname);
-    puts(  "Options:");
+	puts("Usage:");
+	printf("  %s [options] dbname\n\n", progname);
+	puts("Options:");
 
 #ifdef HAVE_GETOPT_LONG
 	puts(
-        "  -a, --data-only          dump out only the data, not the schema\n"
-        "  -c, --clean              clean (drop) schema prior to create\n"
-        "  -d, --inserts            dump data as INSERT, rather than COPY, commands\n"
-        "  -D, --attribute-inserts  dump data as INSERT commands with attribute names\n"
-        "  -h, --host <hostname>    server host name\n"
-        "  -i, --ignore-version     proceed when database version != pg_dump version\n"
-        "  -n, --no-quotes          suppress most quotes around identifiers\n"
-        "  -N, --quotes             enable most quotes around identifiers\n"
-        "  -o, --oids               dump object ids (oids)\n"
-        "  -p, --port <port>        server port number\n"
-        "  -s, --schema-only        dump out only the schema, no data\n"
-        "  -t, --table <table>      dump for this table only\n"
-        "  -u, --password           use password authentication\n"
-        "  -v, --verbose            verbose\n"
-        "  -x, --no-acl             do not dump ACL's (grant/revoke)\n"
-        );
+	"  -a, --data-only          dump out only the data, not the schema\n"
+	   "  -c, --clean              clean (drop) schema prior to create\n"
+		 "  -d, --inserts            dump data as INSERT, rather than COPY, commands\n"
+		 "  -D, --attribute-inserts  dump data as INSERT commands with attribute names\n"
+		 "  -h, --host <hostname>    server host name\n"
+		 "  -i, --ignore-version     proceed when database version != pg_dump version\n"
+	"  -n, --no-quotes          suppress most quotes around identifiers\n"
+	 "  -N, --quotes             enable most quotes around identifiers\n"
+		 "  -o, --oids               dump object ids (oids)\n"
+		 "  -p, --port <port>        server port number\n"
+		 "  -s, --schema-only        dump out only the schema, no data\n"
+		 "  -t, --table <table>      dump for this table only\n"
+		 "  -u, --password           use password authentication\n"
+		 "  -v, --verbose            verbose\n"
+		 "  -x, --no-acl             do not dump ACL's (grant/revoke)\n"
+		);
 #else
-    puts(
-        "  -a                       dump out only the data, no schema\n"
-        "  -c                       clean (drop) schema prior to create\n"
-        "  -d                       dump data as INSERT, rather than COPY, commands\n"
-        "  -D                       dump data as INSERT commands with attribute names\n"
-        "  -h <hostname>            server host name\n"
-        "  -i                       proceed when database version != pg_dump version\n"
-        "  -n                       suppress most quotes around identifiers\n"
-        "  -N                       enable most quotes around identifiers\n"
-        "  -o                       dump object ids (oids)\n"
-        "  -p <port>                server port number\n"
-        "  -s                       dump out only the schema, no data\n"
-        "  -t <table>               dump for this table only\n"
-        "  -u                       use password authentication\n"
-        "  -v                       verbose\n"
-        "  -x                       do not dump ACL's (grant/revoke)\n"
-        );
+	puts(
+		 "  -a                       dump out only the data, no schema\n"
+	   "  -c                       clean (drop) schema prior to create\n"
+		 "  -d                       dump data as INSERT, rather than COPY, commands\n"
+		 "  -D                       dump data as INSERT commands with attribute names\n"
+		 "  -h <hostname>            server host name\n"
+		 "  -i                       proceed when database version != pg_dump version\n"
+	"  -n                       suppress most quotes around identifiers\n"
+	 "  -N                       enable most quotes around identifiers\n"
+		 "  -o                       dump object ids (oids)\n"
+		 "  -p <port>                server port number\n"
+		 "  -s                       dump out only the schema, no data\n"
+		 "  -t <table>               dump for this table only\n"
+		 "  -u                       use password authentication\n"
+		 "  -v                       verbose\n"
+		 "  -x                       do not dump ACL's (grant/revoke)\n"
+		);
 #endif
-    puts("If no database name is not supplied, then the PGDATABASE environment\nvariable value is used.\n");
-    puts("Report bugs to <pgsql-bugs@postgresql.org>.");
+	puts("If no database name is not supplied, then the PGDATABASE environment\nvariable value is used.\n");
+	puts("Report bugs to <pgsql-bugs@postgresql.org>.");
 }
 
 
 static void
 version(void)
 {
-    puts("pg_dump (PostgreSQL) " PG_RELEASE "." PG_VERSION "." PG_SUBVERSION);
-    puts("Portions Copyright (c) 1996-2000, PostgreSQL, Inc");
-    puts("Portions Copyright (C) 1996 Regents of the University of California");
-    puts("Read the file COPYRIGHT to see the usage and distribution terms.");
+	puts("pg_dump (PostgreSQL) " PG_RELEASE "." PG_VERSION "." PG_SUBVERSION);
+	puts("Portions Copyright (c) 1996-2000, PostgreSQL, Inc");
+	puts("Portions Copyright (C) 1996 Regents of the University of California");
+	puts("Read the file COPYRIGHT to see the usage and distribution terms.");
 }
 
 
@@ -202,7 +202,7 @@ isViewRule(char *relname)
 {
 	PGresult   *res;
 	int			ntups;
-	PQExpBuffer	query = createPQExpBuffer();
+	PQExpBuffer query = createPQExpBuffer();
 
 	appendPQExpBuffer(query, "select relname from pg_class, pg_rewrite ");
 	appendPQExpBuffer(query, "where pg_class.oid = ev_class ");
@@ -320,11 +320,11 @@ dumpClasses_nodumpData(FILE *fout, const char *classname, const bool oids)
 static void
 dumpClasses_dumpData(FILE *fout, const char *classname)
 {
-	PGresult	*res;
-	PQExpBuffer	q = createPQExpBuffer();
+	PGresult   *res;
+	PQExpBuffer q = createPQExpBuffer();
 	int			tuple;
 	int			field;
-	const char	*expsrc;
+	const char *expsrc;
 
 	appendPQExpBuffer(q, "SELECT * FROM %s", fmtId(classname, force_quotes));
 	res = PQexec(g_conn, q->data);
@@ -364,19 +364,20 @@ dumpClasses_dumpData(FILE *fout, const char *classname)
 			{
 				case INT2OID:
 				case INT4OID:
-				case OIDOID:		/* int types */
+				case OIDOID:	/* int types */
 				case FLOAT4OID:
-				case FLOAT8OID:		/* float types */
+				case FLOAT8OID:/* float types */
 					/* These types are printed without quotes */
 					fprintf(fout, "%s",
 							PQgetvalue(res, tuple, field));
 					break;
 				default:
+
 					/*
 					 * All other types are printed as string literals,
-					 * with appropriate escaping of special
-					 * characters. Quote mark ' goes to '' per SQL
-					 * standard, other stuff goes to \ sequences.
+					 * with appropriate escaping of special characters.
+					 * Quote mark ' goes to '' per SQL standard, other
+					 * stuff goes to \ sequences.
 					 */
 					putc('\'', fout);
 					expsrc = PQgetvalue(res, tuple, field);
@@ -386,7 +387,7 @@ dumpClasses_dumpData(FILE *fout, const char *classname)
 
 						if (ch == '\\' || ch == '\'')
 						{
-							putc(ch, fout);			/* double these */
+							putc(ch, fout);		/* double these */
 							putc(ch, fout);
 						}
 						else if (ch < '\040')
@@ -432,7 +433,7 @@ dumpClasses(const TableInfo *tblinfo, const int numTables, FILE *fout,
 		fprintf(stderr, "%s dumping out the contents of %s %d table%s/sequence%s %s\n",
 				g_comment_start, all_only,
 				(onlytable == NULL) ? numTables : 1,
-				(onlytable == NULL) ? "s" : "", (onlytable == NULL) ? "s" : "",
+		  (onlytable == NULL) ? "s" : "", (onlytable == NULL) ? "s" : "",
 				g_comment_end);
 
 	/* Dump SEQUENCEs first (if dataOnly) */
@@ -536,12 +537,12 @@ prompt_for_password(char *username, char *password)
 
 
 static void
-check_database_version (bool ignoreVersion)
+check_database_version(bool ignoreVersion)
 {
-	PGresult	*res;
-	const char	*dbversion;
-	const char	*myversion = "PostgreSQL " PG_RELEASE "." PG_VERSION;
-	int			 myversionlen = strlen(myversion);
+	PGresult   *res;
+	const char *dbversion;
+	const char *myversion = "PostgreSQL " PG_RELEASE "." PG_VERSION;
+	int			myversionlen = strlen(myversion);
 
 	res = PQexec(g_conn, "SELECT version()");
 	if (!res ||
@@ -555,11 +556,9 @@ check_database_version (bool ignoreVersion)
 	if (strncmp(dbversion, myversion, myversionlen) != 0)
 	{
 		fprintf(stderr, "Database version: %s\npg_dump version: %s\n",
-				dbversion,  PG_RELEASE "." PG_VERSION);
+				dbversion, PG_RELEASE "." PG_VERSION);
 		if (ignoreVersion)
-		{
 			fprintf(stderr, "Proceeding despite version mismatch.\n");
-		}
 		else
 		{
 			fprintf(stderr, "Aborting because of version mismatch.\n"
@@ -595,7 +594,7 @@ main(int argc, char **argv)
 	static struct option long_options[] = {
 		{"data-only", no_argument, NULL, 'a'},
 		{"clean", no_argument, NULL, 'c'},
-		{"inserts",no_argument, NULL, 'd'},
+		{"inserts", no_argument, NULL, 'd'},
 		{"attribute-inserts", no_argument, NULL, 'D'},
 		{"host", required_argument, NULL, 'h'},
 		{"ignore-version", no_argument, NULL, 'i'},
@@ -609,9 +608,10 @@ main(int argc, char **argv)
 		{"verbose", no_argument, NULL, 'v'},
 		{"no-acl", no_argument, NULL, 'x'},
 		{"help", no_argument, NULL, '?'},
-        {"version", no_argument, NULL, 'V'}
+		{"version", no_argument, NULL, 'V'}
 	};
-	int		optindex;
+	int			optindex;
+
 #endif
 
 	g_verbose = false;
@@ -624,16 +624,16 @@ main(int argc, char **argv)
 
 	dataOnly = schemaOnly = dumpData = attrNames = false;
 
-    if (!strrchr(argv[0], SEP_CHAR))
-        progname = argv[0];
-    else
-        progname = strrchr(argv[0], SEP_CHAR) + 1;
+	if (!strrchr(argv[0], SEP_CHAR))
+		progname = argv[0];
+	else
+		progname = strrchr(argv[0], SEP_CHAR) + 1;
 
 
 #ifdef HAVE_GETOPT_LONG
 	while ((c = getopt_long(argc, argv, "acdDf:h:inNop:st:uvxzV?", long_options, &optindex)) != -1)
 #else
-    while ((c = getopt(argc, argv, "acdDf:h:inNop:st:uvxzV?-")) != -1)
+	while ((c = getopt(argc, argv, "acdDf:h:inNop:st:uvxzV?-")) != -1)
 #endif
 	{
 		switch (c)
@@ -653,7 +653,7 @@ main(int argc, char **argv)
 				dumpData = true;
 				attrNames = true;
 				break;
-            case 'f':
+			case 'f':
 				filename = optarg;
 				break;
 			case 'h':			/* server host */
@@ -669,7 +669,7 @@ main(int argc, char **argv)
 			case 'N':			/* Force double-quotes on identifiers */
 				force_quotes = true;
 				break;
-            case 'o': 		/* Dump oids */
+			case 'o':			/* Dump oids */
 				oids = true;
 				break;
 			case 'p':			/* server port */
@@ -713,41 +713,44 @@ main(int argc, char **argv)
 			case 'x':			/* skip ACL dump */
 				aclsSkip = true;
 				break;
-            case 'V':
-                version();
-                exit(0);
-                break;
+			case 'V':
+				version();
+				exit(0);
+				break;
 			case '?':
-                /* getopt returns '?' on unknown argument. That's not
-                   quite what we want */
-                if (strcmp(argv[optind-1], "-?")==0 || strcmp(argv[optind-1], "--help")==0)
-                {
-                    help(progname);
-                    exit(1);
-                }
-                else
-                {
-                    fputs("Try -? for help.\n", stderr);
-                    exit(1);
-                }
+
+				/*
+				 * getopt returns '?' on unknown argument. That's not
+				 * quite what we want
+				 */
+				if (strcmp(argv[optind - 1], "-?") == 0 || strcmp(argv[optind - 1], "--help") == 0)
+				{
+					help(progname);
+					exit(1);
+				}
+				else
+				{
+					fputs("Try -? for help.\n", stderr);
+					exit(1);
+				}
 				break;
 #ifndef HAVE_GETOPT_LONG
 			case '-':
 				fprintf(stderr, "%s was compiled without support for long options.\n"
-						"Use -? for help on invocation options.\n", progname);
+				   "Use -? for help on invocation options.\n", progname);
 				exit(1);
 				break;
 #endif
 			default:
-                fprintf(stderr, "%s: unknown option -%c\nTry -? for help.\n", progname, c);
-                exit(1);
+				fprintf(stderr, "%s: unknown option -%c\nTry -? for help.\n", progname, c);
+				exit(1);
 		}
 	}
 
 	if (dumpData == true && oids == true)
 	{
 		fprintf(stderr,
-			 "%s: INSERT's can not set oids, so INSERT and OID options can not be used together.\n",
+				"%s: INSERT's can not set oids, so INSERT and OID options can not be used together.\n",
 				progname);
 		exit(1);
 	}
@@ -855,13 +858,15 @@ main(int argc, char **argv)
 	else
 		tblinfo = dumpSchema(NULL, &numTables, tablename, aclsSkip);
 
-	if (!schemaOnly) {
+	if (!schemaOnly)
+	{
 		if (dataOnly)
 			fprintf(g_fout, "UPDATE \"pg_class\" SET \"reltriggers\" = 0 WHERE \"relname\" !~ '^pg_';\n");
 
 		dumpClasses(tblinfo, numTables, g_fout, tablename, oids);
 
-		if (dataOnly) {
+		if (dataOnly)
+		{
 			fprintf(g_fout, "BEGIN TRANSACTION;\n");
 			fprintf(g_fout, "CREATE TEMP TABLE \"tr\" (\"tmp_relname\" name, \"tmp_reltriggers\" smallint);\n");
 			fprintf(g_fout, "INSERT INTO \"tr\" SELECT C.\"relname\", count(T.\"oid\") FROM \"pg_class\" C, \"pg_trigger\" T WHERE C.\"oid\" = T.\"tgrelid\" AND C.\"relname\" !~ '^pg_' GROUP BY 1;\n");
@@ -901,7 +906,7 @@ getTypes(int *numTypes)
 	PGresult   *res;
 	int			ntups;
 	int			i;
-	PQExpBuffer	query = createPQExpBuffer();
+	PQExpBuffer query = createPQExpBuffer();
 	TypeInfo   *tinfo;
 
 	int			i_oid;
@@ -933,8 +938,8 @@ getTypes(int *numTypes)
 
 	appendPQExpBuffer(query, "SELECT pg_type.oid, typowner, typname, typlen, typprtlen, "
 		  "typinput, typoutput, typreceive, typsend, typelem, typdelim, "
-		  "typdefault, typrelid, typbyval, usename from pg_type, pg_user "
-			"where typowner = usesysid");
+		 "typdefault, typrelid, typbyval, usename from pg_type, pg_user "
+					  "where typowner = usesysid");
 
 	res = PQexec(g_conn, query->data);
 	if (!res ||
@@ -1015,10 +1020,10 @@ getTypes(int *numTypes)
 OprInfo    *
 getOperators(int *numOprs)
 {
-	PGresult	*res;
+	PGresult   *res;
 	int			ntups;
 	int			i;
-	PQExpBuffer	query = createPQExpBuffer();
+	PQExpBuffer query = createPQExpBuffer();
 
 	OprInfo    *oprinfo;
 
@@ -1043,10 +1048,10 @@ getOperators(int *numOprs)
 	 */
 
 	appendPQExpBuffer(query, "SELECT pg_operator.oid, oprname, oprkind, oprcode, "
-			"oprleft, oprright, oprcom, oprnegate, oprrest, oprjoin, "
-			"oprcanhash, oprlsortop, oprrsortop, usename "
-			"from pg_operator, pg_user "
-			"where oprowner = usesysid");
+			   "oprleft, oprright, oprcom, oprnegate, oprrest, oprjoin, "
+					  "oprcanhash, oprlsortop, oprrsortop, usename "
+					  "from pg_operator, pg_user "
+					  "where oprowner = usesysid");
 
 	res = PQexec(g_conn, query->data);
 	if (!res ||
@@ -1154,7 +1159,7 @@ clearFuncInfo(FuncInfo *fun, int numFuncs)
 			free(fun[i].proname);
 		if (fun[i].usename)
 			free(fun[i].usename);
-		for (a = 0; a < FUNC_MAX_ARGS ; ++a)
+		for (a = 0; a < FUNC_MAX_ARGS; ++a)
 			if (fun[i].argtypes[a])
 				free(fun[i].argtypes[a]);
 		if (fun[i].prorettype)
@@ -1209,8 +1214,8 @@ clearTableInfo(TableInfo *tblinfo, int numTables)
 			free(tblinfo[i].typnames);
 		if (tblinfo[i].notnull)
 			free(tblinfo[i].notnull);
-	if (tblinfo[i].primary_key)
-	    free(tblinfo[i].primary_key);
+		if (tblinfo[i].primary_key)
+			free(tblinfo[i].primary_key);
 	}
 	free(tblinfo);
 }
@@ -1356,7 +1361,7 @@ getAggregates(int *numAggs)
 	PGresult   *res;
 	int			ntups;
 	int			i;
-	PQExpBuffer	query = createPQExpBuffer();
+	PQExpBuffer query = createPQExpBuffer();
 	AggInfo    *agginfo;
 
 	int			i_oid;
@@ -1374,10 +1379,10 @@ getAggregates(int *numAggs)
 	/* find all user-defined aggregates */
 
 	appendPQExpBuffer(query,
-			"SELECT pg_aggregate.oid, aggname, aggtransfn1, aggtransfn2, "
-			"aggfinalfn, aggtranstype1, aggbasetype, aggtranstype2, "
+		   "SELECT pg_aggregate.oid, aggname, aggtransfn1, aggtransfn2, "
+				"aggfinalfn, aggtranstype1, aggbasetype, aggtranstype2, "
 		  "agginitval1, agginitval2, usename from pg_aggregate, pg_user "
-			"where aggowner = usesysid");
+					  "where aggowner = usesysid");
 
 	res = PQexec(g_conn, query->data);
 	if (!res ||
@@ -1436,11 +1441,11 @@ getAggregates(int *numAggs)
 FuncInfo   *
 getFuncs(int *numFuncs)
 {
-	PGresult	*res;
+	PGresult   *res;
 	int			ntups;
 	int			i;
-	PQExpBuffer	query = createPQExpBuffer();
-	FuncInfo	*finfo;
+	PQExpBuffer query = createPQExpBuffer();
+	FuncInfo   *finfo;
 
 	int			i_oid;
 	int			i_proname;
@@ -1456,11 +1461,11 @@ getFuncs(int *numFuncs)
 	/* find all user-defined funcs */
 
 	appendPQExpBuffer(query,
-			"SELECT pg_proc.oid, proname, prolang, pronargs, prorettype, "
-			"proretset, proargtypes, prosrc, probin, usename "
-			"from pg_proc, pg_user "
-			"where pg_proc.oid > '%u'::oid and proowner = usesysid",
-			g_last_builtin_oid);
+		   "SELECT pg_proc.oid, proname, prolang, pronargs, prorettype, "
+					  "proretset, proargtypes, prosrc, probin, usename "
+					  "from pg_proc, pg_user "
+				 "where pg_proc.oid > '%u'::oid and proowner = usesysid",
+					  g_last_builtin_oid);
 
 	res = PQexec(g_conn, query->data);
 	if (!res ||
@@ -1532,11 +1537,11 @@ getFuncs(int *numFuncs)
 TableInfo  *
 getTables(int *numTables, FuncInfo *finfo, int numFuncs)
 {
-	PGresult	*res;
+	PGresult   *res;
 	int			ntups;
 	int			i;
-	PQExpBuffer	query = createPQExpBuffer();
-	TableInfo	*tblinfo;
+	PQExpBuffer query = createPQExpBuffer();
+	TableInfo  *tblinfo;
 
 	int			i_oid;
 	int			i_relname;
@@ -1545,25 +1550,25 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
 	int			i_usename;
 	int			i_relchecks;
 	int			i_reltriggers;
-    int         i_relhasindex;
+	int			i_relhasindex;
 
 	/*
 	 * find all the user-defined tables (no indices and no catalogs),
 	 * ordering by oid is important so that we always process the parent
 	 * tables before the child tables when traversing the tblinfo*
 	 *
-	 * we ignore tables that are not type 'r' (ordinary relation)
-	 * or 'S' (sequence) --- in particular, Large Object relations
-	 * (type 'l') are ignored.
+	 * we ignore tables that are not type 'r' (ordinary relation) or 'S'
+	 * (sequence) --- in particular, Large Object relations (type 'l') are
+	 * ignored.
 	 */
 
 	appendPQExpBuffer(query,
-			"SELECT pg_class.oid, relname, relkind, relacl, usename, "
-			"relchecks, reltriggers, relhasindex "
-			"from pg_class, pg_user "
-			"where relowner = usesysid and "
-			"(relkind = 'r' or relkind = 'S') and relname !~ '^pg_' "
-			"order by oid");
+			   "SELECT pg_class.oid, relname, relkind, relacl, usename, "
+					  "relchecks, reltriggers, relhasindex "
+					  "from pg_class, pg_user "
+					  "where relowner = usesysid and "
+				"(relkind = 'r' or relkind = 'S') and relname !~ '^pg_' "
+					  "order by oid");
 
 	res = PQexec(g_conn, query->data);
 	if (!res ||
@@ -1617,14 +1622,14 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
 
 			resetPQExpBuffer(query);
 			appendPQExpBuffer(query, "SELECT rcname from pg_relcheck, pg_inherits as i "
-					"where rcrelid = '%s'::oid "
-					" and rcrelid = i.inhrelid"
-					" and exists "
-					"  (select * from pg_relcheck as c "
-					"    where c.rcname = pg_relcheck.rcname "
-					"      and c.rcsrc = pg_relcheck.rcsrc "
-					"      and c.rcrelid = i.inhparent) ",
-					tblinfo[i].oid);
+							  "where rcrelid = '%s'::oid "
+							  " and rcrelid = i.inhrelid"
+							  " and exists "
+							  "  (select * from pg_relcheck as c "
+							  "    where c.rcname = pg_relcheck.rcname "
+							  "      and c.rcsrc = pg_relcheck.rcsrc "
+							  "      and c.rcrelid = i.inhparent) ",
+							  tblinfo[i].oid);
 			res2 = PQexec(g_conn, query->data);
 			if (!res2 ||
 				PQresultStatus(res2) != PGRES_TUPLES_OK)
@@ -1661,14 +1666,14 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
 
 			resetPQExpBuffer(query);
 			appendPQExpBuffer(query, "SELECT rcname, rcsrc from pg_relcheck "
-					"where rcrelid = '%s'::oid "
-					"   and not exists "
-					"  (select * from pg_relcheck as c, pg_inherits as i "
-					"   where i.inhrelid = pg_relcheck.rcrelid "
-					"     and c.rcname = pg_relcheck.rcname "
-					"     and c.rcsrc = pg_relcheck.rcsrc "
-					"     and c.rcrelid = i.inhparent) ",
-					tblinfo[i].oid);
+							  "where rcrelid = '%s'::oid "
+							  "   and not exists "
+				   "  (select * from pg_relcheck as c, pg_inherits as i "
+							  "   where i.inhrelid = pg_relcheck.rcrelid "
+							  "     and c.rcname = pg_relcheck.rcname "
+							  "     and c.rcsrc = pg_relcheck.rcsrc "
+							  "     and c.rcrelid = i.inhparent) ",
+							  tblinfo[i].oid);
 			res2 = PQexec(g_conn, query->data);
 			if (!res2 ||
 				PQresultStatus(res2) != PGRES_TUPLES_OK)
@@ -1692,7 +1697,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
 				const char *expr = PQgetvalue(res2, i2, i_rcsrc);
 
 				resetPQExpBuffer(query);
-				if (name[0] != '$') {
+				if (name[0] != '$')
+				{
 					appendPQExpBuffer(query, "CONSTRAINT %s ",
 									  fmtId(name, force_quotes));
 				}
@@ -1704,40 +1710,42 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
 		else
 			tblinfo[i].check_expr = NULL;
 
-	/* Get primary key */
-		if (strcmp(PQgetvalue(res, i, i_relhasindex), "t")==0)
+		/* Get primary key */
+		if (strcmp(PQgetvalue(res, i, i_relhasindex), "t") == 0)
 		{
-			PGresult * res2;
-			char str[INDEX_MAX_KEYS * (NAMEDATALEN*2 + 4) + 1];
-			int j;
+			PGresult   *res2;
+			char		str[INDEX_MAX_KEYS * (NAMEDATALEN * 2 + 4) + 1];
+			int			j;
 
 			resetPQExpBuffer(query);
 			appendPQExpBuffer(query,
-		    "SELECT a.attname "
-		    "FROM pg_index i, pg_class c, pg_attribute a "
-		    "WHERE i.indisprimary AND i.indrelid = %s "
-		    "  AND i.indexrelid = c.oid AND a.attnum > 0 AND a.attrelid = c.oid "
-		    "ORDER BY a.attnum ",
-		    tblinfo[i].oid);
+							  "SELECT a.attname "
+						   "FROM pg_index i, pg_class c, pg_attribute a "
+							  "WHERE i.indisprimary AND i.indrelid = %s "
+							  "  AND i.indexrelid = c.oid AND a.attnum > 0 AND a.attrelid = c.oid "
+							  "ORDER BY a.attnum ",
+							  tblinfo[i].oid);
 			res2 = PQexec(g_conn, query->data);
 			if (!res2 || PQresultStatus(res2) != PGRES_TUPLES_OK)
 			{
 				fprintf(stderr, "getTables(): SELECT (for PRIMARY KEY) failed.  Explanation from backend: %s",
-			PQerrorMessage(g_conn));
+						PQerrorMessage(g_conn));
 				exit_nicely(g_conn);
 			}
 
 			str[0] = '\0';
 			for (j = 0; j < PQntuples(res2); j++)
 			{
-				if (strlen(str)>0)
+				if (strlen(str) > 0)
 					strcat(str, ", ");
 				strcat(str, fmtId(PQgetvalue(res2, j, 0), force_quotes));
 			}
 
-			if (strlen(str)>0) {
+			if (strlen(str) > 0)
+			{
 				tblinfo[i].primary_key = strdup(str);
-				if (tblinfo[i].primary_key == NULL) {
+				if (tblinfo[i].primary_key == NULL)
+				{
 					perror("strdup");
 					exit(1);
 				}
@@ -1753,7 +1761,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
 		{
 			PGresult   *res2;
 			int			i_tgoid,
-				        i_tgname,
+						i_tgname,
 						i_tgfoid,
 						i_tgtype,
 						i_tgnargs,
@@ -1773,9 +1781,9 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
 
 			resetPQExpBuffer(query);
 			appendPQExpBuffer(query, "SELECT tgname, tgfoid, tgtype, tgnargs, tgargs, tgisconstraint, tgconstrname, tgdeferrable, tginitdeferred, oid "
-					"from pg_trigger "
-					"where tgrelid = '%s'::oid ",
-					tblinfo[i].oid);
+							  "from pg_trigger "
+							  "where tgrelid = '%s'::oid ",
+							  tblinfo[i].oid);
 			res2 = PQexec(g_conn, query->data);
 			if (!res2 ||
 				PQresultStatus(res2) != PGRES_TUPLES_OK)
@@ -1808,30 +1816,30 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
 			for (i2 = 0; i2 < ntups2; i2++)
 			{
 				const char *tgfuncoid = PQgetvalue(res2, i2, i_tgfoid);
-				char *tgfunc = NULL;
+				char	   *tgfunc = NULL;
 				int2		tgtype = atoi(PQgetvalue(res2, i2, i_tgtype));
 				int			tgnargs = atoi(PQgetvalue(res2, i2, i_tgnargs));
 				const char *tgargs = PQgetvalue(res2, i2, i_tgargs);
-				int tgisconstraint;
-				int tgdeferrable;
-				int tginitdeferred;
+				int			tgisconstraint;
+				int			tgdeferrable;
+				int			tginitdeferred;
 				const char *p;
 				int			findx;
 
 				if (strcmp(PQgetvalue(res2, i2, i_tgisconstraint), "f") == 0)
-					tgisconstraint=0;
+					tgisconstraint = 0;
 				else
-					tgisconstraint=1;
+					tgisconstraint = 1;
 
 				if (strcmp(PQgetvalue(res2, i2, i_tgdeferrable), "f") == 0)
-					tgdeferrable=0;
+					tgdeferrable = 0;
 				else
-					tgdeferrable=1;
+					tgdeferrable = 1;
 
 				if (strcmp(PQgetvalue(res2, i2, i_tginitdeferred), "f") == 0)
-					tginitdeferred=0;
+					tginitdeferred = 0;
 				else
-					tginitdeferred=1;
+					tginitdeferred = 1;
 
 				for (findx = 0; findx < numFuncs; findx++)
 				{
@@ -1840,45 +1848,45 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
 						strcmp(finfo[findx].prorettype, "0") == 0)
 						break;
 				}
-				
+
 				if (findx == numFuncs)
 				{
-					PGresult *r;
-
-		                        /*
-                		         * the funcname is an oid which we use to find the name of the
-		                         * pg_proc.  We need to do this because getFuncs() only reads
-                		         * in the user-defined funcs not all the funcs.  We might not
-		                         * find what we want by looking in FuncInfo*
-                		         */
-		                        resetPQExpBuffer(query);
-                		        appendPQExpBuffer(query,
-                                	        "SELECT proname from pg_proc "
-                                        	"where pg_proc.oid = '%s'::oid",
-	                                        tgfuncoid);  
-
-	        	                r = PQexec(g_conn, query->data);
-                	        	if (!r || PQresultStatus(r) != PGRES_TUPLES_OK)
-        	                	{
-                		                fprintf(stderr, "getTables(): SELECT (funcname) failed.  Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
-                                		exit_nicely(g_conn);
-                        		}
+					PGresult   *r;
+
+					/*
+					 * the funcname is an oid which we use to find the
+					 * name of the pg_proc.  We need to do this because
+					 * getFuncs() only reads in the user-defined funcs not
+					 * all the funcs.  We might not find what we want by
+					 * looking in FuncInfo*
+					 */
+					resetPQExpBuffer(query);
+					appendPQExpBuffer(query,
+									  "SELECT proname from pg_proc "
+									  "where pg_proc.oid = '%s'::oid",
+									  tgfuncoid);
+
+					r = PQexec(g_conn, query->data);
+					if (!r || PQresultStatus(r) != PGRES_TUPLES_OK)
+					{
+						fprintf(stderr, "getTables(): SELECT (funcname) failed.  Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
+						exit_nicely(g_conn);
+					}
 					tgfunc = strdup(PQgetvalue(r, 0, PQfnumber(r, "proname")));
-                		        PQclear(r);
+					PQclear(r);
 				}
-				else {
+				else
 					tgfunc = strdup(finfo[findx].proname);
-				}
 #if 0
 				/* XXX - how to emit this DROP TRIGGER? */
 				if (dropSchema)
 				{
 					resetPQExpBuffer(query);
 					appendPQExpBuffer(query, "DROP TRIGGER %s ",
-									  fmtId(PQgetvalue(res2, i2, i_tgname),
-											force_quotes));
+									fmtId(PQgetvalue(res2, i2, i_tgname),
+										  force_quotes));
 					appendPQExpBuffer(query, "ON %s;\n",
-									  fmtId(tblinfo[i].relname, force_quotes));
+								fmtId(tblinfo[i].relname, force_quotes));
 					fputs(query->data, fout);
 				}
 #endif
@@ -1889,7 +1897,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
 					appendPQExpBuffer(query, "CREATE CONSTRAINT TRIGGER ");
 					appendPQExpBuffer(query, fmtId(PQgetvalue(res2, i2, i_tgconstrname), force_quotes));
 				}
-				else { 
+				else
+				{
 					appendPQExpBuffer(query, "CREATE TRIGGER ");
 					appendPQExpBuffer(query, fmtId(PQgetvalue(res2, i2, i_tgname), force_quotes));
 				}
@@ -1922,22 +1931,16 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
 				}
 				appendPQExpBuffer(query, " ON %s ", fmtId(tblinfo[i].relname, force_quotes));
 
-				if (tgisconstraint) 
+				if (tgisconstraint)
 				{
-					if (!tgdeferrable) 
-					{
+					if (!tgdeferrable)
 						appendPQExpBuffer(query, " NOT");
-					}
 					appendPQExpBuffer(query, " DEFERRABLE INITIALLY ");
 					if (tginitdeferred)
-					{
 						appendPQExpBuffer(query, "DEFERRED");
-					}
-					else 
-					{
+					else
 						appendPQExpBuffer(query, "IMMEDIATE");
-					}
-					
+
 				}
 
 				appendPQExpBuffer(query, " FOR EACH ROW");
@@ -1945,7 +1948,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
 								  fmtId(tgfunc, force_quotes));
 				for (findx = 0; findx < tgnargs; findx++)
 				{
-					const char	   *s;
+					const char *s;
 
 					for (p = tgargs;;)
 					{
@@ -1984,19 +1987,17 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
 				tblinfo[i].triggers[i2] = strdup(query->data);
 
 				/*** Initialize trcomments and troids ***/
-				
+
 				resetPQExpBuffer(query);
-				appendPQExpBuffer(query, "TRIGGER %s ", 
-								  fmtId(PQgetvalue(res2, i2, i_tgname), force_quotes));
+				appendPQExpBuffer(query, "TRIGGER %s ",
+					fmtId(PQgetvalue(res2, i2, i_tgname), force_quotes));
 				appendPQExpBuffer(query, "ON %s",
-								  fmtId(tblinfo[i].relname, force_quotes));
+								fmtId(tblinfo[i].relname, force_quotes));
 				tblinfo[i].trcomments[i2] = strdup(query->data);
 				tblinfo[i].troids[i2] = strdup(PQgetvalue(res2, i2, i_tgoid));
 
 				if (tgfunc)
-				{
 					free(tgfunc);
-				}
 			}
 			PQclear(res2);
 		}
@@ -2006,7 +2007,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
 			tblinfo[i].trcomments = NULL;
 			tblinfo[i].troids = NULL;
 		}
-		  
+
 	}
 
 	PQclear(res);
@@ -2027,11 +2028,11 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
 InhInfo    *
 getInherits(int *numInherits)
 {
-	PGresult	*res;
+	PGresult   *res;
 	int			ntups;
 	int			i;
-	PQExpBuffer	query = createPQExpBuffer();
-	InhInfo		*inhinfo;
+	PQExpBuffer query = createPQExpBuffer();
+	InhInfo    *inhinfo;
 
 	int			i_inhrelid;
 	int			i_inhparent;
@@ -2082,14 +2083,14 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
 {
 	int			i,
 				j;
-	PQExpBuffer	q = createPQExpBuffer();
+	PQExpBuffer q = createPQExpBuffer();
 	int			i_attname;
 	int			i_typname;
 	int			i_atttypmod;
 	int			i_attnotnull;
 	int			i_atthasdef;
-	int         i_attoid;
-	PGresult	*res;
+	int			i_attoid;
+	PGresult   *res;
 	int			ntups;
 
 	for (i = 0; i < numTables; i++)
@@ -2113,11 +2114,11 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
 
 		resetPQExpBuffer(q);
 		appendPQExpBuffer(q, "SELECT a.oid as attoid, a.attnum, a.attname, t.typname, a.atttypmod, "
-				"a.attnotnull, a.atthasdef "
-				"from pg_attribute a, pg_type t "
-				"where a.attrelid = '%s'::oid and a.atttypid = t.oid "
-				"and a.attnum > 0 order by attnum",
-				tblinfo[i].oid);
+						  "a.attnotnull, a.atthasdef "
+						  "from pg_attribute a, pg_type t "
+				   "where a.attrelid = '%s'::oid and a.atttypid = t.oid "
+						  "and a.attnum > 0 order by attnum",
+						  tblinfo[i].oid);
 		res = PQexec(g_conn, q->data);
 		if (!res ||
 			PQresultStatus(res) != PGRES_TUPLES_OK)
@@ -2166,8 +2167,8 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
 
 				resetPQExpBuffer(q);
 				appendPQExpBuffer(q, "SELECT adsrc from pg_attrdef "
-						"where adrelid = '%s'::oid and adnum = %d ",
-						tblinfo[i].oid, j + 1);
+							 "where adrelid = '%s'::oid and adnum = %d ",
+								  tblinfo[i].oid, j + 1);
 				res2 = PQexec(g_conn, q->data);
 				if (!res2 ||
 					PQresultStatus(res2) != PGRES_TUPLES_OK)
@@ -2199,7 +2200,7 @@ IndInfo    *
 getIndices(int *numIndices)
 {
 	int			i;
-	PQExpBuffer	query = createPQExpBuffer();
+	PQExpBuffer query = createPQExpBuffer();
 	PGresult   *res;
 	int			ntups;
 	IndInfo    *indinfo;
@@ -2211,7 +2212,7 @@ getIndices(int *numIndices)
 	int			i_indkey;
 	int			i_indclass;
 	int			i_indisunique;
-	int         i_indoid;
+	int			i_indoid;
 
 	/*
 	 * find all the user-defined indices. We do not handle partial
@@ -2223,14 +2224,14 @@ getIndices(int *numIndices)
 	 */
 
 	appendPQExpBuffer(query,
-	    "SELECT t1.oid as indoid, t1.relname as indexrelname, t2.relname as indrelname, "
-			"i.indproc, i.indkey, i.indclass, "
-			"a.amname as indamname, i.indisunique "
-			"from pg_index i, pg_class t1, pg_class t2, pg_am a "
-			"WHERE t1.oid = i.indexrelid and t2.oid = i.indrelid "
-			"and t1.relam = a.oid and i.indexrelid > '%u'::oid "
-			"and t2.relname !~ '^pg_' and t2.relkind != 'l' and not i.indisprimary",
-			g_last_builtin_oid);
+					  "SELECT t1.oid as indoid, t1.relname as indexrelname, t2.relname as indrelname, "
+					  "i.indproc, i.indkey, i.indclass, "
+					  "a.amname as indamname, i.indisunique "
+					"from pg_index i, pg_class t1, pg_class t2, pg_am a "
+				   "WHERE t1.oid = i.indexrelid and t2.oid = i.indrelid "
+					  "and t1.relam = a.oid and i.indexrelid > '%u'::oid "
+					  "and t2.relname !~ '^pg_' and t2.relkind != 'l' and not i.indisprimary",
+					  g_last_builtin_oid);
 
 	res = PQexec(g_conn, query->data);
 	if (!res ||
@@ -2277,23 +2278,25 @@ getIndices(int *numIndices)
 }
 
 /*------------------------------------------------------------------
- * dumpComments -- 
+ * dumpComments --
  *
- * This routine is used to dump any comments associated with the 
+ * This routine is used to dump any comments associated with the
  * oid handed to this routine. The routine takes a constant character
  * string for the target part of the object and the oid of the object
  * whose comments are to be dumped. It is perfectly acceptable
  * to hand an oid to this routine which has not been commented. In
- * addition, the routine takes the stdio FILE handle to which the 
+ * addition, the routine takes the stdio FILE handle to which the
  * output should be written.
  *------------------------------------------------------------------
 */
 
-void dumpComment(FILE *fout, const char *target, const char *oid) {
+void
+dumpComment(FILE *fout, const char *target, const char *oid)
+{
 
-	PGresult *res;
+	PGresult   *res;
 	PQExpBuffer query;
-	int i_description;
+	int			i_description;
 
 	/*** Build query to find comment ***/
 
@@ -2304,7 +2307,8 @@ void dumpComment(FILE *fout, const char *target, const char *oid) {
 	/*** Execute query ***/
 
 	res = PQexec(g_conn, query->data);
-	if (!res || PQresultStatus(res) != PGRES_TUPLES_OK) {
+	if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
+	{
 		fprintf(stderr, "DumpComment: SELECT failed: '%s'.\n",
 				PQerrorMessage(g_conn));
 		exit_nicely(g_conn);
@@ -2312,33 +2316,36 @@ void dumpComment(FILE *fout, const char *target, const char *oid) {
 
 	/*** If a comment exists, build COMMENT ON statement ***/
 
-	if (PQntuples(res) != 0) {
+	if (PQntuples(res) != 0)
+	{
 		i_description = PQfnumber(res, "description");
-		fprintf(fout, "COMMENT ON %s IS '%s';\n", 
+		fprintf(fout, "COMMENT ON %s IS '%s';\n",
 				target, checkForQuote(PQgetvalue(res, 0, i_description)));
 	}
 
 	/*** Clear the statement buffer and return ***/
 
 	PQclear(res);
-    
+
 }
 
 /*------------------------------------------------------------------
- * dumpDBComment -- 
+ * dumpDBComment --
  *
- * This routine is used to dump any comments associated with the 
- * database to which we are currently connected. If the user chose 
+ * This routine is used to dump any comments associated with the
+ * database to which we are currently connected. If the user chose
  * to dump the schema of the database, then this is the first
  * statement issued.
  *------------------------------------------------------------------
 */
 
-void dumpDBComment(FILE *fout) {
+void
+dumpDBComment(FILE *fout)
+{
 
-	PGresult *res;
+	PGresult   *res;
 	PQExpBuffer query;
-	int i_oid;
+	int			i_oid;
 
 	/*** Build query to find comment ***/
 
@@ -2349,7 +2356,8 @@ void dumpDBComment(FILE *fout) {
 	/*** Execute query ***/
 
 	res = PQexec(g_conn, query->data);
-	if (!res || PQresultStatus(res) != PGRES_TUPLES_OK) {
+	if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
+	{
 		fprintf(stderr, "dumpDBComment: SELECT failed: '%s'.\n",
 				PQerrorMessage(g_conn));
 		exit_nicely(g_conn);
@@ -2357,7 +2365,8 @@ void dumpDBComment(FILE *fout) {
 
 	/*** If a comment exists, build COMMENT ON statement ***/
 
-	if (PQntuples(res) != 0) {
+	if (PQntuples(res) != 0)
+	{
 		i_oid = PQfnumber(res, "oid");
 		resetPQExpBuffer(query);
 		appendPQExpBuffer(query, "DATABASE %s", fmtId(PQdb(g_conn), force_quotes));
@@ -2367,7 +2376,7 @@ void dumpDBComment(FILE *fout) {
 	/*** Clear the statement buffer and return ***/
 
 	PQclear(res);
-	
+
 }
 
 /*
@@ -2380,7 +2389,7 @@ dumpTypes(FILE *fout, FuncInfo *finfo, int numFuncs,
 		  TypeInfo *tinfo, int numTypes)
 {
 	int			i;
-	PQExpBuffer	q = createPQExpBuffer();
+	PQExpBuffer q = createPQExpBuffer();
 	int			funcInd;
 
 	for (i = 0; i < numTypes; i++)
@@ -2422,17 +2431,17 @@ dumpTypes(FILE *fout, FuncInfo *finfo, int numFuncs,
 
 		resetPQExpBuffer(q);
 		appendPQExpBuffer(q,
-				"CREATE TYPE %s "
-				"( internallength = %s, externallength = %s, input = %s, "
-				"output = %s, send = %s, receive = %s, default = '%s'",
-				fmtId(tinfo[i].typname, force_quotes),
-				tinfo[i].typlen,
-				tinfo[i].typprtlen,
-				tinfo[i].typinput,
-				tinfo[i].typoutput,
-				tinfo[i].typsend,
-				tinfo[i].typreceive,
-				tinfo[i].typdefault);
+						  "CREATE TYPE %s "
+			   "( internallength = %s, externallength = %s, input = %s, "
+				  "output = %s, send = %s, receive = %s, default = '%s'",
+						  fmtId(tinfo[i].typname, force_quotes),
+						  tinfo[i].typlen,
+						  tinfo[i].typprtlen,
+						  tinfo[i].typinput,
+						  tinfo[i].typoutput,
+						  tinfo[i].typsend,
+						  tinfo[i].typreceive,
+						  tinfo[i].typdefault);
 
 		if (tinfo[i].isArray)
 		{
@@ -2441,7 +2450,7 @@ dumpTypes(FILE *fout, FuncInfo *finfo, int numFuncs,
 			elemType = findTypeByOid(tinfo, numTypes, tinfo[i].typelem);
 
 			appendPQExpBuffer(q, ", element = %s, delimiter = '%s'",
-					elemType, tinfo[i].typdelim);
+							  elemType, tinfo[i].typdelim);
 		}
 		if (tinfo[i].passedbyvalue)
 			appendPQExpBuffer(q, ",passedbyvalue);\n");
@@ -2468,22 +2477,22 @@ void
 dumpProcLangs(FILE *fout, FuncInfo *finfo, int numFuncs,
 			  TypeInfo *tinfo, int numTypes)
 {
-	PGresult	*res;
-	PQExpBuffer	query = createPQExpBuffer();
+	PGresult   *res;
+	PQExpBuffer query = createPQExpBuffer();
 	int			ntups;
 	int			i_lanname;
 	int			i_lanpltrusted;
 	int			i_lanplcallfoid;
 	int			i_lancompiler;
-	char		*lanname;
-	char		*lancompiler;
-	const char	*lanplcallfoid;
+	char	   *lanname;
+	char	   *lancompiler;
+	const char *lanplcallfoid;
 	int			i,
 				fidx;
 
 	appendPQExpBuffer(query, "SELECT * FROM pg_language "
-			"WHERE lanispl "
-			"ORDER BY oid");
+					  "WHERE lanispl "
+					  "ORDER BY oid");
 	res = PQexec(g_conn, query->data);
 	if (!res ||
 		PQresultStatus(res) != PGRES_TUPLES_OK)
@@ -2561,10 +2570,10 @@ static void
 dumpOneFunc(FILE *fout, FuncInfo *finfo, int i,
 			TypeInfo *tinfo, int numTypes)
 {
-	PQExpBuffer	q = createPQExpBuffer();
+	PQExpBuffer q = createPQExpBuffer();
 	PQExpBuffer fnlist = createPQExpBuffer();
 	int			j;
-	char		*func_def;
+	char	   *func_def;
 	char		func_lang[NAMEDATALEN + 1];
 
 	if (finfo[i].dumped)
@@ -2633,8 +2642,8 @@ dumpOneFunc(FILE *fout, FuncInfo *finfo, int i,
 
 			typname = findTypeByOid(tinfo, numTypes, finfo[i].argtypes[j]);
 			appendPQExpBuffer(q, "%s%s",
-					(j > 0) ? "," : "",
-					fmtId(typname, false));
+							  (j > 0) ? "," : "",
+							  fmtId(typname, false));
 		}
 		appendPQExpBuffer(q, ");\n");
 		fputs(q->data, fout);
@@ -2648,16 +2657,16 @@ dumpOneFunc(FILE *fout, FuncInfo *finfo, int i,
 
 		typname = findTypeByOid(tinfo, numTypes, finfo[i].argtypes[j]);
 		appendPQExpBuffer(q, "%s%s",
-				(j > 0) ? "," : "",
-				fmtId(typname, false));
+						  (j > 0) ? "," : "",
+						  fmtId(typname, false));
 		appendPQExpBuffer(fnlist, "%s%s",
 						  (j > 0) ? "," : "",
 						  fmtId(typname, false));
 	}
 	appendPQExpBuffer(q, " ) RETURNS %s%s AS '%s' LANGUAGE '%s';\n",
-			(finfo[i].retset) ? " SETOF " : "",
-			fmtId(findTypeByOid(tinfo, numTypes, finfo[i].prorettype), false),
-			func_def, func_lang);
+					  (finfo[i].retset) ? " SETOF " : "",
+	   fmtId(findTypeByOid(tinfo, numTypes, finfo[i].prorettype), false),
+					  func_def, func_lang);
 
 	fputs(q->data, fout);
 
@@ -2681,15 +2690,15 @@ dumpOprs(FILE *fout, OprInfo *oprinfo, int numOperators,
 		 TypeInfo *tinfo, int numTypes)
 {
 	int			i;
-	PQExpBuffer	q = createPQExpBuffer();
-	PQExpBuffer	leftarg = createPQExpBuffer();
-	PQExpBuffer	rightarg = createPQExpBuffer();
-	PQExpBuffer	commutator = createPQExpBuffer();
-	PQExpBuffer	negator = createPQExpBuffer();
-	PQExpBuffer	restrictor = createPQExpBuffer();
-	PQExpBuffer	join = createPQExpBuffer();
-	PQExpBuffer	sort1 = createPQExpBuffer();
-	PQExpBuffer	sort2 = createPQExpBuffer();
+	PQExpBuffer q = createPQExpBuffer();
+	PQExpBuffer leftarg = createPQExpBuffer();
+	PQExpBuffer rightarg = createPQExpBuffer();
+	PQExpBuffer commutator = createPQExpBuffer();
+	PQExpBuffer negator = createPQExpBuffer();
+	PQExpBuffer restrictor = createPQExpBuffer();
+	PQExpBuffer join = createPQExpBuffer();
+	PQExpBuffer sort1 = createPQExpBuffer();
+	PQExpBuffer sort2 = createPQExpBuffer();
 
 	for (i = 0; i < numOperators; i++)
 	{
@@ -2722,13 +2731,13 @@ dumpOprs(FILE *fout, OprInfo *oprinfo, int numOperators,
 			strcmp(oprinfo[i].oprkind, "b") == 0)
 		{
 			appendPQExpBuffer(leftarg, ",\n\tLEFTARG = %s ",
-					fmtId(findTypeByOid(tinfo, numTypes, oprinfo[i].oprleft), false));
+							  fmtId(findTypeByOid(tinfo, numTypes, oprinfo[i].oprleft), false));
 		}
 		if (strcmp(oprinfo[i].oprkind, "l") == 0 ||
 			strcmp(oprinfo[i].oprkind, "b") == 0)
 		{
 			appendPQExpBuffer(rightarg, ",\n\tRIGHTARG = %s ",
-					fmtId(findTypeByOid(tinfo, numTypes, oprinfo[i].oprright), false));
+							  fmtId(findTypeByOid(tinfo, numTypes, oprinfo[i].oprright), false));
 		}
 		if (!(strcmp(oprinfo[i].oprcom, "0") == 0))
 			appendPQExpBuffer(commutator, ",\n\tCOMMUTATOR = %s ",
@@ -2758,29 +2767,29 @@ dumpOprs(FILE *fout, OprInfo *oprinfo, int numOperators,
 		{
 			resetPQExpBuffer(q);
 			appendPQExpBuffer(q, "DROP OPERATOR %s (%s", oprinfo[i].oprname,
-					fmtId(findTypeByOid(tinfo, numTypes, oprinfo[i].oprleft),
-						  false));
+				fmtId(findTypeByOid(tinfo, numTypes, oprinfo[i].oprleft),
+					  false));
 			appendPQExpBuffer(q, ", %s);\n",
-					fmtId(findTypeByOid(tinfo, numTypes, oprinfo[i].oprright),
-						  false));
+			   fmtId(findTypeByOid(tinfo, numTypes, oprinfo[i].oprright),
+					 false));
 			fputs(q->data, fout);
 		}
 
 		resetPQExpBuffer(q);
 		appendPQExpBuffer(q,
-				"CREATE OPERATOR %s "
-				"(PROCEDURE = %s %s%s%s%s%s%s%s%s%s);\n",
-				oprinfo[i].oprname,
-				oprinfo[i].oprcode,
-				leftarg->data,
-				rightarg->data,
-				commutator->data,
-				negator->data,
-				restrictor->data,
+						  "CREATE OPERATOR %s "
+						  "(PROCEDURE = %s %s%s%s%s%s%s%s%s%s);\n",
+						  oprinfo[i].oprname,
+						  oprinfo[i].oprcode,
+						  leftarg->data,
+						  rightarg->data,
+						  commutator->data,
+						  negator->data,
+						  restrictor->data,
 		  (strcmp(oprinfo[i].oprcanhash, "t") == 0) ? ",\n\tHASHES" : "",
-				join->data,
-				sort1->data,
-				sort2->data);
+						  join->data,
+						  sort1->data,
+						  sort2->data);
 
 		fputs(q->data, fout);
 	}
@@ -2796,11 +2805,11 @@ dumpAggs(FILE *fout, AggInfo *agginfo, int numAggs,
 		 TypeInfo *tinfo, int numTypes)
 {
 	int			i;
-	PQExpBuffer	q = createPQExpBuffer();
-	PQExpBuffer	sfunc1 = createPQExpBuffer();
-	PQExpBuffer	sfunc2 = createPQExpBuffer();
-	PQExpBuffer	basetype = createPQExpBuffer();
-	PQExpBuffer	finalfunc = createPQExpBuffer();
+	PQExpBuffer q = createPQExpBuffer();
+	PQExpBuffer sfunc1 = createPQExpBuffer();
+	PQExpBuffer sfunc2 = createPQExpBuffer();
+	PQExpBuffer basetype = createPQExpBuffer();
+	PQExpBuffer finalfunc = createPQExpBuffer();
 	char		comma1[2],
 				comma2[2];
 
@@ -2817,30 +2826,30 @@ dumpAggs(FILE *fout, AggInfo *agginfo, int numAggs,
 			continue;
 
 		appendPQExpBuffer(basetype,
-				"BASETYPE = %s, ",
-				fmtId(findTypeByOid(tinfo, numTypes, agginfo[i].aggbasetype), false));
+						  "BASETYPE = %s, ",
+						  fmtId(findTypeByOid(tinfo, numTypes, agginfo[i].aggbasetype), false));
 
 		if (!(strcmp(agginfo[i].aggtransfn1, "-") == 0))
 		{
 			appendPQExpBuffer(sfunc1,
-					"SFUNC1 = %s, STYPE1 = %s",
-					agginfo[i].aggtransfn1,
-					fmtId(findTypeByOid(tinfo, numTypes, agginfo[i].aggtranstype1), false));
+							  "SFUNC1 = %s, STYPE1 = %s",
+							  agginfo[i].aggtransfn1,
+							  fmtId(findTypeByOid(tinfo, numTypes, agginfo[i].aggtranstype1), false));
 			if (agginfo[i].agginitval1)
 				appendPQExpBuffer(sfunc1, ", INITCOND1 = '%s'",
-						agginfo[i].agginitval1);
+								  agginfo[i].agginitval1);
 
 		}
 
 		if (!(strcmp(agginfo[i].aggtransfn2, "-") == 0))
 		{
 			appendPQExpBuffer(sfunc2,
-					"SFUNC2 = %s, STYPE2 = %s",
-					agginfo[i].aggtransfn2,
-					fmtId(findTypeByOid(tinfo, numTypes, agginfo[i].aggtranstype2), false));
+							  "SFUNC2 = %s, STYPE2 = %s",
+							  agginfo[i].aggtransfn2,
+							  fmtId(findTypeByOid(tinfo, numTypes, agginfo[i].aggtranstype2), false));
 			if (agginfo[i].agginitval2)
 				appendPQExpBuffer(sfunc2, ", INITCOND2 = '%s'",
-						agginfo[i].agginitval2);
+								  agginfo[i].agginitval2);
 		}
 
 		if (!(strcmp(agginfo[i].aggfinalfn, "-") == 0))
@@ -2867,26 +2876,26 @@ dumpAggs(FILE *fout, AggInfo *agginfo, int numAggs,
 		{
 			resetPQExpBuffer(q);
 			appendPQExpBuffer(q, "DROP AGGREGATE %s %s;\n", agginfo[i].aggname,
-					fmtId(findTypeByOid(tinfo, numTypes, agginfo[i].aggbasetype), false));
+							  fmtId(findTypeByOid(tinfo, numTypes, agginfo[i].aggbasetype), false));
 			fputs(q->data, fout);
 		}
 
 		resetPQExpBuffer(q);
 		appendPQExpBuffer(q, "CREATE AGGREGATE %s ( %s %s%s %s%s %s );\n",
-				agginfo[i].aggname,
-				basetype->data,
-				sfunc1->data,
-				comma1,
-				sfunc2->data,
-				comma2,
-				finalfunc->data);
+						  agginfo[i].aggname,
+						  basetype->data,
+						  sfunc1->data,
+						  comma1,
+						  sfunc2->data,
+						  comma2,
+						  finalfunc->data);
 
 		fputs(q->data, fout);
 
 		/*** Dump Aggregate Comments ***/
 
 		resetPQExpBuffer(q);
-		appendPQExpBuffer(q, "AGGREGATE %s %s", agginfo[i].aggname, 
+		appendPQExpBuffer(q, "AGGREGATE %s %s", agginfo[i].aggname,
 						  fmtId(findTypeByOid(tinfo, numTypes, agginfo[i].aggbasetype), false));
 		dumpComment(fout, q->data, agginfo[i].oid);
 
@@ -2972,6 +2981,7 @@ dumpACL(FILE *fout, TableInfo tbinfo)
 	/* Scan comma-separated ACL items */
 	for (tok = strtok(aclbuf, ","); tok != NULL; tok = strtok(NULL, ","))
 	{
+
 		/*
 		 * Token may start with '{' and/or '"'.  Actually only the start
 		 * of the string should have '{', but we don't verify that.
@@ -3041,8 +3051,8 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
 	int			i,
 				j,
 				k;
-	PQExpBuffer	q = createPQExpBuffer();
-	char		*serialSeq = NULL;		/* implicit sequence name created
+	PQExpBuffer q = createPQExpBuffer();
+	char	   *serialSeq = NULL;		/* implicit sequence name created
 										 * by SERIAL datatype */
 	const char *serialSeqSuffix = "_id_seq";	/* suffix for implicit
 												 * SERIAL sequences */
@@ -3123,7 +3133,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
 						appendPQExpBuffer(q, "character");
 						if (len > 1)
 							appendPQExpBuffer(q, "(%d)",
-									tblinfo[i].atttypmod[j] - VARHDRSZ);
+									 tblinfo[i].atttypmod[j] - VARHDRSZ);
 					}
 					else if (!strcmp(tblinfo[i].typnames[j], "varchar"))
 					{
@@ -3131,7 +3141,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
 						if (tblinfo[i].atttypmod[j] != -1)
 						{
 							appendPQExpBuffer(q, "(%d)",
-									tblinfo[i].atttypmod[j] - VARHDRSZ);
+									 tblinfo[i].atttypmod[j] - VARHDRSZ);
 						}
 					}
 					else if (!strcmp(tblinfo[i].typnames[j], "numeric"))
@@ -3143,7 +3153,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
 							precision = (tmp_typmod >> 16) & 0xffff;
 							scale = tmp_typmod & 0xffff;
 							appendPQExpBuffer(q, "(%d,%d)",
-									precision, scale);
+											  precision, scale);
 						}
 					}
 
@@ -3155,16 +3165,16 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
 					else if (!strcmp(tblinfo[i].typnames[j], "char"))
 					{
 						appendPQExpBuffer(q, "%s",
-								fmtId(tblinfo[i].typnames[j], true));
+									fmtId(tblinfo[i].typnames[j], true));
 					}
 					else
 					{
 						appendPQExpBuffer(q, "%s",
-								fmtId(tblinfo[i].typnames[j], false));
+								   fmtId(tblinfo[i].typnames[j], false));
 					}
 					if (tblinfo[i].adef_expr[j] != NULL)
 						appendPQExpBuffer(q, " DEFAULT %s",
-								tblinfo[i].adef_expr[j]);
+										  tblinfo[i].adef_expr[j]);
 					if (tblinfo[i].notnull[j])
 						appendPQExpBuffer(q, " NOT NULL");
 					actual_atts++;
@@ -3177,17 +3187,18 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
 				if (actual_atts + k > 0)
 					appendPQExpBuffer(q, ",\n\t");
 				appendPQExpBuffer(q, "%s",
-						tblinfo[i].check_expr[k]);
+								  tblinfo[i].check_expr[k]);
 			}
 
-	    /* PRIMARY KEY */
-	    if (tblinfo[i].primary_key) {
-		if (actual_atts + tblinfo[i].ncheck > 0)
-		    appendPQExpBuffer(q, ",\n\t");
-		appendPQExpBuffer(q, "PRIMARY KEY (%s)", tblinfo[i].primary_key);
-	    }
+			/* PRIMARY KEY */
+			if (tblinfo[i].primary_key)
+			{
+				if (actual_atts + tblinfo[i].ncheck > 0)
+					appendPQExpBuffer(q, ",\n\t");
+				appendPQExpBuffer(q, "PRIMARY KEY (%s)", tblinfo[i].primary_key);
+			}
 
-	    appendPQExpBuffer(q, "\n)");
+			appendPQExpBuffer(q, "\n)");
 
 			if (numParents > 0)
 			{
@@ -3195,8 +3206,8 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
 				for (k = 0; k < numParents; k++)
 				{
 					appendPQExpBuffer(q, "%s%s",
-							(k > 0) ? ", " : "",
-							fmtId(parentRels[k], force_quotes));
+									  (k > 0) ? ", " : "",
+									  fmtId(parentRels[k], force_quotes));
 				}
 				appendPQExpBuffer(q, ")");
 			}
@@ -3206,22 +3217,23 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
 			if (!aclsSkip)
 				dumpACL(fout, tblinfo[i]);
 
-			  /* Dump Field Comments */
+			/* Dump Field Comments */
 
-			for (j = 0; j < tblinfo[i].numatts; j++) {	     	   
+			for (j = 0; j < tblinfo[i].numatts; j++)
+			{
 				resetPQExpBuffer(q);
 				appendPQExpBuffer(q, "COLUMN %s", fmtId(tblinfo[i].relname, force_quotes));
 				appendPQExpBuffer(q, ".");
 				appendPQExpBuffer(q, "%s", fmtId(tblinfo[i].attnames[j], force_quotes));
 				dumpComment(fout, q->data, tblinfo[i].attoids[j]);
 			}
-	  
+
 			/* Dump Table Comments */
-			
+
 			resetPQExpBuffer(q);
 			appendPQExpBuffer(q, "TABLE %s", fmtId(tblinfo[i].relname, force_quotes));
 			dumpComment(fout, q->data, tblinfo[i].oid);
-			
+
 		}
 	}
 }
@@ -3237,7 +3249,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
 	int			i,
 				k;
 	int			tableInd;
-	PQExpBuffer	attlist = createPQExpBuffer();
+	PQExpBuffer attlist = createPQExpBuffer();
 	char	   *classname[INDEX_MAX_KEYS];
 	char	   *funcname;		/* the name of the function to comput the
 								 * index key from */
@@ -3245,7 +3257,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
 				indclass;
 	int			nclass;
 
-	PQExpBuffer	q = createPQExpBuffer(),
+	PQExpBuffer q = createPQExpBuffer(),
 				id1 = createPQExpBuffer(),
 				id2 = createPQExpBuffer();
 	PGresult   *res;
@@ -3274,9 +3286,9 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
 			 */
 			resetPQExpBuffer(q);
 			appendPQExpBuffer(q,
-					"SELECT proname from pg_proc "
-					"where pg_proc.oid = '%s'::oid",
-					indinfo[i].indproc);
+							  "SELECT proname from pg_proc "
+							  "where pg_proc.oid = '%s'::oid",
+							  indinfo[i].indproc);
 			res = PQexec(g_conn, q->data);
 			if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
 			{
@@ -3296,9 +3308,9 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
 				break;
 			resetPQExpBuffer(q);
 			appendPQExpBuffer(q,
-					"SELECT opcname from pg_opclass "
-					"where pg_opclass.oid = '%u'::oid",
-					indclass);
+							  "SELECT opcname from pg_opclass "
+							  "where pg_opclass.oid = '%u'::oid",
+							  indclass);
 			res = PQexec(g_conn, q->data);
 			if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
 			{
@@ -3348,7 +3360,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
 				appendPQExpBuffer(id1, fmtId(attname, force_quotes));
 				appendPQExpBuffer(id2, fmtId(classname[k], force_quotes));
 				appendPQExpBuffer(attlist, "%s%s %s",
-						(k == 0) ? "" : ", ", id1->data, id2->data);
+							 (k == 0) ? "" : ", ", id1->data, id2->data);
 				free(classname[k]);
 			}
 		}
@@ -3396,7 +3408,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
 			resetPQExpBuffer(q);
 			appendPQExpBuffer(q, "INDEX %s", id1->data);
 			dumpComment(fout, q->data, indinfo[i].indoid);
-			
+
 		}
 	}
 
@@ -3537,21 +3549,21 @@ findLastBuiltinOid(void)
 	if (res == NULL ||
 		PQresultStatus(res) != PGRES_TUPLES_OK)
 	{
-		fprintf(stderr,"pg_dump error in finding the template1 database.");
-		fprintf(stderr,"Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
+		fprintf(stderr, "pg_dump error in finding the template1 database.");
+		fprintf(stderr, "Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
 		exit_nicely(g_conn);
 	}
 	ntups = PQntuples(res);
 	if (ntups < 1)
 	{
-		fprintf(stderr,"pg_dump: couldn't find the template1 database.\n");
-		fprintf(stderr,"There is no 'template1' entry in the 'pg_database' table.\n");
+		fprintf(stderr, "pg_dump: couldn't find the template1 database.\n");
+		fprintf(stderr, "There is no 'template1' entry in the 'pg_database' table.\n");
 		exit_nicely(g_conn);
 	}
 	if (ntups > 1)
 	{
-		fprintf(stderr,"pg_dump: found more than one template1 database.\n");
-		fprintf(stderr,"There is more than one 'template1' entry in the 'pg_database' table\n");
+		fprintf(stderr, "pg_dump: found more than one template1 database.\n");
+		fprintf(stderr, "There is more than one 'template1' entry in the 'pg_database' table\n");
 		exit_nicely(g_conn);
 	}
 	last_oid = atoi(PQgetvalue(res, 0, PQfnumber(res, "oid")));
@@ -3598,7 +3610,7 @@ checkForQuote(const char *s)
 static void
 dumpSequence(FILE *fout, TableInfo tbinfo)
 {
-	PGresult	*res;
+	PGresult   *res;
 	int4		last,
 				incby,
 				maxv,
@@ -3606,13 +3618,13 @@ dumpSequence(FILE *fout, TableInfo tbinfo)
 				cache;
 	char		cycled,
 				called;
-    const char	*t;
-	PQExpBuffer	query = createPQExpBuffer();
+	const char *t;
+	PQExpBuffer query = createPQExpBuffer();
 
 	appendPQExpBuffer(query,
 			"SELECT sequence_name, last_value, increment_by, max_value, "
-			"min_value, cache_value, is_cycled, is_called from %s",
-			fmtId(tbinfo.relname, force_quotes));
+				  "min_value, cache_value, is_cycled, is_called from %s",
+					  fmtId(tbinfo.relname, force_quotes));
 
 	res = PQexec(g_conn, query->data);
 	if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
@@ -3658,10 +3670,10 @@ dumpSequence(FILE *fout, TableInfo tbinfo)
 
 	resetPQExpBuffer(query);
 	appendPQExpBuffer(query,
-			"CREATE SEQUENCE %s start %d increment %d maxvalue %d "
-			"minvalue %d  cache %d %s;\n",
+				  "CREATE SEQUENCE %s start %d increment %d maxvalue %d "
+					  "minvalue %d  cache %d %s;\n",
 	 fmtId(tbinfo.relname, force_quotes), last, incby, maxv, minv, cache,
-			(cycled == 't') ? "cycle" : "");
+					  (cycled == 't') ? "cycle" : "");
 
 	fputs(query->data, fout);
 
@@ -3714,11 +3726,11 @@ dumpRules(FILE *fout, const char *tablename,
 	int			nrules;
 	int			i,
 				t;
-	PQExpBuffer	query = createPQExpBuffer();
+	PQExpBuffer query = createPQExpBuffer();
 
 	int			i_definition;
-	int         i_oid;
-	int         i_rulename;
+	int			i_oid;
+	int			i_rulename;
 
 	if (g_verbose)
 		fprintf(stderr, "%s dumping out rules %s\n",
@@ -3737,11 +3749,11 @@ dumpRules(FILE *fout, const char *tablename,
 		 */
 		resetPQExpBuffer(query);
 		appendPQExpBuffer(query, "SELECT pg_get_ruledef(pg_rewrite.rulename) "
-				"AS definition, pg_rewrite.oid, pg_rewrite.rulename FROM pg_rewrite, pg_class "
-				"WHERE pg_class.relname = '%s' "
-				"AND pg_rewrite.ev_class = pg_class.oid "
-				"ORDER BY pg_rewrite.oid",
-				tblinfo[t].relname);
+						  "AS definition, pg_rewrite.oid, pg_rewrite.rulename FROM pg_rewrite, pg_class "
+						  "WHERE pg_class.relname = '%s' "
+						  "AND pg_rewrite.ev_class = pg_class.oid "
+						  "ORDER BY pg_rewrite.oid",
+						  tblinfo[t].relname);
 		res = PQexec(g_conn, query->data);
 		if (!res ||
 			PQresultStatus(res) != PGRES_TUPLES_OK)
@@ -3760,8 +3772,9 @@ dumpRules(FILE *fout, const char *tablename,
 		 * Dump them out
 		 */
 
-		for (i = 0; i < nrules; i++) {
-			
+		for (i = 0; i < nrules; i++)
+		{
+
 			fprintf(fout, "%s\n", PQgetvalue(res, i, i_definition));
 
 			/* Dump rule comments */
@@ -3769,7 +3782,7 @@ dumpRules(FILE *fout, const char *tablename,
 			resetPQExpBuffer(query);
 			appendPQExpBuffer(query, "RULE %s", fmtId(PQgetvalue(res, i, i_rulename), force_quotes));
 			dumpComment(fout, query->data, PQgetvalue(res, i, i_oid));
-			
+
 		}
 
 		PQclear(res);
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index aacc5339fb20b049dbcb4796484599fae8b42ec8..d50015ccfca23156637dd6628f18cb9fe8bc6162 100644
--- a/src/bin/pg_dump/pg_dump.h
+++ b/src/bin/pg_dump/pg_dump.h
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_dump.h,v 1.47 2000/01/26 05:57:38 momjian Exp $
+ * $Id: pg_dump.h,v 1.48 2000/04/12 17:16:15 momjian Exp $
  *
  * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
  *
@@ -75,7 +75,7 @@ typedef struct _tableInfo
 								 * attribute if the value is 1, then this
 								 * attribute is an inherited attribute */
 	char	  **attnames;		/* the attribute names */
-	char      **attoids;        /* oids of the various attributes */
+	char	  **attoids;		/* oids of the various attributes */
 	char	  **typnames;		/* fill out attributes */
 	bool	   *notnull;		/* Not null constraints of an attribute */
 	char	  **adef_expr;		/* DEFAULT expressions */
@@ -95,9 +95,9 @@ typedef struct _tableInfo
 	char	  **check_expr;		/* [CONSTRAINT name] CHECK expressions */
 	int			ntrig;			/* # of triggers */
 	char	  **triggers;		/* CREATE TRIGGER ... */
-	char      **trcomments;     /* COMMENT ON TRIGGER ... */
-	char      **troids;         /* TRIGGER oids */
-    char       *primary_key;    /* PRIMARY KEY of the table, if any */
+	char	  **trcomments;		/* COMMENT ON TRIGGER ... */
+	char	  **troids;			/* TRIGGER oids */
+	char	   *primary_key;	/* PRIMARY KEY of the table, if any */
 } TableInfo;
 
 typedef struct _inhInfo
@@ -108,7 +108,7 @@ typedef struct _inhInfo
 
 typedef struct _indInfo
 {
-	char       *indoid;         /* oid of the pg_class entry for the index */
+	char	   *indoid;			/* oid of the pg_class entry for the index */
 	char	   *indexrelname;	/* name of the secondary index class */
 	char	   *indrelname;		/* name of the indexed heap class */
 	char	   *indamname;		/* name of the access method (e.g. btree,
@@ -234,4 +234,4 @@ extern void dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
 			TableInfo *tbinfo, int numTables, const char *tablename);
 extern const char *fmtId(const char *identifier, bool force_quotes);
 
-#endif /* PG_DUMP_H */
+#endif	 /* PG_DUMP_H */
diff --git a/src/bin/pg_id/pg_id.c b/src/bin/pg_id/pg_id.c
index b118e5e2078e2c6beed44779bd261ed662ebab05..9c3a105c9e6da818c5390c0235b0d699c691da13 100644
--- a/src/bin/pg_id/pg_id.c
+++ b/src/bin/pg_id/pg_id.c
@@ -6,7 +6,7 @@
  *
  * Copyright (C) 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/pg_id.c,v 1.13 2000/02/16 13:15:25 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/pg_id.c,v 1.14 2000/04/12 17:16:17 momjian Exp $
  */
 #include <postgres.h>
 
@@ -19,76 +19,77 @@
 #include <unistd.h>
 #include <sys/types.h>
 
-int main(int argc, char * argv[])
+int
+main(int argc, char *argv[])
 {
-    int c;
-    int nameflag = 0,
-        realflag = 0,
-        userflag = 0;
-    const char * username = NULL;
+	int			c;
+	int			nameflag = 0,
+				realflag = 0,
+				userflag = 0;
+	const char *username = NULL;
 
-    struct passwd * pw;
+	struct passwd *pw;
 
-    while ((c = getopt(argc, argv, "nru")) != -1)
-    {
-        switch(c)
-        {
-            case 'n':
-                nameflag = 1;
-                break;
-            case 'r':
-                realflag = 1;
-                break;
-            case 'u':
-                userflag = 1;
-                break;
-            default:
-                fprintf(stderr, "Usage: %s [-n] [-r] [-u] [username]\n", argv[0]);
-                exit(1);
-        }
-    }
+	while ((c = getopt(argc, argv, "nru")) != -1)
+	{
+		switch (c)
+		{
+			case 'n':
+				nameflag = 1;
+				break;
+			case 'r':
+				realflag = 1;
+				break;
+			case 'u':
+				userflag = 1;
+				break;
+			default:
+				fprintf(stderr, "Usage: %s [-n] [-r] [-u] [username]\n", argv[0]);
+				exit(1);
+		}
+	}
 
-    if (argc - optind >= 1)
-        username = argv[optind];
+	if (argc - optind >= 1)
+		username = argv[optind];
 
-    if (nameflag && !userflag)
-    {
-        fprintf(stderr, "%s: -n must be used together with -u\n", argv[0]);
-        exit(1);
-    }
-    if (username && realflag)
-    {
-        fprintf(stderr, "%s: -r cannot be used when a user name is given\n", argv[0]);
-        exit(1);
-    }
+	if (nameflag && !userflag)
+	{
+		fprintf(stderr, "%s: -n must be used together with -u\n", argv[0]);
+		exit(1);
+	}
+	if (username && realflag)
+	{
+		fprintf(stderr, "%s: -r cannot be used when a user name is given\n", argv[0]);
+		exit(1);
+	}
 
 
-    if (username)
-    {
-        pw = getpwnam(username);
-        if (!pw)
-        {
-            fprintf(stderr, "%s: %s: no such user\n", argv[0], username);
-            exit(1);
-        }
-    }
-    else if (realflag)
-        pw = getpwuid(getuid());
-    else
-        pw = getpwuid(geteuid());
-            
-    if (!pw)
-    {
-        perror(argv[0]);
-        exit(1);
-    }
+	if (username)
+	{
+		pw = getpwnam(username);
+		if (!pw)
+		{
+			fprintf(stderr, "%s: %s: no such user\n", argv[0], username);
+			exit(1);
+		}
+	}
+	else if (realflag)
+		pw = getpwuid(getuid());
+	else
+		pw = getpwuid(geteuid());
 
-    if (!userflag)
-        printf("uid=%d(%s)\n", (int)pw->pw_uid, pw->pw_name);
-    else if (nameflag)
-        puts(pw->pw_name);
-    else
-        printf("%d\n", (int)pw->pw_uid);
+	if (!pw)
+	{
+		perror(argv[0]);
+		exit(1);
+	}
 
-    return 0;
+	if (!userflag)
+		printf("uid=%d(%s)\n", (int) pw->pw_uid, pw->pw_name);
+	else if (nameflag)
+		puts(pw->pw_name);
+	else
+		printf("%d\n", (int) pw->pw_uid);
+
+	return 0;
 }
diff --git a/src/bin/pg_passwd/pg_passwd.c b/src/bin/pg_passwd/pg_passwd.c
index 001ce9a7720b9dc6ca34a94fec8449fb64570dc4..f5edf552ebfde2c260077c44e765201d6ccca0cb 100644
--- a/src/bin/pg_passwd/pg_passwd.c
+++ b/src/bin/pg_passwd/pg_passwd.c
@@ -19,12 +19,12 @@ extern char *crypt(const char *, const char *);
 #endif
 
 char	   *comname;
-static void	usage(FILE *stream);
-static void	read_pwd_file(char *filename);
-static void	write_pwd_file(char *filename, char *bkname);
-static void	encrypt_pwd(char key[9], char salt[3], char passwd[14]);
-static void	prompt_for_username(char *username);
-static void	prompt_for_password(char *prompt, char *password);
+static void usage(FILE *stream);
+static void read_pwd_file(char *filename);
+static void write_pwd_file(char *filename, char *bkname);
+static void encrypt_pwd(char key[9], char salt[3], char passwd[14]);
+static void prompt_for_username(char *username);
+static void prompt_for_password(char *prompt, char *password);
 
 static void
 usage(FILE *stream)
@@ -258,6 +258,7 @@ check_pwd(char key[9], char passwd[14])
 
 	return strncmp(shouldbe, passwd, 13) == 0 ? 1 : 0;
 }
+
 #endif
 
 static void
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index a66e9f4c73e79bf0e725fca89db639ea220a0502..bc95e205065d5f73d0bcafeba385c70a90fd43a3 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.27 2000/04/11 17:35:50 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.28 2000/04/12 17:16:22 momjian Exp $
  */
 #include "postgres.h"
 #include "command.h"
@@ -46,12 +46,15 @@
 
 static backslashResult exec_command(const char *cmd,
 			 const char *options_string,
-             const char ** continue_parse,
+			 const char **continue_parse,
 			 PQExpBuffer query_buf);
 
-enum option_type { OT_NORMAL, OT_SQLID };
-static char * scan_option(char ** string, enum option_type type, char * quote);
-static char * unescape(const unsigned char *source, size_t len);
+enum option_type
+{
+	OT_NORMAL, OT_SQLID
+};
+static char *scan_option(char **string, enum option_type type, char *quote);
+static char *unescape(const unsigned char *source, size_t len);
 
 static bool do_edit(const char *filename_arg, PQExpBuffer query_buf);
 static bool do_connect(const char *new_dbname, const char *new_user);
@@ -84,35 +87,35 @@ HandleSlashCmds(const char *line,
 {
 	backslashResult status = CMD_SKIP_LINE;
 	char	   *my_line;
-	char       *options_string = NULL;
+	char	   *options_string = NULL;
 	size_t		blank_loc;
 	const char *continue_parse = NULL;	/* tell the mainloop where the
 										 * backslash command ended */
 
 #ifdef USE_ASSERT_CHECKING
-    assert(line);
-    assert(end_of_cmd);
+	assert(line);
+	assert(end_of_cmd);
 #endif
 
 	my_line = xstrdup(line);
 
 	/*
-	 * Find the first whitespace. line[blank_loc] will now
-	 * be the whitespace character or the \0 at the end
-     *
-     * Also look for a backslash, so stuff like \p\g works.
+	 * Find the first whitespace. line[blank_loc] will now be the
+	 * whitespace character or the \0 at the end
+	 *
+	 * Also look for a backslash, so stuff like \p\g works.
 	 */
 	blank_loc = strcspn(my_line, " \t\\");
 
-    if (my_line[blank_loc] == '\\')
-    {
-        continue_parse = &my_line[blank_loc];
+	if (my_line[blank_loc] == '\\')
+	{
+		continue_parse = &my_line[blank_loc];
 		my_line[blank_loc] = '\0';
-    }
+	}
 	/* do we have an option string? */
 	else if (my_line[blank_loc] != '\0')
-    {
-        options_string = &my_line[blank_loc + 1];
+	{
+		options_string = &my_line[blank_loc + 1];
 		my_line[blank_loc] = '\0';
 	}
 
@@ -120,11 +123,12 @@ HandleSlashCmds(const char *line,
 
 	if (status == CMD_UNKNOWN)
 	{
+
 		/*
-		 * If the command was not recognized, try inserting a space after the
-         * first letter and call again. The one letter commands allow arguments
-         * to start immediately after the command, but that is no longer
-         * encouraged.
+		 * If the command was not recognized, try inserting a space after
+		 * the first letter and call again. The one letter commands allow
+		 * arguments to start immediately after the command, but that is
+		 * no longer encouraged.
 		 */
 		char		new_cmd[2];
 
@@ -133,29 +137,29 @@ HandleSlashCmds(const char *line,
 
 		status = exec_command(new_cmd, my_line + 1, &continue_parse, query_buf);
 
-        if (status != CMD_UNKNOWN && isalpha(new_cmd[0]))
-            psql_error("Warning: this syntax is deprecated\n");
+		if (status != CMD_UNKNOWN && isalpha(new_cmd[0]))
+			psql_error("Warning: this syntax is deprecated\n");
 	}
 
 	if (status == CMD_UNKNOWN)
 	{
-        if (pset.cur_cmd_interactive)
-            fprintf(stderr, "Invalid command \\%s. Try \\? for help.\n", my_line);
-        else
-            psql_error("invalid command \\%s\n", my_line);
+		if (pset.cur_cmd_interactive)
+			fprintf(stderr, "Invalid command \\%s. Try \\? for help.\n", my_line);
+		else
+			psql_error("invalid command \\%s\n", my_line);
 		status = CMD_ERROR;
 	}
 
 	if (continue_parse && *continue_parse && *(continue_parse + 1) == '\\')
 		continue_parse += 2;
 
-    if (end_of_cmd)
-    {
-        if (continue_parse)
-            *end_of_cmd = line + (continue_parse - my_line);
-        else
-            *end_of_cmd = line + strlen(line);
-    }
+	if (end_of_cmd)
+	{
+		if (continue_parse)
+			*end_of_cmd = line + (continue_parse - my_line);
+		else
+			*end_of_cmd = line + strlen(line);
+	}
 
 	free(my_line);
 
@@ -167,25 +171,30 @@ HandleSlashCmds(const char *line,
 static backslashResult
 exec_command(const char *cmd,
 			 const char *options_string,
-             const char ** continue_parse,
+			 const char **continue_parse,
 			 PQExpBuffer query_buf)
 {
 	bool		success = true; /* indicate here if the command ran ok or
 								 * failed */
 	bool		quiet = QUIET();
 	backslashResult status = CMD_SKIP_LINE;
-    char       *string, *string_cpy;
-
-    /*
-     * The 'string' variable will be overwritten to point to the next token,
-     * hence we need an extra pointer so we can free this at the end.
-     */
-    if (options_string)
-        string = string_cpy = xstrdup(options_string);
-    else
-        string = string_cpy = NULL;
-
-	/* \a -- toggle field alignment This makes little sense but we keep it around. */
+	char	   *string,
+			   *string_cpy;
+
+	/*
+	 * The 'string' variable will be overwritten to point to the next
+	 * token, hence we need an extra pointer so we can free this at the
+	 * end.
+	 */
+	if (options_string)
+		string = string_cpy = xstrdup(options_string);
+	else
+		string = string_cpy = NULL;
+
+	/*
+	 * \a -- toggle field alignment This makes little sense but we keep it
+	 * around.
+	 */
 	if (strcmp(cmd, "a") == 0)
 	{
 		if (pset.popt.topt.format != PRINT_ALIGNED)
@@ -196,51 +205,54 @@ exec_command(const char *cmd,
 
 	/* \C -- override table title (formerly change HTML caption) */
 	else if (strcmp(cmd, "C") == 0)
-    {
-        char * opt = scan_option(&string, OT_NORMAL, NULL);
+	{
+		char	   *opt = scan_option(&string, OT_NORMAL, NULL);
+
 		success = do_pset("title", opt, &pset.popt, quiet);
-        free(opt);
-    }
+		free(opt);
+	}
 
 	/*----------
 	 * \c or \connect -- connect to new database or as different user
 	 *
 	 * \c foo bar  connect to db "foo" as user "bar"
-     * \c foo [-]  connect to db "foo" as current user
-     * \c - bar    connect to current db as user "bar"
-     * \c          connect to default db as default user
-     *----------
+	 * \c foo [-]  connect to db "foo" as current user
+	 * \c - bar    connect to current db as user "bar"
+	 * \c		   connect to default db as default user
+	 *----------
 	 */
 	else if (strcmp(cmd, "c") == 0 || strcmp(cmd, "connect") == 0)
 	{
-        char *opt1, *opt2;
-        char opt1q, opt2q;
+		char	   *opt1,
+				   *opt2;
+		char		opt1q,
+					opt2q;
 
-        opt1 = scan_option(&string, OT_NORMAL, &opt1q);
-        opt2 = scan_option(&string, OT_NORMAL, &opt2q);
+		opt1 = scan_option(&string, OT_NORMAL, &opt1q);
+		opt2 = scan_option(&string, OT_NORMAL, &opt2q);
 
 		if (opt2)
 			/* gave username */
-			success = do_connect(!opt1q && (strcmp(opt1, "-")==0 || strcmp(opt1, "")==0) ? "" : opt1,
-                                 !opt2q && (strcmp(opt2, "-")==0 || strcmp(opt2, "")==0) ? "" : opt2);
+			success = do_connect(!opt1q && (strcmp(opt1, "-") == 0 || strcmp(opt1, "") == 0) ? "" : opt1,
+								 !opt2q && (strcmp(opt2, "-") == 0 || strcmp(opt2, "") == 0) ? "" : opt2);
 		else if (opt1)
-            /* gave database name */
-            success = do_connect(!opt1q && (strcmp(opt1, "-")==0 || strcmp(opt1, "")==0) ? "" : opt1, "");
-        else
-            /* connect to default db as default user */
-            success = do_connect(NULL, NULL);
-
-        free(opt1);
-        free(opt2);
+			/* gave database name */
+			success = do_connect(!opt1q && (strcmp(opt1, "-") == 0 || strcmp(opt1, "") == 0) ? "" : opt1, "");
+		else
+			/* connect to default db as default user */
+			success = do_connect(NULL, NULL);
+
+		free(opt1);
+		free(opt2);
 	}
 
 	/* \copy */
 	else if (strcasecmp(cmd, "copy") == 0)
-    {
+	{
 		success = do_copy(options_string);
-        if (options_string)
-            string += strlen(string);
-    }
+		if (options_string)
+			string += strlen(string);
+	}
 
 	/* \copyright */
 	else if (strcmp(cmd, "copyright") == 0)
@@ -249,20 +261,20 @@ exec_command(const char *cmd,
 	/* \d* commands */
 	else if (cmd[0] == 'd')
 	{
-        char * name;
-        bool show_verbose;
+		char	   *name;
+		bool		show_verbose;
 
-        name = scan_option(&string, OT_SQLID, NULL);
-        show_verbose = strchr(cmd, '+') ? true : false;
+		name = scan_option(&string, OT_SQLID, NULL);
+		show_verbose = strchr(cmd, '+') ? true : false;
 
 		switch (cmd[1])
 		{
 			case '\0':
-            case '+':
+			case '+':
 				if (name)
 					success = describeTableDetails(name, show_verbose);
 				else
-                    /* standard listing of interesting things */
+					/* standard listing of interesting things */
 					success = listTables("tvs", NULL, show_verbose);
 				break;
 			case 'a':
@@ -299,7 +311,7 @@ exec_command(const char *cmd,
 			default:
 				status = CMD_UNKNOWN;
 		}
-        free(name);
+		free(name);
 	}
 
 
@@ -308,63 +320,63 @@ exec_command(const char *cmd,
 	 * the query buffer
 	 */
 	else if (strcmp(cmd, "e") == 0 || strcmp(cmd, "edit") == 0)
-    {
-        char * fname;
-
-        if (!query_buf)
-        {
-            psql_error("no query buffer\n");
-            status = CMD_ERROR;
-        }
-        else
-        {
-            fname = scan_option(&string, OT_NORMAL, NULL);
-            status = do_edit(fname, query_buf) ? CMD_NEWEDIT : CMD_ERROR;
-            free(fname);
-        }
-    }
+	{
+		char	   *fname;
+
+		if (!query_buf)
+		{
+			psql_error("no query buffer\n");
+			status = CMD_ERROR;
+		}
+		else
+		{
+			fname = scan_option(&string, OT_NORMAL, NULL);
+			status = do_edit(fname, query_buf) ? CMD_NEWEDIT : CMD_ERROR;
+			free(fname);
+		}
+	}
 
 	/* \echo and \qecho */
-	else if (strcmp(cmd, "echo") == 0 || strcmp(cmd, "qecho")==0)
+	else if (strcmp(cmd, "echo") == 0 || strcmp(cmd, "qecho") == 0)
 	{
-        char * value;
-        char quoted;
-        bool no_newline = false;
-        bool first = true;
-        FILE * fout;
-
-        if (strcmp(cmd, "qecho")==0)
-            fout = pset.queryFout;
-        else
-            fout = stdout;
-
-        while((value = scan_option(&string, OT_NORMAL, &quoted)))
-        {
-            if (!quoted && strcmp(value, "-n")==0)
-                no_newline = true;
-            else
-            {
-                if (first)
-                    first = false;
-                else
-                    fputc(' ', fout);
-                fputs(value, fout);
-            }
-            free(value);
-        }
-        if (!no_newline)
-            fputs("\n", fout);
+		char	   *value;
+		char		quoted;
+		bool		no_newline = false;
+		bool		first = true;
+		FILE	   *fout;
+
+		if (strcmp(cmd, "qecho") == 0)
+			fout = pset.queryFout;
+		else
+			fout = stdout;
+
+		while ((value = scan_option(&string, OT_NORMAL, &quoted)))
+		{
+			if (!quoted && strcmp(value, "-n") == 0)
+				no_newline = true;
+			else
+			{
+				if (first)
+					first = false;
+				else
+					fputc(' ', fout);
+				fputs(value, fout);
+			}
+			free(value);
+		}
+		if (!no_newline)
+			fputs("\n", fout);
 	}
 
 	/* \encoding -- set/show client side encoding */
 	else if (strcmp(cmd, "encoding") == 0)
 	{
-		char *encoding = scan_option(&string, OT_NORMAL, NULL);
+		char	   *encoding = scan_option(&string, OT_NORMAL, NULL);
 
-	        if (!encoding)
+		if (!encoding)
 			/* show encoding */
 			puts(pg_encoding_to_char(pset.encoding));
-	        else
+		else
 		{
 #ifdef MULTIBYTE
 			/* set encoding */
@@ -380,63 +392,66 @@ exec_command(const char *cmd,
 #else
 			psql_error("\\%s: multi-byte support is not enabled\n", cmd);
 #endif
-		        free(encoding);
-	        }
+			free(encoding);
+		}
 	}
 
 	/* \f -- change field separator */
 	else if (strcmp(cmd, "f") == 0)
-    {
-        char * fname = scan_option(&string, OT_NORMAL, NULL);
+	{
+		char	   *fname = scan_option(&string, OT_NORMAL, NULL);
+
 		success = do_pset("fieldsep", fname, &pset.popt, quiet);
-        free(fname);
-    }
+		free(fname);
+	}
 
 	/* \g means send query */
 	else if (strcmp(cmd, "g") == 0)
 	{
-        char * fname = scan_option(&string, OT_NORMAL, NULL);
+		char	   *fname = scan_option(&string, OT_NORMAL, NULL);
+
 		if (!fname)
 			pset.gfname = NULL;
 		else
 			pset.gfname = xstrdup(fname);
-        free(fname);
+		free(fname);
 		status = CMD_SEND;
 	}
 
 	/* help */
 	else if (strcmp(cmd, "h") == 0 || strcmp(cmd, "help") == 0)
-    {
+	{
 		helpSQL(options_string ? &options_string[strspn(options_string, " \t")] : NULL);
-        /* set pointer to end of line */
-        if (string)
-            string += strlen(string);
-    }
+		/* set pointer to end of line */
+		if (string)
+			string += strlen(string);
+	}
 
 	/* HTML mode */
 	else if (strcmp(cmd, "H") == 0 || strcmp(cmd, "html") == 0)
-    {
+	{
 		if (pset.popt.topt.format != PRINT_HTML)
 			success = do_pset("format", "html", &pset.popt, quiet);
 		else
 			success = do_pset("format", "aligned", &pset.popt, quiet);
-    }
+	}
 
 
 	/* \i is include file */
 	else if (strcmp(cmd, "i") == 0 || strcmp(cmd, "include") == 0)
 	{
-        char * fname = scan_option(&string, OT_NORMAL, NULL);
+		char	   *fname = scan_option(&string, OT_NORMAL, NULL);
+
 		if (!fname)
-        {
-            psql_error("\\%s: missing required argument\n", cmd);
+		{
+			psql_error("\\%s: missing required argument\n", cmd);
 			success = false;
 		}
 		else
-        {
+		{
 			success = (process_file(fname) == EXIT_SUCCESS);
-            free (fname);
-        }
+			free(fname);
+		}
 	}
 
 	/* \l is list databases */
@@ -446,20 +461,21 @@ exec_command(const char *cmd,
 		success = listAllDbs(true);
 
 	/*
-     * large object things
-     */
+	 * large object things
+	 */
 	else if (strncmp(cmd, "lo_", 3) == 0)
 	{
-        char *opt1, *opt2;
+		char	   *opt1,
+				   *opt2;
 
-        opt1 = scan_option(&string, OT_NORMAL, NULL);
-        opt2 = scan_option(&string, OT_NORMAL, NULL);
+		opt1 = scan_option(&string, OT_NORMAL, NULL);
+		opt2 = scan_option(&string, OT_NORMAL, NULL);
 
 		if (strcmp(cmd + 3, "export") == 0)
 		{
 			if (!opt2)
 			{
-                psql_error("\\%s: missing required argument\n", cmd);
+				psql_error("\\%s: missing required argument\n", cmd);
 				success = false;
 			}
 			else
@@ -470,7 +486,7 @@ exec_command(const char *cmd,
 		{
 			if (!opt1)
 			{
-                psql_error("\\%s: missing required argument\n", cmd);
+				psql_error("\\%s: missing required argument\n", cmd);
 				success = false;
 			}
 			else
@@ -484,7 +500,7 @@ exec_command(const char *cmd,
 		{
 			if (!opt1)
 			{
-                psql_error("\\%s: missing required argument\n", cmd);
+				psql_error("\\%s: missing required argument\n", cmd);
 				success = false;
 			}
 			else
@@ -494,18 +510,19 @@ exec_command(const char *cmd,
 		else
 			status = CMD_UNKNOWN;
 
-        free(opt1);
-        free(opt2);
+		free(opt1);
+		free(opt2);
 	}
 
 
 	/* \o -- set query output */
 	else if (strcmp(cmd, "o") == 0 || strcmp(cmd, "out") == 0)
-    {
-        char * fname = scan_option(&string, OT_NORMAL, NULL);
+	{
+		char	   *fname = scan_option(&string, OT_NORMAL, NULL);
+
 		success = setQFout(fname);
-        free(fname);
-    }
+		free(fname);
+	}
 
 	/* \p prints the current query buffer */
 	else if (strcmp(cmd, "p") == 0 || strcmp(cmd, "print") == 0)
@@ -520,18 +537,19 @@ exec_command(const char *cmd,
 	/* \pset -- set printing parameters */
 	else if (strcmp(cmd, "pset") == 0)
 	{
-        char * opt0 = scan_option(&string, OT_NORMAL, NULL);
-        char * opt1 = scan_option(&string, OT_NORMAL, NULL);
+		char	   *opt0 = scan_option(&string, OT_NORMAL, NULL);
+		char	   *opt1 = scan_option(&string, OT_NORMAL, NULL);
+
 		if (!opt0)
 		{
-            psql_error("\\%s: missing required argument\n", cmd);
+			psql_error("\\%s: missing required argument\n", cmd);
 			success = false;
 		}
 		else
 			success = do_pset(opt0, opt1, &pset.popt, quiet);
 
-        free(opt0);
-        free(opt1);
+		free(opt0);
+		free(opt1);
 	}
 
 	/* \q or \quit */
@@ -549,28 +567,27 @@ exec_command(const char *cmd,
 	/* \s save history in a file or show it on the screen */
 	else if (strcmp(cmd, "s") == 0)
 	{
-		char *fname = scan_option(&string, OT_NORMAL, NULL);
+		char	   *fname = scan_option(&string, OT_NORMAL, NULL);
 
 		success = saveHistory(fname ? fname : "/dev/tty");
 
 		if (success && !quiet && fname)
 			printf("Wrote history to %s.\n", fname);
-        free(fname);
+		free(fname);
 	}
 
 	/* \set -- generalized set variable/option command */
 	else if (strcmp(cmd, "set") == 0)
 	{
-        char * opt0 = scan_option(&string, OT_NORMAL, NULL);
+		char	   *opt0 = scan_option(&string, OT_NORMAL, NULL);
 
 		if (!opt0)
 		{
 			/* list all variables */
 
 			/*
-			 * XXX
-             * This is in utter violation of the GetVariable abstraction, but I
-             * have not bothered to do it better.
+			 * XXX This is in utter violation of the GetVariable
+			 * abstraction, but I have not bothered to do it better.
 			 */
 			struct _variable *ptr;
 
@@ -580,36 +597,37 @@ exec_command(const char *cmd,
 		}
 		else
 		{
-            /*
-             * Set variable to the concatenation of the arguments.
-             */
-            char * newval = NULL;
-            char * opt;
-
-            opt = scan_option(&string, OT_NORMAL, NULL);
-            newval = xstrdup(opt ? opt : "");
-            free(opt);
-
-            while ((opt = scan_option(&string, OT_NORMAL, NULL)))
-            {
-                newval = realloc(newval, strlen(newval) + strlen(opt) + 1);
-                if (!newval)
-                {
-                    psql_error("out of memory\n");
-                    exit(EXIT_FAILURE);
-                }
-                strcat(newval, opt);
-                free(opt);
-            }
+
+			/*
+			 * Set variable to the concatenation of the arguments.
+			 */
+			char	   *newval = NULL;
+			char	   *opt;
+
+			opt = scan_option(&string, OT_NORMAL, NULL);
+			newval = xstrdup(opt ? opt : "");
+			free(opt);
+
+			while ((opt = scan_option(&string, OT_NORMAL, NULL)))
+			{
+				newval = realloc(newval, strlen(newval) + strlen(opt) + 1);
+				if (!newval)
+				{
+					psql_error("out of memory\n");
+					exit(EXIT_FAILURE);
+				}
+				strcat(newval, opt);
+				free(opt);
+			}
 
 			if (!SetVariable(pset.vars, opt0, newval))
 			{
-                psql_error("\\%s: error\n", cmd);
+				psql_error("\\%s: error\n", cmd);
 				success = false;
 			}
-            free(newval);
+			free(newval);
 		}
-        free(opt0);
+		free(opt0);
 	}
 
 	/* \t -- turn off headers and row count */
@@ -619,67 +637,69 @@ exec_command(const char *cmd,
 
 	/* \T -- define html <table ...> attributes */
 	else if (strcmp(cmd, "T") == 0)
-    {
-        char * value = scan_option(&string, OT_NORMAL, NULL);
+	{
+		char	   *value = scan_option(&string, OT_NORMAL, NULL);
+
 		success = do_pset("tableattr", value, &pset.popt, quiet);
-        free(value);
-    }
-
-    /* \unset */
-    else if (strcmp(cmd, "unset") == 0)
-    {
-        char * opt = scan_option(&string, OT_NORMAL, NULL);
-        if (!opt)
-        {
-            psql_error("\\%s: missing required argument\n", cmd);
-            success = false;
-        }
-        if (!SetVariable(pset.vars, opt, NULL))
-        {
-            psql_error("\\%s: error\n", cmd);
-            success = false;
-        }
-        free(opt);
-    }
+		free(value);
+	}
+
+	/* \unset */
+	else if (strcmp(cmd, "unset") == 0)
+	{
+		char	   *opt = scan_option(&string, OT_NORMAL, NULL);
+
+		if (!opt)
+		{
+			psql_error("\\%s: missing required argument\n", cmd);
+			success = false;
+		}
+		if (!SetVariable(pset.vars, opt, NULL))
+		{
+			psql_error("\\%s: error\n", cmd);
+			success = false;
+		}
+		free(opt);
+	}
 
 	/* \w -- write query buffer to file */
 	else if (strcmp(cmd, "w") == 0 || strcmp(cmd, "write") == 0)
 	{
 		FILE	   *fd = NULL;
 		bool		is_pipe = false;
-        char       *fname = NULL;
-
-        if (!query_buf)
-        {
-            psql_error("no query buffer\n");
-            status = CMD_ERROR;
-        }
-        else
-        {
-            fname = scan_option(&string, OT_NORMAL, NULL);
-
-            if (!fname)
-            {
-                psql_error("\\%s: missing required argument\n", cmd);
-                success = false;
-            }
-            else
-            {
-                if (fname[0] == '|')
-                {
-                    is_pipe = true;
-                    fd = popen(&fname[1], "w");
-                }
-                else
-                    fd = fopen(fname, "w");
-
-                if (!fd)
-                {
-                    psql_error("%s: %s\n", fname, strerror(errno));
-                    success = false;
-                }
-            }
-        }
+		char	   *fname = NULL;
+
+		if (!query_buf)
+		{
+			psql_error("no query buffer\n");
+			status = CMD_ERROR;
+		}
+		else
+		{
+			fname = scan_option(&string, OT_NORMAL, NULL);
+
+			if (!fname)
+			{
+				psql_error("\\%s: missing required argument\n", cmd);
+				success = false;
+			}
+			else
+			{
+				if (fname[0] == '|')
+				{
+					is_pipe = true;
+					fd = popen(&fname[1], "w");
+				}
+				else
+					fd = fopen(fname, "w");
+
+				if (!fd)
+				{
+					psql_error("%s: %s\n", fname, strerror(errno));
+					success = false;
+				}
+			}
+		}
 
 		if (fd)
 		{
@@ -695,12 +715,12 @@ exec_command(const char *cmd,
 
 			if (result == EOF)
 			{
-                psql_error("%s: %s\n", fname, strerror(errno));
+				psql_error("%s: %s\n", fname, strerror(errno));
 				success = false;
 			}
 		}
 
-        free(fname);
+		free(fname);
 	}
 
 	/* \x -- toggle expanded table representation */
@@ -710,41 +730,43 @@ exec_command(const char *cmd,
 
 	/* \z -- list table rights (grant/revoke) */
 	else if (strcmp(cmd, "z") == 0)
-    {
-        char * opt = scan_option(&string, OT_SQLID, NULL);
+	{
+		char	   *opt = scan_option(&string, OT_SQLID, NULL);
+
 		success = permissionsList(opt);
-        free(opt);
-    }
+		free(opt);
+	}
 
-    /* \! -- shell escape */
+	/* \! -- shell escape */
 	else if (strcmp(cmd, "!") == 0)
-    {
+	{
 		success = do_shell(options_string);
-        /* wind pointer to end of line */
-        if (string)
-            string += strlen(string);
-    }
+		/* wind pointer to end of line */
+		if (string)
+			string += strlen(string);
+	}
 
-    /* \? -- slash command help */
+	/* \? -- slash command help */
 	else if (strcmp(cmd, "?") == 0)
 		slashUsage();
 
 #if 0
-    /*
+
+	/*
 	 * These commands don't do anything. I just use them to test the
 	 * parser.
 	 */
 	else if (strcmp(cmd, "void") == 0 || strcmp(cmd, "#") == 0)
 	{
 		int			i = 0;
-        char       *value;
+		char	   *value;
 
 		fprintf(stderr, "+ optstr = |%s|\n", options_string);
-        while((value = scan_option(&string, OT_NORMAL, NULL)))
-        {
+		while ((value = scan_option(&string, OT_NORMAL, NULL)))
+		{
 			fprintf(stderr, "+ opt(%d) = |%s|\n", i++, value);
-            free(value);
-        }
+			free(value);
+		}
 	}
 #endif
 
@@ -754,12 +776,12 @@ exec_command(const char *cmd,
 	if (!success)
 		status = CMD_ERROR;
 
-    /* eat the rest of the options string */
-    while(scan_option(&string, OT_NORMAL, NULL)) ;
+	/* eat the rest of the options string */
+	while (scan_option(&string, OT_NORMAL, NULL));
 
-    if (options_string && continue_parse)
-        *continue_parse = options_string + (string - string_cpy);
-    free(string_cpy);
+	if (options_string && continue_parse)
+		*continue_parse = options_string + (string - string_cpy);
+	free(string_cpy);
 
 	return status;
 }
@@ -770,268 +792,272 @@ exec_command(const char *cmd,
  * scan_option()
  */
 static char *
-scan_option(char ** string, enum option_type type, char * quote)
+scan_option(char **string, enum option_type type, char *quote)
 {
-    unsigned int pos = 0;
-    char * options_string;
-    char * return_val;
-
-    if (quote)
-        *quote = 0;
-
-    if (!string || !(*string))
-        return NULL;
-
-    options_string = *string;
-    /* skip leading whitespace */
-    pos += strspn(options_string+pos, " \t");
-
-    switch (options_string[pos])
-    {
-        /*
-         * Double quoted string
-         */
-        case '"':
-        {
-            unsigned int jj;
-            unsigned short int bslash_count = 0;
-
-            /* scan for end of quote */
-            for (jj = pos+1; options_string[jj]; jj += PQmblen(&options_string[jj], pset.encoding))
-            {
-                if (options_string[jj] == '"' && bslash_count % 2 == 0)
-                    break;
-
-                if (options_string[jj] == '\\')
-                    bslash_count++;
-                else
-                    bslash_count=0;
-            }
-
-            if (options_string[jj] == 0)
-            {
-                psql_error("parse error at end of line\n");
-                *string = &options_string[jj];
-                return NULL;
-            }
-
-            return_val = malloc(jj-pos+2);
-            if (!return_val)
-            {
-                psql_error("out of memory\n");
-                exit(EXIT_FAILURE);
-            }
-
-            if (type == OT_NORMAL)
-            {
-                strncpy(return_val, &options_string[pos], jj-pos+1);
-                return_val[jj-pos+1] = '\0';
-            }
-            /*
-             * If this is expected to be an SQL identifier like option
-             * then we strip out the double quotes
-             */
-            else if (type == OT_SQLID)
-            {
-                unsigned int k, cc;
-
-                bslash_count = 0;
-                cc = 0;
-                for (k = pos+1; options_string[k]; k += PQmblen(&options_string[k], pset.encoding))
-                {   
-                    if (options_string[k] == '"' && bslash_count % 2 == 0)
-                        break;
-                                        
-                    if (options_string[jj] == '\\')
-                        bslash_count++;
-                    else
-                        bslash_count=0;
-                    
-                    return_val[cc++] = options_string[k];
-                }
-                return_val[cc] = '\0';
-            }       
-                    
-            *string = options_string + jj+1;
-            if (quote)
-                *quote = '"';
-                    
-            return return_val;
-        }           
-
-        /*
-         * A single quote has a psql internal meaning, such as
-         * for delimiting file names, and it also allows for such
-         * escape sequences as \t.
-         */
-        case '\'':
-        {
-            unsigned int jj;
-            unsigned short int bslash_count = 0;
-
-            for (jj = pos+1; options_string[jj]; jj += PQmblen(&options_string[jj], pset.encoding))
-            {
-                if (options_string[jj] == '\'' && bslash_count % 2 == 0)
-                    break;
-
-                if (options_string[jj] == '\\')
-                    bslash_count++;
-                else
-                    bslash_count=0;
-            }
-
-            if (options_string[jj] == 0)
-            {
-                psql_error("parse error at end of line\n");
-                *string = &options_string[jj];
-                return NULL;
-            }
-
-            return_val = unescape(&options_string[pos+1], jj-pos-1);
-            *string = &options_string[jj + 1];
-            if (quote)
-                *quote = '\'';
-            return return_val;
-        }
-
-        /*
-         * Backticks are for command substitution, like in shells
-         */
-        case '`':
-        {
-            bool		error = false;
-            FILE	   *fd = NULL;
-            char	   *file;
-            PQExpBufferData output;
-            char		buf[512];
-            size_t		result, len;
-
-            len = strcspn(options_string + pos + 1, "`");
-            if (options_string[pos + 1 + len] == 0)
-            {
-                psql_error("parse error at end of line\n");
-                *string = &options_string[pos + 1 + len];
-                return NULL;
-            }
-
-            options_string[pos + 1 + len] = '\0';
-            file = options_string + pos + 1;
-
-            fd = popen(file, "r");
-            if (!fd)
-            {
-                psql_error("%s: %s\n", file, strerror(errno));
-                error = true;
-            }
-
-            if (!error)
-            {
-                initPQExpBuffer(&output);
-
-                do
-                {
-                    result = fread(buf, 1, 512, fd);
-                    if (ferror(fd))
-                    {
-                        psql_error("%s: %s\n", file, strerror(errno));
-                        error = true;
-                        break;
-                    }
-                    appendBinaryPQExpBuffer(&output, buf, result);
-                } while (!feof(fd));
-                appendPQExpBufferChar(&output, '\0');
-
-                if (pclose(fd) == -1)
-                {
-                    psql_error("%s: %s\n", file, strerror(errno));
-                    error = true;
-                }
-            }
-
-            if (!error)
-            {
-                if (output.data[strlen(output.data) - 1] == '\n')
-                    output.data[strlen(output.data) - 1] = '\0';
-            }
-
-            if (!error)
-                return_val = output.data;
-            else
-            {
-                return_val = xstrdup("");
-                termPQExpBuffer(&output);
-            }
-            options_string[pos + 1 + len] = '`';
-            *string = options_string + pos + len + 2;
-            if (quote)
-                *quote = '`';
-            return return_val;
-        }
-
-        /*
-         * end of line
-         */
-        case 0:
-            *string = &options_string[pos];
-            return NULL;
-
-        /*
-         * Variable substitution
-         */
-        case ':':
-        {
-            size_t token_end;
-            const char * value;
-            char save_char;
-            
-            token_end = strcspn(&options_string[pos+1], " \t");
-            save_char = options_string[pos+token_end+1];
-            options_string[pos+token_end+1] = '\0';
-            value  = GetVariable(pset.vars, options_string+pos+1);
-            if (!value)
-                value = "";
-            return_val = xstrdup(value);
-            options_string[pos+token_end+1] = save_char;
-            *string = &options_string[pos + token_end+1];
-            return return_val;
-        }
-
-        /*
-         * Next command
-         */
-        case '\\':
-            *string = options_string + pos;
-            return NULL;
-            break;
-
-        /*
-         * A normal word
-         */
-        default:
-        {
-            size_t token_end;
-            char * cp;
-            
-            token_end = strcspn(&options_string[pos], " \t");
-            return_val = malloc(token_end + 1);
-            if (!return_val)
-            {
-                psql_error("out of memory\n");
-                exit(EXIT_FAILURE);
-            }
-            strncpy(return_val, &options_string[pos], token_end);
-            return_val[token_end] = 0;
-
-            if (type == OT_SQLID)
-                for (cp = return_val; *cp; cp += PQmblen(cp, pset.encoding))
-                    if (isascii(*cp))
-                        *cp = tolower(*cp);
-
-            *string = &options_string[pos+token_end];
-            return return_val;
-        }
-            
-    }
+	unsigned int pos = 0;
+	char	   *options_string;
+	char	   *return_val;
+
+	if (quote)
+		*quote = 0;
+
+	if (!string || !(*string))
+		return NULL;
+
+	options_string = *string;
+	/* skip leading whitespace */
+	pos += strspn(options_string + pos, " \t");
+
+	switch (options_string[pos])
+	{
+
+			/*
+			 * Double quoted string
+			 */
+		case '"':
+			{
+				unsigned int jj;
+				unsigned short int bslash_count = 0;
+
+				/* scan for end of quote */
+				for (jj = pos + 1; options_string[jj]; jj += PQmblen(&options_string[jj], pset.encoding))
+				{
+					if (options_string[jj] == '"' && bslash_count % 2 == 0)
+						break;
+
+					if (options_string[jj] == '\\')
+						bslash_count++;
+					else
+						bslash_count = 0;
+				}
+
+				if (options_string[jj] == 0)
+				{
+					psql_error("parse error at end of line\n");
+					*string = &options_string[jj];
+					return NULL;
+				}
+
+				return_val = malloc(jj - pos + 2);
+				if (!return_val)
+				{
+					psql_error("out of memory\n");
+					exit(EXIT_FAILURE);
+				}
+
+				if (type == OT_NORMAL)
+				{
+					strncpy(return_val, &options_string[pos], jj - pos + 1);
+					return_val[jj - pos + 1] = '\0';
+				}
+
+				/*
+				 * If this is expected to be an SQL identifier like option
+				 * then we strip out the double quotes
+				 */
+				else if (type == OT_SQLID)
+				{
+					unsigned int k,
+								cc;
+
+					bslash_count = 0;
+					cc = 0;
+					for (k = pos + 1; options_string[k]; k += PQmblen(&options_string[k], pset.encoding))
+					{
+						if (options_string[k] == '"' && bslash_count % 2 == 0)
+							break;
+
+						if (options_string[jj] == '\\')
+							bslash_count++;
+						else
+							bslash_count = 0;
+
+						return_val[cc++] = options_string[k];
+					}
+					return_val[cc] = '\0';
+				}
+
+				*string = options_string + jj + 1;
+				if (quote)
+					*quote = '"';
+
+				return return_val;
+			}
+
+			/*
+			 * A single quote has a psql internal meaning, such as for
+			 * delimiting file names, and it also allows for such escape
+			 * sequences as \t.
+			 */
+		case '\'':
+			{
+				unsigned int jj;
+				unsigned short int bslash_count = 0;
+
+				for (jj = pos + 1; options_string[jj]; jj += PQmblen(&options_string[jj], pset.encoding))
+				{
+					if (options_string[jj] == '\'' && bslash_count % 2 == 0)
+						break;
+
+					if (options_string[jj] == '\\')
+						bslash_count++;
+					else
+						bslash_count = 0;
+				}
+
+				if (options_string[jj] == 0)
+				{
+					psql_error("parse error at end of line\n");
+					*string = &options_string[jj];
+					return NULL;
+				}
+
+				return_val = unescape(&options_string[pos + 1], jj - pos - 1);
+				*string = &options_string[jj + 1];
+				if (quote)
+					*quote = '\'';
+				return return_val;
+			}
+
+			/*
+			 * Backticks are for command substitution, like in shells
+			 */
+		case '`':
+			{
+				bool		error = false;
+				FILE	   *fd = NULL;
+				char	   *file;
+				PQExpBufferData output;
+				char		buf[512];
+				size_t		result,
+							len;
+
+				len = strcspn(options_string + pos + 1, "`");
+				if (options_string[pos + 1 + len] == 0)
+				{
+					psql_error("parse error at end of line\n");
+					*string = &options_string[pos + 1 + len];
+					return NULL;
+				}
+
+				options_string[pos + 1 + len] = '\0';
+				file = options_string + pos + 1;
+
+				fd = popen(file, "r");
+				if (!fd)
+				{
+					psql_error("%s: %s\n", file, strerror(errno));
+					error = true;
+				}
+
+				if (!error)
+				{
+					initPQExpBuffer(&output);
+
+					do
+					{
+						result = fread(buf, 1, 512, fd);
+						if (ferror(fd))
+						{
+							psql_error("%s: %s\n", file, strerror(errno));
+							error = true;
+							break;
+						}
+						appendBinaryPQExpBuffer(&output, buf, result);
+					} while (!feof(fd));
+					appendPQExpBufferChar(&output, '\0');
+
+					if (pclose(fd) == -1)
+					{
+						psql_error("%s: %s\n", file, strerror(errno));
+						error = true;
+					}
+				}
+
+				if (!error)
+				{
+					if (output.data[strlen(output.data) - 1] == '\n')
+						output.data[strlen(output.data) - 1] = '\0';
+				}
+
+				if (!error)
+					return_val = output.data;
+				else
+				{
+					return_val = xstrdup("");
+					termPQExpBuffer(&output);
+				}
+				options_string[pos + 1 + len] = '`';
+				*string = options_string + pos + len + 2;
+				if (quote)
+					*quote = '`';
+				return return_val;
+			}
+
+			/*
+			 * end of line
+			 */
+		case 0:
+			*string = &options_string[pos];
+			return NULL;
+
+			/*
+			 * Variable substitution
+			 */
+		case ':':
+			{
+				size_t		token_end;
+				const char *value;
+				char		save_char;
+
+				token_end = strcspn(&options_string[pos + 1], " \t");
+				save_char = options_string[pos + token_end + 1];
+				options_string[pos + token_end + 1] = '\0';
+				value = GetVariable(pset.vars, options_string + pos + 1);
+				if (!value)
+					value = "";
+				return_val = xstrdup(value);
+				options_string[pos + token_end + 1] = save_char;
+				*string = &options_string[pos + token_end + 1];
+				return return_val;
+			}
+
+			/*
+			 * Next command
+			 */
+		case '\\':
+			*string = options_string + pos;
+			return NULL;
+			break;
+
+			/*
+			 * A normal word
+			 */
+		default:
+			{
+				size_t		token_end;
+				char	   *cp;
+
+				token_end = strcspn(&options_string[pos], " \t");
+				return_val = malloc(token_end + 1);
+				if (!return_val)
+				{
+					psql_error("out of memory\n");
+					exit(EXIT_FAILURE);
+				}
+				strncpy(return_val, &options_string[pos], token_end);
+				return_val[token_end] = 0;
+
+				if (type == OT_SQLID)
+					for (cp = return_val; *cp; cp += PQmblen(cp, pset.encoding))
+						if (isascii(*cp))
+							*cp = tolower(*cp);
+
+				*string = &options_string[pos + token_end];
+				return return_val;
+			}
+
+	}
 }
 
 
@@ -1066,7 +1092,7 @@ unescape(const unsigned char *source, size_t len)
 		exit(EXIT_FAILURE);
 	}
 
-	for (p = source; p-source < len && *p; p += PQmblen(p, pset.encoding))
+	for (p = source; p - source < len && *p; p += PQmblen(p, pset.encoding))
 	{
 		if (esc)
 		{
@@ -1152,12 +1178,12 @@ do_connect(const char *new_dbname, const char *new_user)
 	bool		need_pass;
 	bool		success = false;
 
-    /* Delete variables (in case we fail before setting them anew) */
-    SetVariable(pset.vars, "DBNAME", NULL);
-    SetVariable(pset.vars, "USER", NULL);
-    SetVariable(pset.vars, "HOST", NULL);
-    SetVariable(pset.vars, "PORT", NULL);
-    SetVariable(pset.vars, "ENCODING", NULL);
+	/* Delete variables (in case we fail before setting them anew) */
+	SetVariable(pset.vars, "DBNAME", NULL);
+	SetVariable(pset.vars, "USER", NULL);
+	SetVariable(pset.vars, "HOST", NULL);
+	SetVariable(pset.vars, "PORT", NULL);
+	SetVariable(pset.vars, "ENCODING", NULL);
 
 	/* If dbname is "" then use old name, else new one (even if NULL) */
 	if (oldconn && new_dbname && PQdb(oldconn) && strcmp(new_dbname, "") == 0)
@@ -1166,7 +1192,7 @@ do_connect(const char *new_dbname, const char *new_user)
 		dbparam = new_dbname;
 
 	/* If user is "" then use the old one */
-	if (new_user && PQuser(oldconn) && strcmp(new_user, "")==0)
+	if (new_user && PQuser(oldconn) && strcmp(new_user, "") == 0)
 		userparam = PQuser(oldconn);
 	else
 		userparam = new_user;
@@ -1187,7 +1213,7 @@ do_connect(const char *new_dbname, const char *new_user)
 	{
 		need_pass = false;
 		pset.db = PQsetdbLogin(PQhost(oldconn), PQport(oldconn),
-								NULL, NULL, dbparam, userparam, pwparam);
+							   NULL, NULL, dbparam, userparam, pwparam);
 
 		if (PQstatus(pset.db) == CONNECTION_BAD &&
 			strcmp(PQerrorMessage(pset.db), "fe_sendauth: no password supplied\n") == 0)
@@ -1207,27 +1233,30 @@ do_connect(const char *new_dbname, const char *new_user)
 	 */
 	if (!pset.db || PQstatus(pset.db) == CONNECTION_BAD)
 	{
-        if (pset.cur_cmd_interactive)
-        {
-            psql_error("%s", PQerrorMessage(pset.db));
-            PQfinish(pset.db);
-            if (oldconn)
-            {
-                fputs("Previous connection kept\n", stderr);
-                pset.db = oldconn;
-            }
-            else
-                pset.db = NULL;
-        }
-        else
-        {
-            /* we don't want unpredictable things to
-             * happen in scripting mode */
-            psql_error("\\connect: %s", PQerrorMessage(pset.db));
-            PQfinish(pset.db);
+		if (pset.cur_cmd_interactive)
+		{
+			psql_error("%s", PQerrorMessage(pset.db));
+			PQfinish(pset.db);
+			if (oldconn)
+			{
+				fputs("Previous connection kept\n", stderr);
+				pset.db = oldconn;
+			}
+			else
+				pset.db = NULL;
+		}
+		else
+		{
+
+			/*
+			 * we don't want unpredictable things to happen in scripting
+			 * mode
+			 */
+			psql_error("\\connect: %s", PQerrorMessage(pset.db));
+			PQfinish(pset.db);
 			if (oldconn)
 				PQfinish(oldconn);
-            pset.db = NULL;
+			pset.db = NULL;
 		}
 	}
 	else
@@ -1238,7 +1267,8 @@ do_connect(const char *new_dbname, const char *new_user)
 				printf("You are now connected to database %s.\n", dbparam);
 			else if (dbparam != new_dbname)		/* no new db */
 				printf("You are now connected as new user %s.\n", new_user);
-			else /* both new */
+			else
+/* both new */
 				printf("You are now connected to database %s as user %s.\n",
 					   PQdb(pset.db), PQuser(pset.db));
 		}
@@ -1249,17 +1279,17 @@ do_connect(const char *new_dbname, const char *new_user)
 		success = true;
 	}
 
-    PQsetNoticeProcessor(pset.db, NoticeProcessor, NULL);
-    pset.encoding = PQclientEncoding(pset.db);
+	PQsetNoticeProcessor(pset.db, NoticeProcessor, NULL);
+	pset.encoding = PQclientEncoding(pset.db);
 
-    /* Update variables */
-    SetVariable(pset.vars, "DBNAME", PQdb(pset.db));
-    SetVariable(pset.vars, "USER", PQuser(pset.db));
-    SetVariable(pset.vars, "HOST", PQhost(pset.db));
-    SetVariable(pset.vars, "PORT", PQport(pset.db));
-    SetVariable(pset.vars, "ENCODING", pg_encoding_to_char(pset.encoding));
+	/* Update variables */
+	SetVariable(pset.vars, "DBNAME", PQdb(pset.db));
+	SetVariable(pset.vars, "USER", PQuser(pset.db));
+	SetVariable(pset.vars, "HOST", PQhost(pset.db));
+	SetVariable(pset.vars, "PORT", PQport(pset.db));
+	SetVariable(pset.vars, "ENCODING", pg_encoding_to_char(pset.encoding));
 
-    pset.issuper = test_superuser(PQuser(pset.db));
+	pset.issuper = test_superuser(PQuser(pset.db));
 
 	return success;
 }
@@ -1271,25 +1301,25 @@ do_connect(const char *new_dbname, const char *new_user)
  * (Is used to set up the prompt right.)
  */
 bool
-test_superuser(const char * username)
+test_superuser(const char *username)
 {
-    PGresult *res;
-    char buf[64 + NAMEDATALEN];
-    bool answer;
-
-    if (!username)
-        return false;
-
-    sprintf(buf, "SELECT usesuper FROM pg_user WHERE usename = '%.*s'", NAMEDATALEN, username);
-    res = PSQLexec(buf);
-
-    answer =
-        (PQntuples(res)>0 && PQnfields(res)>0
-         && !PQgetisnull(res,0,0)
-         && PQgetvalue(res,0,0)
-         && strcmp(PQgetvalue(res,0,0), "t")==0);
-    PQclear(res);
-    return answer;
+	PGresult   *res;
+	char		buf[64 + NAMEDATALEN];
+	bool		answer;
+
+	if (!username)
+		return false;
+
+	sprintf(buf, "SELECT usesuper FROM pg_user WHERE usename = '%.*s'", NAMEDATALEN, username);
+	res = PSQLexec(buf);
+
+	answer =
+		(PQntuples(res) > 0 && PQnfields(res) > 0
+		 && !PQgetisnull(res, 0, 0)
+		 && PQgetvalue(res, 0, 0)
+		 && strcmp(PQgetvalue(res, 0, 0), "t") == 0);
+	PQclear(res);
+	return answer;
 }
 
 
@@ -1330,8 +1360,8 @@ editFile(const char *fname)
 	sprintf(sys, "exec %s %s", editorName, fname);
 	result = system(sys);
 	if (result == -1)
-        psql_error("could not start editor %s\n", editorName);
-    else if (result == 127)
+		psql_error("could not start editor %s\n", editorName);
+	else if (result == 127)
 		psql_error("could not start /bin/sh\n");
 	free(sys);
 
@@ -1362,11 +1392,11 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
 		/* make a temp file to edit */
 #ifndef WIN32
 		mode_t		oldumask;
-        const char *tmpdirenv = getenv("TMPDIR");
+		const char *tmpdirenv = getenv("TMPDIR");
 
 		sprintf(fnametmp, "%s/psql.edit.%ld.%ld",
-                tmpdirenv ? tmpdirenv : "/tmp",
-                (long) geteuid(), (long) getpid());
+				tmpdirenv ? tmpdirenv : "/tmp",
+				(long) geteuid(), (long) getpid());
 #else
 		GetTempFileName(".", "psql", 0, fnametmp);
 #endif
@@ -1382,7 +1412,7 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
 
 		if (!stream)
 		{
-            psql_error("couldn't open temp file %s: %s\n", fname, strerror(errno));
+			psql_error("couldn't open temp file %s: %s\n", fname, strerror(errno));
 			error = true;
 		}
 		else
@@ -1397,7 +1427,7 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
 
 			if (fwrite(query_buf->data, 1, ql, stream) != ql)
 			{
-                psql_error("%s: %s\n", fname, strerror(errno));
+				psql_error("%s: %s\n", fname, strerror(errno));
 				fclose(stream);
 				remove(fname);
 				error = true;
@@ -1410,7 +1440,7 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
 #ifndef WIN32
 	if (!error && stat(fname, &before) != 0)
 	{
-        psql_error("%s: %s\n", fname, strerror(errno));
+		psql_error("%s: %s\n", fname, strerror(errno));
 		error = true;
 	}
 #endif
@@ -1422,7 +1452,7 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
 #ifndef WIN32
 	if (!error && stat(fname, &after) != 0)
 	{
-        psql_error("%s: %s\n", fname, strerror(errno));
+		psql_error("%s: %s\n", fname, strerror(errno));
 		error = true;
 	}
 
@@ -1435,7 +1465,7 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
 		stream = fopen(fname, "r");
 		if (!stream)
 		{
-            psql_error("%s: %s\n", fname, strerror(errno));
+			psql_error("%s: %s\n", fname, strerror(errno));
 			error = true;
 		}
 		else
@@ -1444,29 +1474,29 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
 			char		line[1024];
 
 			resetPQExpBuffer(query_buf);
-            while (fgets(line, 1024, stream))
+			while (fgets(line, 1024, stream))
 				appendPQExpBufferStr(query_buf, line);
 
-            if (ferror(stream))
-            {
-                psql_error("%s: %s\n", fname, strerror(errno));
-                error = true;
-            }
+			if (ferror(stream))
+			{
+				psql_error("%s: %s\n", fname, strerror(errno));
+				error = true;
+			}
 
 			fclose(stream);
 		}
 
-    }
+	}
 
-  		/* remove temp file */
+	/* remove temp file */
 	if (!filename_arg)
-    {
-		if (remove(fname)==-1)
-        {
-            psql_error("%s: %s\n", fname, strerror(errno));
-            error=true;
-        }
-    }
+	{
+		if (remove(fname) == -1)
+		{
+			psql_error("%s: %s\n", fname, strerror(errno));
+			error = true;
+		}
+	}
 
 	return !error;
 }
@@ -1484,7 +1514,7 @@ process_file(char *filename)
 {
 	FILE	   *fd;
 	int			result;
-    char       *oldfilename;
+	char	   *oldfilename;
 
 	if (!filename)
 		return false;
@@ -1493,12 +1523,12 @@ process_file(char *filename)
 
 	if (!fd)
 	{
-        psql_error("%s: %s\n", filename, strerror(errno));
+		psql_error("%s: %s\n", filename, strerror(errno));
 		return false;
 	}
 
-    oldfilename = pset.inputfile;
-    pset.inputfile = filename;
+	oldfilename = pset.inputfile;
+	pset.inputfile = filename;
 	result = MainLoop(fd);
 	fclose(fd);
 	pset.inputfile = oldfilename;
@@ -1537,7 +1567,7 @@ _align2string(enum printFormat in)
 
 
 bool
-do_pset(const char *param, const char *value, printQueryOpt * popt, bool quiet)
+do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
 {
 	size_t		vallen = 0;
 
@@ -1624,12 +1654,13 @@ do_pset(const char *param, const char *value, printQueryOpt * popt, bool quiet)
 			free(popt->topt.recordSep);
 			popt->topt.recordSep = xstrdup(value);
 		}
-		if (!quiet) {
-            if (strcmp(popt->topt.recordSep, "\n")==0)
-                printf("Record separator is <newline>.");
-            else
-                printf("Record separator is '%s'.\n", popt->topt.recordSep);
-        }
+		if (!quiet)
+		{
+			if (strcmp(popt->topt.recordSep, "\n") == 0)
+				printf("Record separator is <newline>.");
+			else
+				printf("Record separator is '%s'.\n", popt->topt.recordSep);
+		}
 	}
 
 	/* toggle between full and barebones format */
@@ -1723,13 +1754,14 @@ do_shell(const char *command)
 			shellName = DEFAULT_SHELL;
 
 		sys = malloc(strlen(shellName) + 16);
-		if (!sys) {
-            psql_error("out of memory\n");
-            if (pset.cur_cmd_interactive)
-                return false;
-            else
-                exit(EXIT_FAILURE);
-        }
+		if (!sys)
+		{
+			psql_error("out of memory\n");
+			if (pset.cur_cmd_interactive)
+				return false;
+			else
+				exit(EXIT_FAILURE);
+		}
 		sprintf(sys, "exec %s", shellName);
 		result = system(sys);
 		free(sys);
@@ -1739,7 +1771,7 @@ do_shell(const char *command)
 
 	if (result == 127 || result == -1)
 	{
-        psql_error("\\!: failed\n");
+		psql_error("\\!: failed\n");
 		return false;
 	}
 	return true;
diff --git a/src/bin/psql/command.h b/src/bin/psql/command.h
index 1fec5346faaa62e0047153f4aacf52b98d301059..f719d2aa206c620fff432db25b770eec7490ca27 100644
--- a/src/bin/psql/command.h
+++ b/src/bin/psql/command.h
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/command.h,v 1.9 2000/02/20 14:28:20 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/command.h,v 1.10 2000/04/12 17:16:22 momjian Exp $
  */
 #ifndef COMMAND_H
 #define COMMAND_H
@@ -23,24 +23,22 @@ typedef enum _backslashResult
 	CMD_NEWEDIT,				/* query buffer was changed (e.g., via \e) */
 	CMD_ERROR					/* the execution of the backslash command
 								 * resulted in an error */
-}			backslashResult;
+} backslashResult;
 
 
-backslashResult
-HandleSlashCmds(const char *line,
+backslashResult HandleSlashCmds(const char *line,
 				PQExpBuffer query_buf,
 				const char **end_of_cmd);
 
 int
-process_file(char *filename);
+			process_file(char *filename);
 
 bool
-test_superuser(const char * username);
+			test_superuser(const char *username);
 
-bool
-do_pset(const char *param,
+bool do_pset(const char *param,
 		const char *value,
-		printQueryOpt * popt,
+		printQueryOpt *popt,
 		bool quiet);
 
-#endif /* COMMAND_H */
+#endif	 /* COMMAND_H */
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c
index fbf6950ffd3c24f05b2380547cdcb10b12348272..d3551c5acccbe0a74574b7e4b4d83baf39ed55e2 100644
--- a/src/bin/psql/common.c
+++ b/src/bin/psql/common.c
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.19 2000/03/05 13:30:19 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.20 2000/04/12 17:16:22 momjian Exp $
  */
 #include "postgres.h"
 #include "common.h"
@@ -21,7 +21,7 @@
 #include <unistd.h>				/* for write() */
 #include <setjmp.h>
 #else
-#include <io.h>                 /* for _write() */
+#include <io.h>					/* for _write() */
 #include <win32.h>
 #endif
 
@@ -49,13 +49,13 @@ xstrdup(const char *string)
 	if (!string)
 	{
 		fprintf(stderr, "%s: xstrdup: cannot duplicate null pointer (internal error)\n",
-                pset.progname);
+				pset.progname);
 		exit(EXIT_FAILURE);
 	}
 	tmp = strdup(string);
 	if (!tmp)
 	{
-        psql_error("out of memory\n");
+		psql_error("out of memory\n");
 		exit(EXIT_FAILURE);
 	}
 	return tmp;
@@ -125,23 +125,23 @@ setQFout(const char *fname)
 
 /*
  * Error reporting for scripts. Errors should look like
- *   psql:filename:lineno: message
+ *	 psql:filename:lineno: message
  *
  */
 void
-psql_error(const char *fmt, ...)
+psql_error(const char *fmt,...)
 {
-    va_list ap;
+	va_list		ap;
 
-    fflush(stdout);
-    if (pset.queryFout!=stdout)
-        fflush(pset.queryFout);
+	fflush(stdout);
+	if (pset.queryFout != stdout)
+		fflush(pset.queryFout);
 
-    if (pset.inputfile)
-        fprintf(stderr, "%s:%s:%u: ", pset.progname, pset.inputfile, pset.lineno);
-    va_start(ap, fmt);
-    vfprintf(stderr, fmt, ap);
-    va_end(ap);
+	if (pset.inputfile)
+		fprintf(stderr, "%s:%s:%u: ", pset.progname, pset.inputfile, pset.lineno);
+	va_start(ap, fmt);
+	vfprintf(stderr, fmt, ap);
+	va_end(ap);
 }
 
 
@@ -150,10 +150,10 @@ psql_error(const char *fmt, ...)
  * for backend NOTICES
  */
 void
-NoticeProcessor(void * arg, const char * message)
+NoticeProcessor(void *arg, const char *message)
 {
-    (void)arg; /* not used */
-    psql_error("%s", message);
+	(void) arg;					/* not used */
+	psql_error("%s", message);
 }
 
 
@@ -181,6 +181,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
 #ifdef HAVE_TERMIOS_H
 	struct termios t_orig,
 				t;
+
 #endif
 
 	destination = (char *) malloc(maxlen + 2);
@@ -189,7 +190,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
 	if (prompt)
 		fputs(prompt, stderr);
 
-    prompt_state = true;
+	prompt_state = true;
 
 #ifdef HAVE_TERMIOS_H
 	if (!echo)
@@ -211,7 +212,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
 	}
 #endif
 
-    prompt_state = false;
+	prompt_state = false;
 
 	length = strlen(destination);
 	if (length > 0 && destination[length - 1] != '\n')
@@ -244,7 +245,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
  * facilities in a signal handler.
  */
 
-PGconn *cancelConn;
+PGconn	   *cancelConn;
 volatile bool cancel_pressed;
 
 #ifndef WIN32
@@ -254,14 +255,14 @@ volatile bool cancel_pressed;
 void
 handle_sigint(SIGNAL_ARGS)
 {
-    /* Don't muck around if copying in or prompting for a password. */
-    if ((copy_in_state && pset.cur_cmd_interactive) || prompt_state)
-        return;
+	/* Don't muck around if copying in or prompting for a password. */
+	if ((copy_in_state && pset.cur_cmd_interactive) || prompt_state)
+		return;
 
 	if (cancelConn == NULL)
-        siglongjmp(main_loop_jmp, 1);
+		siglongjmp(main_loop_jmp, 1);
 
-    cancel_pressed = true;
+	cancel_pressed = true;
 
 	if (PQrequestCancel(cancelConn))
 		write_stderr("Cancel request sent\n");
@@ -271,7 +272,8 @@ handle_sigint(SIGNAL_ARGS)
 		write_stderr(PQerrorMessage(cancelConn));
 	}
 }
-#endif /* not WIN32 */
+
+#endif	 /* not WIN32 */
 
 
 /*
@@ -288,7 +290,7 @@ PSQLexec(const char *query)
 
 	if (!pset.db)
 	{
-        psql_error("You are currently not connected to a database.\n");
+		psql_error("You are currently not connected to a database.\n");
 		return NULL;
 	}
 
@@ -304,19 +306,19 @@ PSQLexec(const char *query)
 
 	cancelConn = pset.db;
 	res = PQexec(pset.db, query);
-    if (PQresultStatus(res) == PGRES_COPY_IN)
-        copy_in_state = true;
-    /* keep cancel connection for copy out state */
-    if (PQresultStatus(res) != PGRES_COPY_OUT)
-        cancelConn = NULL;
+	if (PQresultStatus(res) == PGRES_COPY_IN)
+		copy_in_state = true;
+	/* keep cancel connection for copy out state */
+	if (PQresultStatus(res) != PGRES_COPY_OUT)
+		cancelConn = NULL;
 
 	if (PQstatus(pset.db) == CONNECTION_BAD)
 	{
-        if (!pset.cur_cmd_interactive)
-        {
-            psql_error("connection to server was lost\n");
-            exit(EXIT_BADCONN);
-        }
+		if (!pset.cur_cmd_interactive)
+		{
+			psql_error("connection to server was lost\n");
+			exit(EXIT_BADCONN);
+		}
 		fputs("The connection to the server was lost. Attempting reset: ", stderr);
 		PQreset(pset.db);
 		if (PQstatus(pset.db) == CONNECTION_BAD)
@@ -325,11 +327,11 @@ PSQLexec(const char *query)
 			PQfinish(pset.db);
 			PQclear(res);
 			pset.db = NULL;
-            SetVariable(pset.vars, "DBNAME", NULL);
-            SetVariable(pset.vars, "HOST", NULL);
-            SetVariable(pset.vars, "PORT", NULL);
-            SetVariable(pset.vars, "USER", NULL);
-            SetVariable(pset.vars, "ENCODING", NULL);
+			SetVariable(pset.vars, "DBNAME", NULL);
+			SetVariable(pset.vars, "HOST", NULL);
+			SetVariable(pset.vars, "PORT", NULL);
+			SetVariable(pset.vars, "USER", NULL);
+			SetVariable(pset.vars, "ENCODING", NULL);
 			return NULL;
 		}
 		else
@@ -344,7 +346,7 @@ PSQLexec(const char *query)
 		return res;
 	else
 	{
-        psql_error("%s", PQerrorMessage(pset.db));
+		psql_error("%s", PQerrorMessage(pset.db));
 		PQclear(res);
 		return NULL;
 	}
@@ -373,7 +375,7 @@ SendQuery(const char *query)
 
 	if (!pset.db)
 	{
-        psql_error("You are currently not connected to a database.\n");
+		psql_error("You are currently not connected to a database.\n");
 		return false;
 	}
 
@@ -382,28 +384,29 @@ SendQuery(const char *query)
 		char		buf[3];
 
 		printf("***(Single step mode: Verify query)*********************************************\n"
-               "%s\n"
-               "***(press return to proceed or enter x and return to cancel)********************\n",
-               query);
+			   "%s\n"
+			   "***(press return to proceed or enter x and return to cancel)********************\n",
+			   query);
 		fflush(stdout);
 		fgets(buf, 3, stdin);
 		if (buf[0] == 'x')
 			return false;
 	}
-    else
-    {
-        const char * var = GetVariable(pset.vars, "ECHO");
-        if (var && strncmp(var, "queries", strlen(var))==0)
-            puts(query);
-    }
+	else
+	{
+		const char *var = GetVariable(pset.vars, "ECHO");
+
+		if (var && strncmp(var, "queries", strlen(var)) == 0)
+			puts(query);
+	}
 
 	cancelConn = pset.db;
 	results = PQexec(pset.db, query);
-    if (PQresultStatus(results) == PGRES_COPY_IN)
-        copy_in_state = true;
-    /* keep cancel connection for copy out state */
-    if (PQresultStatus(results) != PGRES_COPY_OUT)
-        cancelConn = NULL;
+	if (PQresultStatus(results) == PGRES_COPY_IN)
+		copy_in_state = true;
+	/* keep cancel connection for copy out state */
+	if (PQresultStatus(results) != PGRES_COPY_OUT)
+		cancelConn = NULL;
 
 	if (results == NULL)
 	{
@@ -415,14 +418,16 @@ SendQuery(const char *query)
 		switch (PQresultStatus(results))
 		{
 			case PGRES_TUPLES_OK:
-                /* write output to \g argument, if any */
+				/* write output to \g argument, if any */
 				if (pset.gfname)
 				{
-					FILE * queryFout_copy = pset.queryFout;
-                    bool queryFoutPipe_copy = pset.queryFoutPipe;
-                    pset.queryFout = NULL; /* so it doesn't get closed */
+					FILE	   *queryFout_copy = pset.queryFout;
+					bool		queryFoutPipe_copy = pset.queryFoutPipe;
 
-                    /* open file/pipe */
+					pset.queryFout = NULL;		/* so it doesn't get
+												 * closed */
+
+					/* open file/pipe */
 					if (!setQFout(pset.gfname))
 					{
 						success = false;
@@ -438,7 +443,7 @@ SendQuery(const char *query)
 					pset.gfname = NULL;
 
 					pset.queryFout = queryFout_copy;
-                    pset.queryFoutPipe = queryFoutPipe_copy;
+					pset.queryFoutPipe = queryFoutPipe_copy;
 
 					success = true;
 					break;
@@ -453,16 +458,16 @@ SendQuery(const char *query)
 				success = true;
 				break;
 			case PGRES_COMMAND_OK:
-            {
-                char buf[10];
+				{
+					char		buf[10];
 
-				success = true;
-                sprintf(buf, "%u", (unsigned int)PQoidValue(results));
-                if (!QUIET())
-                    fprintf(pset.queryFout, "%s\n", PQcmdStatus(results));
-                SetVariable(pset.vars, "LASTOID", buf);
-				break;
-            }
+					success = true;
+					sprintf(buf, "%u", (unsigned int) PQoidValue(results));
+					if (!QUIET())
+						fprintf(pset.queryFout, "%s\n", PQcmdStatus(results));
+					SetVariable(pset.vars, "LASTOID", buf);
+					break;
+				}
 			case PGRES_COPY_OUT:
 				success = handleCopyOut(pset.db, pset.queryFout);
 				break;
@@ -480,19 +485,19 @@ SendQuery(const char *query)
 			case PGRES_FATAL_ERROR:
 			case PGRES_BAD_RESPONSE:
 				success = false;
-                psql_error("%s", PQerrorMessage(pset.db));
+				psql_error("%s", PQerrorMessage(pset.db));
 				break;
 		}
 
-        fflush(pset.queryFout);
+		fflush(pset.queryFout);
 
 		if (PQstatus(pset.db) == CONNECTION_BAD)
 		{
-            if (!pset.cur_cmd_interactive)
-            {
-                psql_error("connection to server was lost\n");
-                exit(EXIT_BADCONN);
-            }
+			if (!pset.cur_cmd_interactive)
+			{
+				psql_error("connection to server was lost\n");
+				exit(EXIT_BADCONN);
+			}
 			fputs("The connection to the server was lost. Attempting reset: ", stderr);
 			PQreset(pset.db);
 			if (PQstatus(pset.db) == CONNECTION_BAD)
@@ -501,29 +506,29 @@ SendQuery(const char *query)
 				PQfinish(pset.db);
 				PQclear(results);
 				pset.db = NULL;
-                SetVariable(pset.vars, "DBNAME", NULL);
-                SetVariable(pset.vars, "HOST", NULL);
-                SetVariable(pset.vars, "PORT", NULL);
-                SetVariable(pset.vars, "USER", NULL);
-                SetVariable(pset.vars, "ENCODING", NULL);
+				SetVariable(pset.vars, "DBNAME", NULL);
+				SetVariable(pset.vars, "HOST", NULL);
+				SetVariable(pset.vars, "PORT", NULL);
+				SetVariable(pset.vars, "USER", NULL);
+				SetVariable(pset.vars, "ENCODING", NULL);
 				return false;
 			}
 			else
 				fputs("Succeeded.\n", stderr);
 		}
-        
+
 		/* check for asynchronous notification returns */
 		while ((notify = PQnotifies(pset.db)) != NULL)
 		{
 			fprintf(pset.queryFout, "Asynchronous NOTIFY '%s' from backend with pid '%d' received.\n",
 					notify->relname, notify->be_pid);
 			free(notify);
-            fflush(pset.queryFout);
+			fflush(pset.queryFout);
 		}
 
 		if (results)
 			PQclear(results);
-    }
+	}
 
 	return success;
 }
diff --git a/src/bin/psql/common.h b/src/bin/psql/common.h
index 2f343e425a670fd896e4537f06b57f06037c6e39..b2600060e1ae2ed056c3f44718355f02013d53cb 100644
--- a/src/bin/psql/common.h
+++ b/src/bin/psql/common.h
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/common.h,v 1.9 2000/03/05 13:30:19 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/common.h,v 1.10 2000/04/12 17:16:22 momjian Exp $
  */
 #ifndef COMMON_H
 #define COMMON_H
@@ -13,28 +13,32 @@
 #include "pqsignal.h"
 #include "libpq-fe.h"
 
-char *		xstrdup(const char *string);
+char	   *xstrdup(const char *string);
 
 bool		setQFout(const char *fname);
 
 #ifndef __GNUC__
-void        psql_error(const char *fmt, ...);
+void		psql_error(const char *fmt,...);
+
 #else
 /* This checks the format string for consistency. */
-void        psql_error(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
+void		psql_error(const char *fmt,...) __attribute__((format(printf, 1, 2)));
+
 #endif
 
-void        NoticeProcessor(void * arg, const char * message);
+void		NoticeProcessor(void *arg, const char *message);
 
-char *		simple_prompt(const char *prompt, int maxlen, bool echo);
+char	   *simple_prompt(const char *prompt, int maxlen, bool echo);
 
 extern volatile bool cancel_pressed;
 extern PGconn *cancelConn;
+
 #ifndef WIN32
-void        handle_sigint(SIGNAL_ARGS);
-#endif /* not WIN32 */
+void		handle_sigint(SIGNAL_ARGS);
+
+#endif	 /* not WIN32 */
 
-PGresult *	PSQLexec(const char *query);
+PGresult   *PSQLexec(const char *query);
 
 bool		SendQuery(const char *query);
 
diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c
index 9f338979f185c4e7aaac2278f96c010c5e6f23c9..7e08a1d6b167fb80ad4229a4cf3a7509cdc22bad 100644
--- a/src/bin/psql/copy.c
+++ b/src/bin/psql/copy.c
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.12 2000/03/01 21:09:58 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.13 2000/04/12 17:16:22 momjian Exp $
  */
 #include "postgres.h"
 #include "copy.h"
@@ -28,7 +28,7 @@
 #define strcasecmp(x,y) stricmp(x,y)
 #endif
 
-bool copy_in_state;
+bool		copy_in_state;
 
 /*
  * parse_slash_copy
@@ -43,12 +43,12 @@ bool copy_in_state;
 struct copy_options
 {
 	char	   *table;
-	char	   *file;  /* NULL = stdin/stdout */
+	char	   *file;			/* NULL = stdin/stdout */
 	bool		from;
 	bool		binary;
 	bool		oids;
 	char	   *delim;
-    char       *null;
+	char	   *null;
 };
 
 
@@ -60,7 +60,7 @@ free_copy_options(struct copy_options * ptr)
 	free(ptr->table);
 	free(ptr->file);
 	free(ptr->delim);
-    free(ptr->null);
+	free(ptr->null);
 	free(ptr);
 }
 
@@ -88,8 +88,8 @@ parse_slash_copy(const char *args)
 	else
 	{
 #ifdef NOT_USED
-        /* this is not implemented yet */
-        if (!quote && strcasecmp(token, "binary") == 0)
+		/* this is not implemented yet */
+		if (!quote && strcasecmp(token, "binary") == 0)
 		{
 			result->binary = true;
 			token = strtokx(NULL, " \t", "\"", '\\', &quote, NULL, pset.encoding);
@@ -142,9 +142,9 @@ parse_slash_copy(const char *args)
 		token = strtokx(NULL, " \t", "'", '\\', &quote, NULL, pset.encoding);
 		if (!token)
 			error = true;
-		else if (!quote && (strcasecmp(token, "stdin")==0 || strcasecmp(token, "stdout")==0))
-            result->file = NULL;
-        else
+		else if (!quote && (strcasecmp(token, "stdin") == 0 || strcasecmp(token, "stdout") == 0))
+			result->file = NULL;
+		else
 			result->file = xstrdup(token);
 	}
 
@@ -162,36 +162,36 @@ parse_slash_copy(const char *args)
 				{
 					token = strtokx(NULL, " \t", "'", '\\', NULL, NULL, pset.encoding);
 					if (token)
-                    {
+					{
 						result->delim = xstrdup(token);
-                        token = strtokx(NULL, " \t", NULL, '\\', NULL, NULL, pset.encoding);
-                    }
+						token = strtokx(NULL, " \t", NULL, '\\', NULL, NULL, pset.encoding);
+					}
 					else
 						error = true;
 				}
 			}
 
-            if (!error && token)
-            {
-                if (strcasecmp(token, "with") == 0)
-                {
-                    token = strtokx(NULL, " \t", NULL, '\\', NULL, NULL, pset.encoding);
-                    if (!token || strcasecmp(token, "null") != 0)
-                        error = true;
-                    else
-                    {
-                        token = strtokx(NULL, " \t", NULL, '\\', NULL, NULL, pset.encoding);
-                        if (!token || strcasecmp(token, "as") != 0)
-                            error = true;
-                        else
-                        {
-                            token = strtokx(NULL, " \t", "'", '\\', NULL, NULL, pset.encoding);
-                            if (token)
-                                result->null = xstrdup(token);
-                        }
-                    }
-                }
-            }
+			if (!error && token)
+			{
+				if (strcasecmp(token, "with") == 0)
+				{
+					token = strtokx(NULL, " \t", NULL, '\\', NULL, NULL, pset.encoding);
+					if (!token || strcasecmp(token, "null") != 0)
+						error = true;
+					else
+					{
+						token = strtokx(NULL, " \t", NULL, '\\', NULL, NULL, pset.encoding);
+						if (!token || strcasecmp(token, "as") != 0)
+							error = true;
+						else
+						{
+							token = strtokx(NULL, " \t", "'", '\\', NULL, NULL, pset.encoding);
+							if (token)
+								result->null = xstrdup(token);
+						}
+					}
+				}
+			}
 		}
 	}
 
@@ -199,10 +199,10 @@ parse_slash_copy(const char *args)
 
 	if (error)
 	{
-        psql_error("\\copy: parse error at %s%s%s\n",
-                   token ? "'" : "",
-                   token ? token : "end of line",
-                   token ? "'" : "");
+		psql_error("\\copy: parse error at %s%s%s\n",
+				   token ? "'" : "",
+				   token ? token : "end of line",
+				   token ? "'" : "");
 		free_copy_options(result);
 		return NULL;
 	}
@@ -234,7 +234,7 @@ do_copy(const char *args)
 
 	strcpy(query, "COPY ");
 	if (options->binary)
-        strcat(query, "BINARY ");
+		strcat(query, "BINARY ");
 
 	strcat(query, "\"");
 	strncat(query, options->table, NAMEDATALEN);
@@ -255,32 +255,32 @@ do_copy(const char *args)
 		strcat(query, "'");
 	}
 
-    if (options->null)
-    {
+	if (options->null)
+	{
 		strcat(query, " WITH NULL AS '");
 		strcat(query, options->null);
 		strcat(query, "'");
 	}
 
 	if (options->from)
-    {
-        if (options->file)
-            copystream = fopen(options->file, "r");
-        else
-            copystream = stdin;
-    }
+	{
+		if (options->file)
+			copystream = fopen(options->file, "r");
+		else
+			copystream = stdin;
+	}
 	else
-    {
-        if (options->file)
-            copystream = fopen(options->file, "w");
-        else
-            copystream = stdout;
-    }
+	{
+		if (options->file)
+			copystream = fopen(options->file, "w");
+		else
+			copystream = stdout;
+	}
 
 	if (!copystream)
 	{
-        psql_error("%s: %s\n",
-                   options->file, strerror(errno));
+		psql_error("%s: %s\n",
+				   options->file, strerror(errno));
 		free_copy_options(options);
 		return false;
 	}
@@ -299,7 +299,7 @@ do_copy(const char *args)
 		case PGRES_FATAL_ERROR:
 		case PGRES_BAD_RESPONSE:
 			success = false;
-            psql_error("\\copy: %s", PQerrorMessage(pset.db));
+			psql_error("\\copy: %s", PQerrorMessage(pset.db));
 			break;
 		default:
 			success = false;
@@ -308,8 +308,8 @@ do_copy(const char *args)
 
 	PQclear(result);
 
-    if (copystream != stdout && copystream != stdin)
-        fclose(copystream);
+	if (copystream != stdout && copystream != stdin)
+		fclose(copystream);
 	free_copy_options(options);
 	return success;
 }
@@ -335,7 +335,7 @@ handleCopyOut(PGconn *conn, FILE *copystream)
 	char		copybuf[COPYBUFSIZ];
 	int			ret;
 
-    assert(cancelConn);
+	assert(cancelConn);
 
 	while (!copydone)
 	{
@@ -365,8 +365,8 @@ handleCopyOut(PGconn *conn, FILE *copystream)
 	}
 	fflush(copystream);
 	ret = !PQendcopy(conn);
-    cancelConn = NULL;
-    return ret;
+	cancelConn = NULL;
+	return ret;
 }
 
 
@@ -394,15 +394,15 @@ handleCopyIn(PGconn *conn, FILE *copystream, const char *prompt)
 	char	   *s;
 	int			bufleft;
 	int			c = 0;
-    int         ret;
+	int			ret;
 
 #ifdef USE_ASSERT_CHECKING
-    assert(copy_in_state);
+	assert(copy_in_state);
 #endif
 
 	if (prompt)					/* disable prompt if not interactive */
 	{
-		if (! isatty(fileno(copystream)))
+		if (!isatty(fileno(copystream)))
 			prompt = NULL;
 	}
 
@@ -419,7 +419,7 @@ handleCopyIn(PGconn *conn, FILE *copystream, const char *prompt)
 		while (!linedone)
 		{						/* for each bufferload in line ... */
 			s = copybuf;
-			for (bufleft = COPYBUFSIZ-1; bufleft > 0; bufleft--)
+			for (bufleft = COPYBUFSIZ - 1; bufleft > 0; bufleft--)
 			{
 				c = getc(copystream);
 				if (c == '\n' || c == EOF)
@@ -434,8 +434,8 @@ handleCopyIn(PGconn *conn, FILE *copystream, const char *prompt)
 			{
 				PQputline(conn, "\\.");
 				copydone = true;
-                if (pset.cur_cmd_interactive)
-                    puts("\\.");
+				if (pset.cur_cmd_interactive)
+					puts("\\.");
 				break;
 			}
 			PQputline(conn, copybuf);
@@ -452,6 +452,6 @@ handleCopyIn(PGconn *conn, FILE *copystream, const char *prompt)
 		PQputline(conn, "\n");
 	}
 	ret = !PQendcopy(conn);
-    copy_in_state = false;
-    return ret;
+	copy_in_state = false;
+	return ret;
 }
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 631a04b336df7abf47e7a22766bfa0b89f8b34ad..75c9df37143e68c14e468ab86382d5fe4275a4a6 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.18 2000/02/26 18:31:25 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.19 2000/04/12 17:16:22 momjian Exp $
  */
 #include "postgres.h"
 #include "describe.h"
@@ -45,10 +45,10 @@ describeAggregates(const char *name)
 	 */
 	strcpy(buf,
 		   "SELECT a.aggname AS \"Name\", t.typname AS \"Type\",\n"
-	   "  obj_description(a.oid) as \"Description\"\n"
-	   "FROM pg_aggregate a, pg_type t\n"
-	   "WHERE a.aggbasetype = t.oid\n"
-	);
+		   "  obj_description(a.oid) as \"Description\"\n"
+		   "FROM pg_aggregate a, pg_type t\n"
+		   "WHERE a.aggbasetype = t.oid\n"
+		);
 
 	if (name)
 	{
@@ -60,10 +60,10 @@ describeAggregates(const char *name)
 	strcat(buf,
 		   "UNION\n"
 		   "SELECT a.aggname AS \"Name\", '(all types)' as \"Type\",\n"
-	   "  obj_description(a.oid) as \"Description\"\n"
+		   "  obj_description(a.oid) as \"Description\"\n"
 		   "FROM pg_aggregate a\n"
-	   "WHERE a.aggbasetype = 0\n"
-	);
+		   "WHERE a.aggbasetype = 0\n"
+		);
 
 	if (name)
 	{
@@ -103,21 +103,21 @@ describeFunctions(const char *name, bool verbose)
 	 * arguments, but have no types defined for those arguments
 	 */
 	strcpy(buf,
-	   "SELECT t.typname as \"Result\", p.proname as \"Function\",\n"
+		   "SELECT t.typname as \"Result\", p.proname as \"Function\",\n"
 		   "       oidvectortypes(p.proargtypes) as \"Arguments\"");
-    if (verbose)
-	strcat(buf, ",\n       u.usename as \"Owner\", l.lanname as \"Language\", p.prosrc as \"Source\",\n"
-	   "       obj_description(p.oid) as \"Description\"");
+	if (verbose)
+		strcat(buf, ",\n       u.usename as \"Owner\", l.lanname as \"Language\", p.prosrc as \"Source\",\n"
+			   "       obj_description(p.oid) as \"Description\"");
 
-    if (!verbose)
-	strcat(buf,
-	       "\nFROM pg_proc p, pg_type t\n"
-	       "WHERE p.prorettype = t.oid and (pronargs = 0 or oidvectortypes(p.proargtypes) != '')\n");
-    else
-	strcat(buf,
-	       "\nFROM pg_proc p, pg_type t, pg_language l, pg_user u\n"
-	       "WHERE p.prorettype = t.oid AND p.prolang = l.oid AND p.proowner = u.usesysid\n"
-	       "  AND (pronargs = 0 or oidvectortypes(p.proargtypes) != '')\n");
+	if (!verbose)
+		strcat(buf,
+			   "\nFROM pg_proc p, pg_type t\n"
+			   "WHERE p.prorettype = t.oid and (pronargs = 0 or oidvectortypes(p.proargtypes) != '')\n");
+	else
+		strcat(buf,
+			   "\nFROM pg_proc p, pg_type t, pg_language l, pg_user u\n"
+			   "WHERE p.prorettype = t.oid AND p.prolang = l.oid AND p.proowner = u.usesysid\n"
+		"  AND (pronargs = 0 or oidvectortypes(p.proargtypes) != '')\n");
 
 	if (name)
 	{
@@ -154,13 +154,14 @@ describeTypes(const char *name, bool verbose)
 	printQueryOpt myopt = pset.popt;
 
 	strcpy(buf, "SELECT t.typname AS \"Type\"");
-    if (verbose)
-	strcat(buf, ",\n  (CASE WHEN t.typlen = -1 THEN 'var'::text ELSE t.typlen::text END) as \"Size\"");
+	if (verbose)
+		strcat(buf, ",\n  (CASE WHEN t.typlen = -1 THEN 'var'::text ELSE t.typlen::text END) as \"Size\"");
 	strcat(buf, ",\n  obj_description(t.oid) as \"Description\"");
-    /*
-     * do not include array types (start with underscore),
-     * do not include user relations (typrelid!=0)
-     */
+
+	/*
+	 * do not include array types (start with underscore), do not include
+	 * user relations (typrelid!=0)
+	 */
 	strcat(buf, "\nFROM pg_type t\nWHERE t.typrelid = 0 AND t.typname !~ '^_.*'\n");
 
 	if (name)
@@ -196,12 +197,12 @@ describeOperators(const char *name)
 	printQueryOpt myopt = pset.popt;
 
 	strcpy(buf,
-	   "SELECT o.oprname AS \"Op\",\n"
+		   "SELECT o.oprname AS \"Op\",\n"
 		   "       t1.typname AS \"Left arg\",\n"
 		   "       t2.typname AS \"Right arg\",\n"
 		   "       t0.typname AS \"Result\",\n"
 		   "       obj_description(p.oid) as \"Description\"\n"
-	   "FROM   pg_proc p, pg_type t0,\n"
+		   "FROM   pg_proc p, pg_type t0,\n"
 		   "       pg_type t1, pg_type t2,\n"
 		   "       pg_operator o\n"
 		   "WHERE  p.prorettype = t0.oid AND\n"
@@ -221,8 +222,8 @@ describeOperators(const char *name)
 		   "       ''::name AS \"Left arg\",\n"
 		   "       t1.typname AS \"Right arg\",\n"
 		   "       t0.typname AS \"Result\",\n"
-	   "       obj_description(p.oid) as \"Description\"\n"
-	   "FROM   pg_operator o, pg_proc p, pg_type t0, pg_type t1\n"
+		   "       obj_description(p.oid) as \"Description\"\n"
+		   "FROM   pg_operator o, pg_proc p, pg_type t0, pg_type t1\n"
 		   "WHERE  RegprocToOid(o.oprcode) = p.oid AND\n"
 		   "       o.oprresult = t0.oid AND\n"
 		   "       o.oprkind = 'l' AND\n"
@@ -239,8 +240,8 @@ describeOperators(const char *name)
 		   "       t1.typname AS \"Left arg\",\n"
 		   "       ''::name AS \"Right arg\",\n"
 		   "       t0.typname AS \"Result\",\n"
-	   "       obj_description(p.oid) as \"Description\"\n"
-	   "FROM   pg_operator o, pg_proc p, pg_type t0, pg_type t1\n"
+		   "       obj_description(p.oid) as \"Description\"\n"
+		   "FROM   pg_operator o, pg_proc p, pg_type t0, pg_type t1\n"
 		   "WHERE  RegprocToOid(o.oprcode) = p.oid AND\n"
 		   "       o.oprresult = t0.oid AND\n"
 		   "       o.oprkind = 'r' AND\n"
@@ -280,7 +281,7 @@ listAllDbs(bool desc)
 	printQueryOpt myopt = pset.popt;
 
 	strcpy(buf,
-	   "SELECT pg_database.datname as \"Database\",\n"
+		   "SELECT pg_database.datname as \"Database\",\n"
 		   "       pg_user.usename as \"Owner\"");
 #ifdef MULTIBYTE
 	strcat(buf,
@@ -291,11 +292,11 @@ listAllDbs(bool desc)
 	strcat(buf, "FROM pg_database, pg_user\n"
 		   "WHERE pg_database.datdba = pg_user.usesysid\n");
 
-    /* Also include databases that have no valid owner. */
-    strcat(buf, "\nUNION\n\n");
+	/* Also include databases that have no valid owner. */
+	strcat(buf, "\nUNION\n\n");
 
 	strcat(buf,
-	   "SELECT pg_database.datname as \"Database\",\n"
+		   "SELECT pg_database.datname as \"Database\",\n"
 		   "       NULL as \"Owner\"");
 #ifdef MULTIBYTE
 	strcat(buf,
@@ -304,9 +305,9 @@ listAllDbs(bool desc)
 	if (desc)
 		strcat(buf, ",\n       obj_description(pg_database.oid) as \"Description\"\n");
 	strcat(buf, "FROM pg_database\n"
-		   "WHERE pg_database.datdba NOT IN (SELECT usesysid FROM pg_user)\n");
+	 "WHERE pg_database.datdba NOT IN (SELECT usesysid FROM pg_user)\n");
 
-    strcat(buf, "ORDER BY \"Database\"");
+	strcat(buf, "ORDER BY \"Database\"");
 
 	res = PSQLexec(buf);
 	if (!res)
@@ -352,11 +353,11 @@ permissionsList(const char *name)
 	if (!res)
 		return false;
 
-    myopt.nullPrint = NULL;
-    sprintf(descbuf, "Access permissions for database \"%s\"", PQdb(pset.db));
-    myopt.title = descbuf;
+	myopt.nullPrint = NULL;
+	sprintf(descbuf, "Access permissions for database \"%s\"", PQdb(pset.db));
+	myopt.title = descbuf;
 
-    printQuery(res, &myopt, pset.queryFout);
+	printQuery(res, &myopt, pset.queryFout);
 
 	PQclear(res);
 	return true;
@@ -408,7 +409,7 @@ objectDescription(const char *object)
 	strcat(descbuf, "\nUNION ALL\n\n");
 	strcat(descbuf, "SELECT DISTINCT o.oprname as \"Name\", 'operator'::text as \"Object\", d.description as \"Description\"\n"
 		   "FROM pg_operator o, pg_description d\n"
-		   /* must get comment via associated function */
+	/* must get comment via associated function */
 		   "WHERE RegprocToOid(o.oprcode) = d.objoid\n");
 	if (object)
 	{
@@ -521,25 +522,34 @@ describeTableDetails(const char *name, bool desc)
 	char	  **footers = NULL;
 	char	  **ptr;
 	unsigned int cols;
-    struct { bool hasindex; char relkind; int16 checks; int16 triggers; bool hasrules; } tableinfo;
-    bool error = false;
+	struct
+	{
+		bool		hasindex;
+		char		relkind;
+		int16		checks;
+		int16		triggers;
+		bool		hasrules;
+	}			tableinfo;
+	bool		error = false;
+
+	/* truncate table name */
+	if (strlen(name) > NAMEDATALEN)
+	{
+		char	   *my_name = xmalloc(NAMEDATALEN + 1);
 
-    /* truncate table name */
-    if (strlen(name) > NAMEDATALEN) {
-        char *my_name = xmalloc(NAMEDATALEN+1);
-        strncpy(my_name, name, NAMEDATALEN);
-        my_name[NAMEDATALEN] = '\0';
-        name = my_name;
-    }
+		strncpy(my_name, name, NAMEDATALEN);
+		my_name[NAMEDATALEN] = '\0';
+		name = my_name;
+	}
 
 	/* Get general table info */
-    sprintf(buf,
-            "SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules\n"
-            "FROM pg_class WHERE relname='%s'",
-            name);
-    res = PSQLexec(buf);
-    if (!res)
-        return false;
+	sprintf(buf,
+	 "SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules\n"
+			"FROM pg_class WHERE relname='%s'",
+			name);
+	res = PSQLexec(buf);
+	if (!res)
+		return false;
 
 	/* Did we get anything? */
 	if (PQntuples(res) == 0)
@@ -550,35 +560,35 @@ describeTableDetails(const char *name, bool desc)
 		return false;
 	}
 
-    /* FIXME: check for null pointers here? */
-    tableinfo.hasindex = strcmp(PQgetvalue(res,0,0),"t")==0;
-    tableinfo.relkind = *(PQgetvalue(res,0,1));
-    tableinfo.checks = atoi(PQgetvalue(res,0,2));
-    tableinfo.triggers = atoi(PQgetvalue(res,0,3));
-    tableinfo.hasrules = strcmp(PQgetvalue(res,0,4),"t")==0;
-    PQclear(res);
+	/* FIXME: check for null pointers here? */
+	tableinfo.hasindex = strcmp(PQgetvalue(res, 0, 0), "t") == 0;
+	tableinfo.relkind = *(PQgetvalue(res, 0, 1));
+	tableinfo.checks = atoi(PQgetvalue(res, 0, 2));
+	tableinfo.triggers = atoi(PQgetvalue(res, 0, 3));
+	tableinfo.hasrules = strcmp(PQgetvalue(res, 0, 4), "t") == 0;
+	PQclear(res);
 
 
 	headers[0] = "Attribute";
 	headers[1] = "Type";
 	cols = 2;
 
-    if (tableinfo.relkind == 'r')
-    {
-        cols++;
-        headers[cols-1] = "Modifier";
-    }
+	if (tableinfo.relkind == 'r')
+	{
+		cols++;
+		headers[cols - 1] = "Modifier";
+	}
 
 	if (desc)
 	{
-        cols++;
-		headers[cols-1] = "Description";
+		cols++;
+		headers[cols - 1] = "Description";
 	}
 
-    headers[cols] = NULL;
+	headers[cols] = NULL;
 
 
-    /* Get column info */
+	/* Get column info */
 	strcpy(buf, "SELECT a.attname, t.typname, a.attlen, a.atttypmod, a.attnotnull, a.atthasdef, a.attnum");
 	if (desc)
 		strcat(buf, ", obj_description(a.oid)");
@@ -593,55 +603,58 @@ describeTableDetails(const char *name, bool desc)
 		return false;
 
 	/* Check if table is a view */
-    if (tableinfo.hasrules) {
-        PGresult *result;
-        sprintf(buf, "SELECT definition FROM pg_views WHERE viewname = '%s'", name);
-        result = PSQLexec(buf);
-        if (!result)
-        {
-            PQclear(res);
-            PQclear(result);
-            return false;
-        }
-
-        if (PQntuples(result) > 0)
-            view_def = xstrdup(PQgetvalue(result, 0, 0));
-        PQclear(result);
-    }
+	if (tableinfo.hasrules)
+	{
+		PGresult   *result;
+
+		sprintf(buf, "SELECT definition FROM pg_views WHERE viewname = '%s'", name);
+		result = PSQLexec(buf);
+		if (!result)
+		{
+			PQclear(res);
+			PQclear(result);
+			return false;
+		}
+
+		if (PQntuples(result) > 0)
+			view_def = xstrdup(PQgetvalue(result, 0, 0));
+		PQclear(result);
+	}
 
 
 	/* Generate table cells to be printed */
 	cells = xmalloc((PQntuples(res) * cols + 1) * sizeof(*cells));
-    cells[PQntuples(res) * cols] = NULL; /* end of list */
+	cells[PQntuples(res) * cols] = NULL;		/* end of list */
 
 	for (i = 0; i < PQntuples(res); i++)
 	{
 		int4		attypmod = atoi(PQgetvalue(res, i, 3));
 		const char *attype = PQgetvalue(res, i, 1);
-        const char *typename;
-        bool        isarray = false;
+		const char *typename;
+		bool		isarray = false;
 
 		/* Name */
-		cells[i * cols + 0] = PQgetvalue(res, i, 0);	/* don't free this afterwards */
+		cells[i * cols + 0] = PQgetvalue(res, i, 0);	/* don't free this
+														 * afterwards */
 
 		/* Type */
-        if (attype[0] == '_')
-        {
-            isarray = true;
-            attype++;
-        }
-        /* (convert some internal type names to SQL'ish) */
-		if (strcmp(attype, "int2")==0)
-            typename = "smallint";
-        else if (strcmp(attype, "int4")==0)
-            typename = "integer";
-        else if (strcmp(attype, "int8")==0)
-            typename = "bigint";
-        else if (strcmp(attype, "bool")==0)
-            typename = "boolean";
-        else
-            typename = attype;
-        /* more might need to be added when date/time types are sorted out */
+		if (attype[0] == '_')
+		{
+			isarray = true;
+			attype++;
+		}
+		/* (convert some internal type names to SQL'ish) */
+		if (strcmp(attype, "int2") == 0)
+			typename = "smallint";
+		else if (strcmp(attype, "int4") == 0)
+			typename = "integer";
+		else if (strcmp(attype, "int8") == 0)
+			typename = "bigint";
+		else if (strcmp(attype, "bool") == 0)
+			typename = "boolean";
+		else
+			typename = attype;
+		/* more might need to be added when date/time types are sorted out */
 
 		cells[i * cols + 1] = xmalloc(NAMEDATALEN + 16);
 		if (strcmp(typename, "bpchar") == 0)
@@ -667,100 +680,101 @@ describeTableDetails(const char *name, bool desc)
 		else
 			strcpy(cells[i * cols + 1], typename);
 
-        if (isarray)
+		if (isarray)
 			strcat(cells[i * cols + 1], "[]");
 
 
 		/* Extra: not null and default */
 		/* (I'm cutting off the 'default' string at 128) */
-        if (tableinfo.relkind == 'r')
-        {
-            cells[i * cols + 2] = xmalloc(128 + 128);
-            cells[i * cols + 2][0] = '\0';
-            if (strcmp(PQgetvalue(res, i, 4), "t") == 0)
-                strcat(cells[i * cols + 2], "not null");
-
-            /* handle "default" here */
-            if (strcmp(PQgetvalue(res, i, 5), "t") == 0)
-            {
-                PGresult *result;
-
-                sprintf(buf, "SELECT substring(d.adsrc for 128) FROM pg_attrdef d, pg_class c\n"
-                        "WHERE c.relname = '%s' AND c.oid = d.adrelid AND d.adnum = %s",
-                        name, PQgetvalue(res, i, 6));
-
-                result = PSQLexec(buf);
-                if (!result)
-                    error = true;
-                else
-                {
-                    if (cells[i * cols + 2][0])
-                        strcat(cells[i * cols + 2], " ");
-                    strcat(cells[i * cols + 2], "default ");
-                    strcat(cells[i * cols + 2], PQgetvalue(result, 0, 0));
-                    PQclear(result);
-                }
-            }
-        }
-
-        if (error)
-            break;
-        
+		if (tableinfo.relkind == 'r')
+		{
+			cells[i * cols + 2] = xmalloc(128 + 128);
+			cells[i * cols + 2][0] = '\0';
+			if (strcmp(PQgetvalue(res, i, 4), "t") == 0)
+				strcat(cells[i * cols + 2], "not null");
+
+			/* handle "default" here */
+			if (strcmp(PQgetvalue(res, i, 5), "t") == 0)
+			{
+				PGresult   *result;
+
+				sprintf(buf, "SELECT substring(d.adsrc for 128) FROM pg_attrdef d, pg_class c\n"
+						"WHERE c.relname = '%s' AND c.oid = d.adrelid AND d.adnum = %s",
+						name, PQgetvalue(res, i, 6));
+
+				result = PSQLexec(buf);
+				if (!result)
+					error = true;
+				else
+				{
+					if (cells[i * cols + 2][0])
+						strcat(cells[i * cols + 2], " ");
+					strcat(cells[i * cols + 2], "default ");
+					strcat(cells[i * cols + 2], PQgetvalue(result, 0, 0));
+					PQclear(result);
+				}
+			}
+		}
+
+		if (error)
+			break;
+
 		/* Description */
 		if (desc)
-			cells[i * cols + cols-1] = PQgetvalue(res, i, 7);
+			cells[i * cols + cols - 1] = PQgetvalue(res, i, 7);
 	}
 
 	/* Make title */
 	title = xmalloc(22 + strlen(name));
-    switch (tableinfo.relkind) {
-        case 'r':
-            if (view_def)
-                sprintf(title, "View \"%s\"", name);
-            else
-                sprintf(title, "Table \"%s\"", name);
-            break;
-        case 'S':
-            sprintf(title, "Sequence \"%s\"", name);
-            break;
-        case 'i':
-            sprintf(title, "Index \"%s\"", name);
-            break;
-        case 's':
-            sprintf(title, "Special relation \"%s\"", name);
-            break;
-        default:
-            sprintf(title, "?%c?", tableinfo.relkind);
-    }
+	switch (tableinfo.relkind)
+	{
+		case 'r':
+			if (view_def)
+				sprintf(title, "View \"%s\"", name);
+			else
+				sprintf(title, "Table \"%s\"", name);
+			break;
+		case 'S':
+			sprintf(title, "Sequence \"%s\"", name);
+			break;
+		case 'i':
+			sprintf(title, "Index \"%s\"", name);
+			break;
+		case 's':
+			sprintf(title, "Special relation \"%s\"", name);
+			break;
+		default:
+			sprintf(title, "?%c?", tableinfo.relkind);
+	}
 
 	/* Make footers */
-    /* Information about the index */
-    if (tableinfo.relkind == 'i')
-    {
-        PGresult * result;
-
-        sprintf(buf, "SELECT i.indisunique, i.indisprimary, a.amname\n"
-                "FROM pg_index i, pg_class c, pg_am a\n"
-                "WHERE i.indexrelid = c.oid AND c.relname = '%s' AND c.relam = a.oid",
-                name);
-
-        result = PSQLexec(buf);
-        if (!result)
-            error = true;
-        else
-        {
-            footers = xmalloc(2 * sizeof(*footers));
-            footers[0] = xmalloc(NAMEDATALEN + 32);
-            sprintf(footers[0], "%s%s",
-                    strcmp(PQgetvalue(result, 0, 0), "t")==0 ? "unique " : "",
-                    PQgetvalue(result, 0, 2)
-                );
-            if (strcmp(PQgetvalue(result, 0, 1), "t")==0)
-                strcat(footers[0], " (primary key)");
-            footers[1] = NULL;
-        }
-    }
-    /* Information about the view */
+	/* Information about the index */
+	if (tableinfo.relkind == 'i')
+	{
+		PGresult   *result;
+
+		sprintf(buf, "SELECT i.indisunique, i.indisprimary, a.amname\n"
+				"FROM pg_index i, pg_class c, pg_am a\n"
+				"WHERE i.indexrelid = c.oid AND c.relname = '%s' AND c.relam = a.oid",
+				name);
+
+		result = PSQLexec(buf);
+		if (!result)
+			error = true;
+		else
+		{
+			footers = xmalloc(2 * sizeof(*footers));
+			footers[0] = xmalloc(NAMEDATALEN + 32);
+			sprintf(footers[0], "%s%s",
+			 strcmp(PQgetvalue(result, 0, 0), "t") == 0 ? "unique " : "",
+					PQgetvalue(result, 0, 2)
+				);
+			if (strcmp(PQgetvalue(result, 0, 1), "t") == 0)
+				strcat(footers[0], " (primary key)");
+			footers[1] = NULL;
+		}
+	}
+	/* Information about the view */
 	else if (tableinfo.relkind == 'r' && view_def)
 	{
 		footers = xmalloc(2 * sizeof(*footers));
@@ -769,137 +783,143 @@ describeTableDetails(const char *name, bool desc)
 		footers[1] = NULL;
 	}
 
-    /* Information about the table */
+	/* Information about the table */
 	else if (tableinfo.relkind == 'r')
 	{
-        PGresult *result1=NULL, *result2=NULL, *result3=NULL, *result4=NULL;
-        int index_count=0, constr_count=0, rule_count=0, trigger_count=0;
-        int count_footers=0;
+		PGresult   *result1 = NULL,
+				   *result2 = NULL,
+				   *result3 = NULL,
+				   *result4 = NULL;
+		int			index_count = 0,
+					constr_count = 0,
+					rule_count = 0,
+					trigger_count = 0;
+		int			count_footers = 0;
 
 		/* count indices */
-        if (!error && tableinfo.hasindex)
-        {
-            sprintf(buf, "SELECT c2.relname\n"
-                    "FROM pg_class c, pg_class c2, pg_index i\n"
-                    "WHERE c.relname = '%s' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\n"
-                    "ORDER BY c2.relname",
-                    name);
-            result1 = PSQLexec(buf);
-            if (!result1)
-                error = true;
-            else
-                index_count = PQntuples(result1);
-        }
-
-        /* count table (and column) constraints */
-        if (!error && tableinfo.checks)
-        {
-            sprintf(buf, "SELECT rcsrc\n"
-                    "FROM pg_relcheck r, pg_class c\n"
-                    "WHERE c.relname='%s' AND c.oid = r.rcrelid",
-                    name);
-            result2 = PSQLexec(buf);
-            if (!result2)
-                error = true;
-            else
-                constr_count = PQntuples(result2);
-        }
-
-        /* count rules */
-        if (!error && tableinfo.hasrules)
-        {
-            sprintf(buf,
-                    "SELECT r.rulename\n"
-                    "FROM pg_rewrite r, pg_class c\n"
-                    "WHERE c.relname='%s' AND c.oid = r.ev_class",
-                    name);
-            result3 = PSQLexec(buf);
-            if (!result3)
-                error = true;
-            else
-                rule_count = PQntuples(result3);
-        }
-
-        /* count triggers */
-        if (!error && tableinfo.hasrules)
-        {
-            sprintf(buf,
-                    "SELECT t.tgname\n"
-                    "FROM pg_trigger t, pg_class c\n"
-                    "WHERE c.relname='%s' AND c.oid = t.tgrelid",
-                    name);
-            result4 = PSQLexec(buf);
-            if (!result4)
-                error = true;
-            else
-                trigger_count = PQntuples(result4);
-        }
-
-        footers = xmalloc((index_count + constr_count + rule_count + trigger_count + 1)
-                          * sizeof(*footers));
-
-        /* print indices */
-        for (i = 0; i < index_count; i++)
-        {
-            sprintf(buf, "%s %s",
-                    index_count==1 ? "Index:" : (i==0 ? "Indices:" : "        "),
-                    PQgetvalue(result1, i, 0)
-                );
-            if (i < index_count-1)
-                strcat(buf, ",");
-
-            footers[count_footers++] = xstrdup(buf);
-        }
-
-        /* print contraints */
-        for (i = 0; i < constr_count; i++)
-        {
-            sprintf(buf, "%s %s",
-                    constr_count==1 ? "Constraint:" : (i==0 ? "Constraints:" : "            "),
-                    PQgetvalue(result2, i, 0)
-                );
-            footers[count_footers++] = xstrdup(buf);
-        }
-
-        /* print rules */
-        for (i = 0; i < rule_count; i++)
-        {
-            sprintf(buf, "%s %s",
-                    rule_count==1 ? "Rule:" : (i==0 ? "Rules:" : "      "),
-                    PQgetvalue(result3, i, 0)
-                );
-            if (i < rule_count-1)
-                strcat(buf, ",");
-
-            footers[count_footers++] = xstrdup(buf);
-        }
-
-        /* print triggers */
-        for (i = 0; i < trigger_count; i++)
-        {
-            sprintf(buf, "%s %s",
-                    trigger_count==1 ? "Trigger:" : (i==0 ? "Triggers:" : "         "),
-                    PQgetvalue(result4, i, 0)
-                );
-            if (i < trigger_count-1)
-                strcat(buf, ",");
-
-            footers[count_footers++] = xstrdup(buf);
-        }
-
-        /* end of list marker */
-        footers[count_footers] = NULL;
-
-        PQclear(result1);
-        PQclear(result2);
-        PQclear(result3);
-        PQclear(result4);
+		if (!error && tableinfo.hasindex)
+		{
+			sprintf(buf, "SELECT c2.relname\n"
+					"FROM pg_class c, pg_class c2, pg_index i\n"
+					"WHERE c.relname = '%s' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\n"
+					"ORDER BY c2.relname",
+					name);
+			result1 = PSQLexec(buf);
+			if (!result1)
+				error = true;
+			else
+				index_count = PQntuples(result1);
+		}
+
+		/* count table (and column) constraints */
+		if (!error && tableinfo.checks)
+		{
+			sprintf(buf, "SELECT rcsrc\n"
+					"FROM pg_relcheck r, pg_class c\n"
+					"WHERE c.relname='%s' AND c.oid = r.rcrelid",
+					name);
+			result2 = PSQLexec(buf);
+			if (!result2)
+				error = true;
+			else
+				constr_count = PQntuples(result2);
+		}
+
+		/* count rules */
+		if (!error && tableinfo.hasrules)
+		{
+			sprintf(buf,
+					"SELECT r.rulename\n"
+					"FROM pg_rewrite r, pg_class c\n"
+					"WHERE c.relname='%s' AND c.oid = r.ev_class",
+					name);
+			result3 = PSQLexec(buf);
+			if (!result3)
+				error = true;
+			else
+				rule_count = PQntuples(result3);
+		}
+
+		/* count triggers */
+		if (!error && tableinfo.hasrules)
+		{
+			sprintf(buf,
+					"SELECT t.tgname\n"
+					"FROM pg_trigger t, pg_class c\n"
+					"WHERE c.relname='%s' AND c.oid = t.tgrelid",
+					name);
+			result4 = PSQLexec(buf);
+			if (!result4)
+				error = true;
+			else
+				trigger_count = PQntuples(result4);
+		}
+
+		footers = xmalloc((index_count + constr_count + rule_count + trigger_count + 1)
+						  * sizeof(*footers));
+
+		/* print indices */
+		for (i = 0; i < index_count; i++)
+		{
+			sprintf(buf, "%s %s",
+					index_count == 1 ? "Index:" : (i == 0 ? "Indices:" : "        "),
+					PQgetvalue(result1, i, 0)
+				);
+			if (i < index_count - 1)
+				strcat(buf, ",");
+
+			footers[count_footers++] = xstrdup(buf);
+		}
+
+		/* print contraints */
+		for (i = 0; i < constr_count; i++)
+		{
+			sprintf(buf, "%s %s",
+					constr_count == 1 ? "Constraint:" : (i == 0 ? "Constraints:" : "            "),
+					PQgetvalue(result2, i, 0)
+				);
+			footers[count_footers++] = xstrdup(buf);
+		}
+
+		/* print rules */
+		for (i = 0; i < rule_count; i++)
+		{
+			sprintf(buf, "%s %s",
+			  rule_count == 1 ? "Rule:" : (i == 0 ? "Rules:" : "      "),
+					PQgetvalue(result3, i, 0)
+				);
+			if (i < rule_count - 1)
+				strcat(buf, ",");
+
+			footers[count_footers++] = xstrdup(buf);
+		}
+
+		/* print triggers */
+		for (i = 0; i < trigger_count; i++)
+		{
+			sprintf(buf, "%s %s",
+					trigger_count == 1 ? "Trigger:" : (i == 0 ? "Triggers:" : "         "),
+					PQgetvalue(result4, i, 0)
+				);
+			if (i < trigger_count - 1)
+				strcat(buf, ",");
+
+			footers[count_footers++] = xstrdup(buf);
+		}
+
+		/* end of list marker */
+		footers[count_footers] = NULL;
+
+		PQclear(result1);
+		PQclear(result2);
+		PQclear(result3);
+		PQclear(result4);
 	}
 
-    if (!error)
-        printTable(title, headers,
-                   (const char**)cells, (const char**)footers,
-                   "llll", &myopt, pset.queryFout);
+	if (!error)
+		printTable(title, headers,
+				   (const char **) cells, (const char **) footers,
+				   "llll", &myopt, pset.queryFout);
 
 	/* clean up */
 	free(title);
@@ -907,8 +927,8 @@ describeTableDetails(const char *name, bool desc)
 	for (i = 0; i < PQntuples(res); i++)
 	{
 		free(cells[i * cols + 1]);
-        if (tableinfo.relkind == 'r')
-            free(cells[i * cols + 2]);
+		if (tableinfo.relkind == 'r')
+			free(cells[i * cols + 2]);
 	}
 	free(cells);
 
@@ -972,14 +992,14 @@ listTables(const char *infotype, const char *name, bool desc)
 			strcat(buf, "'\n");
 		}
 
-	strcat(buf, "UNION\n");
+		strcat(buf, "UNION\n");
 		strcat(buf, "SELECT c.relname as \"Name\", 'table'::text as \"Type\", NULL as \"Owner\"");
 		if (desc)
 			strcat(buf, ", obj_description(c.oid) as \"Description\"");
 		strcat(buf, "\nFROM pg_class c\n"
 			   "WHERE c.relkind = 'r'\n"
 			   "  AND not exists (select 1 from pg_views where viewname = c.relname)\n"
-	       "  AND not exists (select 1 from pg_user where usesysid = c.relowner)\n");
+			   "  AND not exists (select 1 from pg_user where usesysid = c.relowner)\n");
 		strcat(buf, showSystem ? "  AND c.relname ~ '^pg_'\n" : "  AND c.relname !~ '^pg_'\n");
 		if (name)
 		{
@@ -1009,14 +1029,14 @@ listTables(const char *infotype, const char *name, bool desc)
 			strcat(buf, "'\n");
 		}
 
-	strcat(buf, "UNION\n");
+		strcat(buf, "UNION\n");
 		strcat(buf, "SELECT c.relname as \"Name\", 'view'::text as \"Type\", NULL as \"Owner\"");
 		if (desc)
 			strcat(buf, ", obj_description(c.oid) as \"Description\"");
 		strcat(buf, "\nFROM pg_class c\n"
 			   "WHERE c.relkind = 'r'\n"
 			   "  AND exists (select 1 from pg_views where viewname = c.relname)\n"
-	       "  AND not exists (select 1 from pg_user where usesysid = c.relowner)\n");
+			   "  AND not exists (select 1 from pg_user where usesysid = c.relowner)\n");
 		strcat(buf, showSystem ? "  AND c.relname ~ '^pg_'\n" : "  AND c.relname !~ '^pg_'\n");
 		if (name)
 		{
@@ -1033,10 +1053,10 @@ listTables(const char *infotype, const char *name, bool desc)
 			strcat(buf, "\nUNION\n\n");
 
 		strcat(buf,
-	       "SELECT c.relname as \"Name\",\n"
+			   "SELECT c.relname as \"Name\",\n"
 			   "  (CASE WHEN relkind = 'S' THEN 'sequence'::text ELSE 'index'::text END) as \"Type\",\n"
-	       "  u.usename as \"Owner\""
-	    );
+			   "  u.usename as \"Owner\""
+			);
 		if (desc)
 			strcat(buf, ", obj_description(c.oid) as \"Description\"");
 		strcat(buf, "\nFROM pg_class c, pg_user u\n"
@@ -1061,12 +1081,12 @@ listTables(const char *infotype, const char *name, bool desc)
 			strcat(buf, "'\n");
 		}
 
-	strcat(buf, "UNION\n");
+		strcat(buf, "UNION\n");
 		strcat(buf,
-	       "SELECT c.relname as \"Name\",\n"
+			   "SELECT c.relname as \"Name\",\n"
 			   "  (CASE WHEN relkind = 'S' THEN 'sequence'::text ELSE 'index'::text END) as \"Type\",\n"
-	       "  NULL as \"Owner\""
-	    );
+			   "  NULL as \"Owner\""
+			);
 		if (desc)
 			strcat(buf, ", obj_description(c.oid) as \"Description\"");
 		strcat(buf, "\nFROM pg_class c\n"
@@ -1110,13 +1130,13 @@ listTables(const char *infotype, const char *name, bool desc)
 			strcat(buf, "'\n");
 		}
 
-	strcat(buf, "UNION\n");
+		strcat(buf, "UNION\n");
 		strcat(buf, "SELECT c.relname as \"Name\", 'special'::text as \"Type\", NULL as \"Owner\"");
 		if (desc)
 			strcat(buf, ", obj_description(c.oid) as \"Description\"");
 		strcat(buf, "\nFROM pg_class c\n"
 			   "WHERE c.relkind = 's'\n"
-	       "  AND not exists (select 1 from pg_user where usesysid = c.relowner)");
+			   "  AND not exists (select 1 from pg_user where usesysid = c.relowner)");
 		if (name)
 		{
 			strcat(buf, "  AND c.relname ~ '^");
@@ -1133,12 +1153,12 @@ listTables(const char *infotype, const char *name, bool desc)
 		return false;
 
 	if (PQntuples(res) == 0 && !QUIET())
-    {
-        if (name)
-            fprintf(pset.queryFout, "No matching relations found.\n");
-        else
-            fprintf(pset.queryFout, "No relations found.\n");
-    }
+	{
+		if (name)
+			fprintf(pset.queryFout, "No matching relations found.\n");
+		else
+			fprintf(pset.queryFout, "No relations found.\n");
+	}
 	else
 	{
 		myopt.nullPrint = NULL;
diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h
index 673f3fe48656a02ebf2bdf143b1e7c3fffc06cee..7383ea6fa664e0ec7139609d8899a54cb106a381 100644
--- a/src/bin/psql/describe.h
+++ b/src/bin/psql/describe.h
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/describe.h,v 1.8 2000/02/16 13:15:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/describe.h,v 1.9 2000/04/12 17:16:22 momjian Exp $
  */
 #ifndef DESCRIBE_H
 #define DESCRIBE_H
@@ -11,30 +11,30 @@
 #include "settings.h"
 
 /* \da */
-bool describeAggregates(const char *name);
+bool		describeAggregates(const char *name);
 
 /* \df */
-bool describeFunctions(const char *name, bool verbose);
+bool		describeFunctions(const char *name, bool verbose);
 
 /* \dT */
-bool describeTypes(const char *name, bool verbose);
+bool		describeTypes(const char *name, bool verbose);
 
 /* \do */
-bool describeOperators(const char *name);
+bool		describeOperators(const char *name);
 
 /* \z (or \dp) */
-bool permissionsList(const char *name);
+bool		permissionsList(const char *name);
 
 /* \dd */
-bool objectDescription(const char *object);
+bool		objectDescription(const char *object);
 
 /* \d foo */
-bool describeTableDetails(const char *name, bool desc);
+bool		describeTableDetails(const char *name, bool desc);
 
 /* \l */
-bool listAllDbs(bool desc);
+bool		listAllDbs(bool desc);
 
 /* \dt, \di, \ds, \dS, etc. */
-bool listTables(const char *infotype, const char *name, bool desc);
+bool		listTables(const char *infotype, const char *name, bool desc);
 
 #endif	 /* DESCRIBE_H */
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index a1bff8a31b15dbf685e1f896457fde97295df2ec..8c960723fc0d4c48f67258742a611d9281d95c27 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.24 2000/03/05 13:30:19 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.25 2000/04/12 17:16:22 momjian Exp $
  */
 #include "postgres.h"
 #include "help.h"
@@ -52,6 +52,7 @@ usage(void)
 
 #ifndef WIN32
 	struct passwd *pw = NULL;
+
 #endif
 
 	/* Find default user, in case we need it. */
@@ -73,13 +74,13 @@ usage(void)
 	}
 
 /* If this " is the start of the string then it ought to end there to fit in 80 columns >> " */
-    puts(  "This is psql, the PostgreSQL interactive terminal.\n");
-	puts(  "Usage:");
-    puts(  "  psql [options] [dbname [username]]\n");
-    puts(  "Options:");
-	puts(  "  -a              Echo all input from script");
-	puts(  "  -A              Unaligned table output mode (-P format=unaligned)");
-	puts(  "  -c <query>      Run only single query (or slash command) and exit");
+	puts("This is psql, the PostgreSQL interactive terminal.\n");
+	puts("Usage:");
+	puts("  psql [options] [dbname [username]]\n");
+	puts("Options:");
+	puts("  -a              Echo all input from script");
+	puts("  -A              Unaligned table output mode (-P format=unaligned)");
+	puts("  -c <query>      Run only single query (or slash command) and exit");
 
 	/* Display default database */
 	env = getenv("PGDATABASE");
@@ -87,10 +88,10 @@ usage(void)
 		env = user;
 	printf("  -d <dbname>     Specify database name to connect to (default: %s)\n", env);
 
-    puts(  "  -e              Echo queries sent to backend");
-	puts(  "  -E              Display queries that internal commands generate");
-	puts(  "  -f <filename>   Execute queries from file, then exit");
-	puts(  "  -F <string>     Set field separator (default: \"" DEFAULT_FIELD_SEP "\") (-P fieldsep=)");
+	puts("  -e              Echo queries sent to backend");
+	puts("  -E              Display queries that internal commands generate");
+	puts("  -f <filename>   Execute queries from file, then exit");
+	puts("  -F <string>     Set field separator (default: \"" DEFAULT_FIELD_SEP "\") (-P fieldsep=)");
 
 	/* Display default host */
 	env = getenv("PGHOST");
@@ -101,22 +102,22 @@ usage(void)
 		fputs("domain socket", stdout);
 	puts(")");
 
-	puts(  "  -H              HTML table output mode (-P format=html)");
-	puts(  "  -l              List available databases, then exit");
-	puts(  "  -o <filename>   Send query output to filename (or |pipe)");
+	puts("  -H              HTML table output mode (-P format=html)");
+	puts("  -l              List available databases, then exit");
+	puts("  -o <filename>   Send query output to filename (or |pipe)");
 
 	/* Display default port */
 	env = getenv("PGPORT");
 	printf("  -p <port>       Specify database server port (default: %s)\n",
-	   env ? env : "hardwired");
+		   env ? env : "hardwired");
 
-	puts(  "  -P var[=arg]    Set printing option 'var' to 'arg' (see \\pset command)");
-	puts(  "  -q              Run quietly (no messages, only query output)");
-    puts(  "  -R <string>     Set record separator (default: newline) (-P recordsep=)");
-	puts(  "  -s              Single step mode (confirm each query)");
-	puts(  "  -S              Single line mode (newline terminates query)");
-	puts(  "  -t              Don't print headings and row count (-P tuples_only)");
-	puts(  "  -T text         Set HTML table tag options (width, border) (-P tableattr=)");
+	puts("  -P var[=arg]    Set printing option 'var' to 'arg' (see \\pset command)");
+	puts("  -q              Run quietly (no messages, only query output)");
+	puts("  -R <string>     Set record separator (default: newline) (-P recordsep=)");
+	puts("  -s              Single step mode (confirm each query)");
+	puts("  -S              Single line mode (newline terminates query)");
+	puts("  -t              Don't print headings and row count (-P tuples_only)");
+	puts("  -T text         Set HTML table tag options (width, border) (-P tableattr=)");
 
 	/* Display default user */
 	env = getenv("PGUSER");
@@ -124,17 +125,17 @@ usage(void)
 		env = user;
 	printf("  -U <username>   Specify database username (default: %s)\n", env);
 
-	puts(  "  -v name=val     Set psql variable 'name' to 'value'");
-	puts(  "  -V              Show version information and exit");
-	puts(  "  -W              Prompt for password (should happen automatically)");
-	puts(  "  -x              Turn on expanded table output (-P expanded)");
-	puts(  "  -X              Do not read startup file (~/.psqlrc)");
+	puts("  -v name=val     Set psql variable 'name' to 'value'");
+	puts("  -V              Show version information and exit");
+	puts("  -W              Prompt for password (should happen automatically)");
+	puts("  -x              Turn on expanded table output (-P expanded)");
+	puts("  -X              Do not read startup file (~/.psqlrc)");
 
-    puts(  "\nFor more information, type \"\\?\" (for internal commands) or \"\\help\"");
-    puts(  "(for SQL commands) from within psql, or consult the psql section in");
-    puts(  "the PostgreSQL manual, which accompanies the distribution and is also");
-    puts(  "available at <http://www.postgresql.org>.");
-    puts(  "Report bugs to <pgsql-bugs@postgresql.org>.");
+	puts("\nFor more information, type \"\\?\" (for internal commands) or \"\\help\"");
+	puts("(for SQL commands) from within psql, or consult the psql section in");
+	puts("the PostgreSQL manual, which accompanies the distribution and is also");
+	puts("available at <http://www.postgresql.org>.");
+	puts("Report bugs to <pgsql-bugs@postgresql.org>.");
 
 #ifndef WIN32
 	if (pw)
@@ -195,9 +196,9 @@ slashUsage(void)
 		fout = stdout;
 
 	/* if you add/remove a line here, change the row test above */
-    fprintf(fout, " \\a             toggle between unaligned and aligned mode\n");
+	fprintf(fout, " \\a             toggle between unaligned and aligned mode\n");
 	fprintf(fout, " \\c[onnect] [dbname|- [user]]\n"
-		  "                 connect to new database (currently '%s')\n", PQdb(pset.db));
+			"                 connect to new database (currently '%s')\n", PQdb(pset.db));
 	fprintf(fout, " \\copy ...      perform SQL COPY with data stream to the client machine\n");
 	fprintf(fout, " \\copyright     show PostgreSQL usage and distribution terms\n");
 	fprintf(fout, " \\d <table>     describe table (or view, index, sequence)\n");
@@ -210,19 +211,19 @@ slashUsage(void)
 	fprintf(fout, " \\e [fname]     edit the current query buffer or <fname> with external editor\n");
 	fprintf(fout, " \\echo <text>   write text to stdout\n");
 	fprintf(fout, " \\encoding <encoding>  set client encoding\n");
-    fprintf(fout, " \\f <sep>       change field separator\n");
+	fprintf(fout, " \\f <sep>       change field separator\n");
 	fprintf(fout, " \\g [fname]     send query to backend (and results in <fname> or |pipe)\n");
 	fprintf(fout, " \\h [cmd]       help on syntax of sql commands, * for all commands\n");
-    fprintf(fout, " \\H             toggle HTML mode (currently %s)\n",
-            ON(pset.popt.topt.format==PRINT_HTML));
+	fprintf(fout, " \\H             toggle HTML mode (currently %s)\n",
+			ON(pset.popt.topt.format == PRINT_HTML));
 	fprintf(fout, " \\i <fname>     read and execute queries from filename\n");
 	fprintf(fout, " \\l             list all databases\n");
 	fprintf(fout, " \\lo_export, \\lo_import, \\lo_list, \\lo_unlink\n"
-            "                  large object operations\n");
+			"                  large object operations\n");
 	fprintf(fout, " \\o [fname]     send all query results to <fname>, or |pipe\n");
 	fprintf(fout, " \\p             show the content of the current query buffer\n");
 	fprintf(fout, " \\pset {format|border|expanded|fieldsep|recordsep|tuples_only|title|tableattr\n"
-            "     |pager}    set table output options\n");
+			"     |pager}    set table output options\n");
 	fprintf(fout, " \\q             quit psql\n");
 	fprintf(fout, " \\qecho <text>  write text to query output stream (see \\o)\n");
 	fprintf(fout, " \\r             reset (clear) the query buffer\n");
@@ -258,19 +259,19 @@ helpSQL(const char *topic)
 	if (!topic || strlen(topic) == 0)
 	{
 		int			i;
-        int         items_per_column = (QL_HELP_COUNT + 2)/3;
+		int			items_per_column = (QL_HELP_COUNT + 2) / 3;
 
 		puts("Available help:");
 
-        for (i = 0; i < items_per_column; i++)
+		for (i = 0; i < items_per_column; i++)
 		{
-            printf("    %-25s%-25s%-25s\n",
-                   VALUE_OR_NULL(QL_HELP[i].cmd),
-                   VALUE_OR_NULL(QL_HELP[i + items_per_column].cmd),
-                   VALUE_OR_NULL(QL_HELP[i + 2*items_per_column].cmd)
-                   );
+			printf("    %-25s%-25s%-25s\n",
+				   VALUE_OR_NULL(QL_HELP[i].cmd),
+				   VALUE_OR_NULL(QL_HELP[i + items_per_column].cmd),
+				   VALUE_OR_NULL(QL_HELP[i + 2 * items_per_column].cmd)
+				);
 		}
-        putc('\n', stdout);
+		putc('\n', stdout);
 	}
 
 	else
@@ -285,9 +286,9 @@ helpSQL(const char *topic)
 			{
 				help_found = true;
 				printf("Command:     %s\n"
-                       "Description: %s\n"
-                       "Syntax:\n%s\n\n",
-                       QL_HELP[i].cmd, QL_HELP[i].help, QL_HELP[i].syntax);
+					   "Description: %s\n"
+					   "Syntax:\n%s\n\n",
+					 QL_HELP[i].cmd, QL_HELP[i].help, QL_HELP[i].syntax);
 			}
 		}
 
@@ -302,24 +303,24 @@ void
 print_copyright(void)
 {
 	puts(
-        "PostgreSQL Data Base Management System\n\n"
-        "Portions Copyright (c) 1996-2000, PostgreSQL, Inc\n\n"
-        "This software is based on Postgres95, formerly known as Postgres, which\n"
-        "contains the following notice:\n\n"
-        "Portions Copyright(c) 1994 - 7 Regents of the University of California\n\n"
-        "Permission to use, copy, modify, and distribute this software and its\n"
-        "documentation for any purpose, without fee, and without a written agreement\n"
-        "is hereby granted, provided that the above copyright notice and this paragraph\n"
-        "and the following two paragraphs appear in all copies.\n\n"
-        "IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR\n"
-        "DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST\n"
-        "PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF\n"
-        "THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\n"
-        "DAMAGE.\n\n"
-        "THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\n"
-        "BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A\n"
-        "PARTICULAR PURPOSE.THE SOFTWARE PROVIDED HEREUNDER IS ON AN \"AS IS\" BASIS,\n"
-        "AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE,\n"
-        "SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
-        );
+		 "PostgreSQL Data Base Management System\n\n"
+		 "Portions Copyright (c) 1996-2000, PostgreSQL, Inc\n\n"
+		 "This software is based on Postgres95, formerly known as Postgres, which\n"
+		 "contains the following notice:\n\n"
+		 "Portions Copyright(c) 1994 - 7 Regents of the University of California\n\n"
+		 "Permission to use, copy, modify, and distribute this software and its\n"
+		 "documentation for any purpose, without fee, and without a written agreement\n"
+		 "is hereby granted, provided that the above copyright notice and this paragraph\n"
+		 "and the following two paragraphs appear in all copies.\n\n"
+		 "IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR\n"
+		 "DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST\n"
+		 "PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF\n"
+		 "THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\n"
+		 "DAMAGE.\n\n"
+		 "THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\n"
+		 "BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A\n"
+		 "PARTICULAR PURPOSE.THE SOFTWARE PROVIDED HEREUNDER IS ON AN \"AS IS\" BASIS,\n"
+		 "AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE,\n"
+		 "SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+	);
 }
diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c
index 6d7143467c09fc81feed95275554d1df6a56fb8d..86200ad0522d9e0b3ff28af9ef5646f18a4bb2d4 100644
--- a/src/bin/psql/input.c
+++ b/src/bin/psql/input.c
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/input.c,v 1.12 2000/02/20 14:28:20 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/input.c,v 1.13 2000/04/12 17:16:22 momjian Exp $
  */
 #include "postgres.h"
 #include "input.h"
@@ -37,9 +37,11 @@ char *
 gets_interactive(char *prompt)
 {
 	char	   *s;
+
 #ifdef USE_HISTORY
-    const char *var;
-    static char * prev_hist = NULL;
+	const char *var;
+	static char *prev_hist = NULL;
+
 #endif
 
 #ifdef USE_READLINE
@@ -56,19 +58,19 @@ gets_interactive(char *prompt)
 #endif
 
 #ifdef USE_HISTORY
-    if (useHistory && s && s[0] != '\0')
-    {
-        var = GetVariable(pset.vars, "HISTCONTROL");
-        if (!var || (var
-            && !((strcmp(var, "ignorespace") == 0 || strcmp(var, "ignoreboth") ==0) && s[0] == ' ' )
-            && !((strcmp(var, "ignoredups") == 0 || strcmp(var, "ignoreboth") ==0) && prev_hist && strcmp(s, prev_hist) == 0)
-            ))
-        {
-            free(prev_hist);
-            prev_hist = strdup(s);
-            add_history(s);
-        }
-    }
+	if (useHistory && s && s[0] != '\0')
+	{
+		var = GetVariable(pset.vars, "HISTCONTROL");
+		if (!var || (var
+					 && !((strcmp(var, "ignorespace") == 0 || strcmp(var, "ignoreboth") == 0) && s[0] == ' ')
+					 && !((strcmp(var, "ignoredups") == 0 || strcmp(var, "ignoreboth") == 0) && prev_hist && strcmp(s, prev_hist) == 0)
+					 ))
+		{
+			free(prev_hist);
+			prev_hist = strdup(s);
+			add_history(s);
+		}
+	}
 #endif
 
 	return s;
@@ -122,7 +124,7 @@ initializeInput(int flags)
 	if (flags == 1)
 	{
 		useReadline = true;
-        initialize_readline();
+		initialize_readline();
 	}
 #endif
 
@@ -132,7 +134,7 @@ initializeInput(int flags)
 		const char *home;
 
 		useHistory = true;
-        SetVariable(pset.vars, "HISTSIZE", "500");
+		SetVariable(pset.vars, "HISTSIZE", "500");
 		using_history();
 		home = getenv("HOME");
 		if (home)
@@ -149,7 +151,7 @@ initializeInput(int flags)
 	}
 #endif
 
-    atexit(finishInput);
+	atexit(finishInput);
 }
 
 
@@ -191,9 +193,10 @@ finishInput(void)
 			psql_history = (char *) malloc(strlen(home) + 20);
 			if (psql_history)
 			{
-                const char * var = GetVariable(pset.vars, "HISTSIZE");
-                if (var)
-                    stifle_history(atoi(var));
+				const char *var = GetVariable(pset.vars, "HISTSIZE");
+
+				if (var)
+					stifle_history(atoi(var));
 				sprintf(psql_history, "%s/.psql_history", home);
 				write_history(psql_history);
 				free(psql_history);
diff --git a/src/bin/psql/input.h b/src/bin/psql/input.h
index c141d1658cd09c80e542d1230a60259a1a73b125..557179113b91cc430310e281a3db76203207691b 100644
--- a/src/bin/psql/input.h
+++ b/src/bin/psql/input.h
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/input.h,v 1.9 2000/03/08 01:58:22 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/input.h,v 1.10 2000/04/12 17:16:22 momjian Exp $
  */
 #ifndef INPUT_H
 #define INPUT_H
@@ -15,30 +15,30 @@
  * USE_READLINE and USE_HISTORY are the definite pointers regarding existence or not.
  */
 #ifdef HAVE_LIBREADLINE
-# if defined(HAVE_READLINE_READLINE_H)
-#  include <readline/readline.h>
-#  define USE_READLINE 1
-# elif defined(HAVE_READLINE_H)
-#  include <readline.h>
-#  define USE_READLINE 1
-# endif
+#if defined(HAVE_READLINE_READLINE_H)
+#include <readline/readline.h>
+#define USE_READLINE 1
+#elif defined(HAVE_READLINE_H)
+#include <readline.h>
+#define USE_READLINE 1
+#endif
 #endif
 
 #if defined(HAVE_LIBHISTORY) || (defined(HAVE_LIBREADLINE) && defined(HAVE_HISTORY_IN_READLINE))
-# if defined(HAVE_READLINE_HISTORY_H)
-#  include <readline/history.h>
-#  define USE_HISTORY 1
-# elif defined(HAVE_HISTORY_H)
-#  include <history.h>
-#  define USE_HISTORY 1
-# endif
+#if defined(HAVE_READLINE_HISTORY_H)
+#include <readline/history.h>
+#define USE_HISTORY 1
+#elif defined(HAVE_HISTORY_H)
+#include <history.h>
+#define USE_HISTORY 1
+#endif
 #endif
 
-char * gets_interactive(char *prompt);
-char * gets_fromFile(FILE *source);
+char	   *gets_interactive(char *prompt);
+char	   *gets_fromFile(FILE *source);
 
-void initializeInput(int flags);
-bool saveHistory(char *fname);
-void finishInput(void);
+void		initializeInput(int flags);
+bool		saveHistory(char *fname);
+void		finishInput(void);
 
-#endif /* INPUT_H */
+#endif	 /* INPUT_H */
diff --git a/src/bin/psql/large_obj.c b/src/bin/psql/large_obj.c
index c5b4a63477973407a2f684591652b8626ac7b82f..020b0173eb4017c1427b0dcb9434373510cbd77b 100644
--- a/src/bin/psql/large_obj.c
+++ b/src/bin/psql/large_obj.c
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.c,v 1.9 2000/02/16 13:15:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.c,v 1.10 2000/04/12 17:16:22 momjian Exp $
  */
 #include "postgres.h"
 #include "large_obj.h"
@@ -92,8 +92,8 @@ do_lo_export(const char *loid_arg, const char *filename_arg)
 
 	if (!pset.db)
 	{
-        if (!pset.cur_cmd_interactive)
-            fprintf(stderr, "%s: ", pset.progname);
+		if (!pset.cur_cmd_interactive)
+			fprintf(stderr, "%s: ", pset.progname);
 		fputs("\\lo_export: not connected to a database\n", stderr);
 		return false;
 	}
@@ -161,8 +161,8 @@ do_lo_import(const char *filename_arg, const char *comment_arg)
 
 	if (!pset.db)
 	{
-        if (!pset.cur_cmd_interactive)
-            fprintf(stderr, "%s: ", pset.progname);
+		if (!pset.cur_cmd_interactive)
+			fprintf(stderr, "%s: ", pset.progname);
 		fputs("\\lo_import: not connected to a database\n", stderr);
 		return false;
 	}
@@ -226,8 +226,8 @@ do_lo_import(const char *filename_arg, const char *comment_arg)
 
 
 	fprintf(pset.queryFout, "lo_import %d\n", loid);
-    sprintf(buf, "%u", (unsigned int)loid);
-    SetVariable(pset.vars, "LASTOID", buf);
+	sprintf(buf, "%u", (unsigned int) loid);
+	SetVariable(pset.vars, "LASTOID", buf);
 
 	return true;
 }
@@ -254,8 +254,8 @@ do_lo_unlink(const char *loid_arg)
 
 	if (!pset.db)
 	{
-        if (!pset.cur_cmd_interactive)
-            fprintf(stderr, "%s: ", pset.progname);
+		if (!pset.cur_cmd_interactive)
+			fprintf(stderr, "%s: ", pset.progname);
 		fputs("\\lo_unlink: not connected to a database\n", stderr);
 		return false;
 	}
@@ -328,14 +328,14 @@ do_lo_list(void)
 	printQueryOpt myopt = pset.popt;
 
 	strcpy(buf,
-           "SELECT usename as \"Owner\", substring(relname from 5) as \"ID\",\n"
-           "  obj_description(pg_class.oid) as \"Description\"\n"
-           "FROM pg_class, pg_user\n"
+	"SELECT usename as \"Owner\", substring(relname from 5) as \"ID\",\n"
+		   "  obj_description(pg_class.oid) as \"Description\"\n"
+		   "FROM pg_class, pg_user\n"
 		   "WHERE usesysid = relowner AND relkind = 'l'\n"
-           "UNION\n"
-           "SELECT NULL as \"Owner\", substring(relname from 5) as \"ID\",\n"
-           "  obj_description(pg_class.oid) as \"Description\"\n"
-           "FROM pg_class\n"
+		   "UNION\n"
+	   "SELECT NULL as \"Owner\", substring(relname from 5) as \"ID\",\n"
+		   "  obj_description(pg_class.oid) as \"Description\"\n"
+		   "FROM pg_class\n"
 		   "WHERE not exists (select 1 from pg_user where usesysid = relowner) AND relkind = 'l'\n"
 		   "ORDER BY \"ID\"");
 
diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c
index b27d344a78160c1d2ac781ca85259d2ab56340c4..a6f9d90c842e2d248978e37c705fa4f9982b9b01 100644
--- a/src/bin/psql/mainloop.c
+++ b/src/bin/psql/mainloop.c
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.27 2000/03/27 21:11:37 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.28 2000/04/12 17:16:22 momjian Exp $
  */
 #include "postgres.h"
 #include "mainloop.h"
@@ -19,7 +19,8 @@
 #ifndef WIN32
 #include <setjmp.h>
 
-sigjmp_buf main_loop_jmp;
+sigjmp_buf	main_loop_jmp;
+
 #endif
 
 
@@ -36,8 +37,8 @@ int
 MainLoop(FILE *source)
 {
 	PQExpBuffer query_buf;		/* buffer for query being accumulated */
-    PQExpBuffer previous_buf;   /* if there isn't anything in the new buffer
-                                   yet, use this one for \e, etc. */
+	PQExpBuffer previous_buf;	/* if there isn't anything in the new
+								 * buffer yet, use this one for \e, etc. */
 	char	   *line;			/* current line of input */
 	int			len;			/* length of the line */
 	volatile int successResult = EXIT_SUCCESS;
@@ -48,9 +49,9 @@ MainLoop(FILE *source)
 	volatile bool xcomment;		/* in extended comment */
 	volatile int paren_level;
 	unsigned int query_start;
-    volatile int count_eof = 0;
-    const char *var;
-    volatile unsigned int bslash_count = 0;
+	volatile int count_eof = 0;
+	const char *var;
+	volatile unsigned int bslash_count = 0;
 
 	int			i,
 				prevlen,
@@ -60,7 +61,7 @@ MainLoop(FILE *source)
 	FILE	   *prev_cmd_source;
 	bool		prev_cmd_interactive;
 
-    unsigned int prev_lineno;
+	unsigned int prev_lineno;
 	volatile bool die_on_error = false;
 
 
@@ -74,10 +75,10 @@ MainLoop(FILE *source)
 
 
 	query_buf = createPQExpBuffer();
-    previous_buf = createPQExpBuffer();
+	previous_buf = createPQExpBuffer();
 	if (!query_buf || !previous_buf)
 	{
-        psql_error("out of memory\n");
+		psql_error("out of memory\n");
 		exit(EXIT_FAILURE);
 	}
 
@@ -85,59 +86,62 @@ MainLoop(FILE *source)
 	in_quote = 0;
 	paren_level = 0;
 	slashCmdStatus = CMD_UNKNOWN;		/* set default */
-    prev_lineno = pset.lineno;
-    pset.lineno = 0;
+	prev_lineno = pset.lineno;
+	pset.lineno = 0;
 
 
 	/* main loop to get queries and execute them */
 	while (1)
 	{
 #ifndef WIN32
-        /*
-         * Welcome code for Control-C
-         */
-        if (cancel_pressed)
-        {
-            if (!pset.cur_cmd_interactive)
-            {
-                /*
-                 * You get here if you stopped a script with Ctrl-C and a query
-                 * cancel was issued. In that case we don't do the longjmp, so
-                 * the query routine can finish nicely.
-                 */
-                successResult = EXIT_USER;
-                break;
-            }
-
-            cancel_pressed = false;
-        }
-
-        if (sigsetjmp(main_loop_jmp, 1) != 0)
-        {
-            /* got here with longjmp */
-
-            if (pset.cur_cmd_interactive)
-            {
-                fputc('\n', stdout);
-                resetPQExpBuffer(query_buf);
-
-                /* reset parsing state */
-                xcomment = false;
-                in_quote = 0;
-                paren_level = 0;
-                count_eof = 0;
-                slashCmdStatus = CMD_UNKNOWN;
-            }
-            else
-            {
-                successResult = EXIT_USER;
-                break;
-            }
-        }
-#endif /* not WIN32 */
+
+		/*
+		 * Welcome code for Control-C
+		 */
+		if (cancel_pressed)
+		{
+			if (!pset.cur_cmd_interactive)
+			{
+
+				/*
+				 * You get here if you stopped a script with Ctrl-C and a
+				 * query cancel was issued. In that case we don't do the
+				 * longjmp, so the query routine can finish nicely.
+				 */
+				successResult = EXIT_USER;
+				break;
+			}
+
+			cancel_pressed = false;
+		}
+
+		if (sigsetjmp(main_loop_jmp, 1) != 0)
+		{
+			/* got here with longjmp */
+
+			if (pset.cur_cmd_interactive)
+			{
+				fputc('\n', stdout);
+				resetPQExpBuffer(query_buf);
+
+				/* reset parsing state */
+				xcomment = false;
+				in_quote = 0;
+				paren_level = 0;
+				count_eof = 0;
+				slashCmdStatus = CMD_UNKNOWN;
+			}
+			else
+			{
+				successResult = EXIT_USER;
+				break;
+			}
+		}
+#endif	 /* not WIN32 */
 
 		if (slashCmdStatus == CMD_NEWEDIT)
 		{
+
 			/*
 			 * just returned from editing the line? then just copy to the
 			 * input buffer
@@ -148,11 +152,12 @@ MainLoop(FILE *source)
 			xcomment = false;
 			in_quote = 0;
 			paren_level = 0;
-            slashCmdStatus = CMD_UNKNOWN;
+			slashCmdStatus = CMD_UNKNOWN;
 		}
 		else
 		{
-            fflush(stdout);
+			fflush(stdout);
+
 			/*
 			 * otherwise, set interactive prompt if necessary and get
 			 * another line
@@ -167,8 +172,8 @@ MainLoop(FILE *source)
 					prompt_status = PROMPT_DOUBLEQUOTE;
 				else if (xcomment)
 					prompt_status = PROMPT_COMMENT;
-                else if (paren_level)
-                    prompt_status = PROMPT_PAREN;
+				else if (paren_level)
+					prompt_status = PROMPT_PAREN;
 				else if (query_buf->len > 0)
 					prompt_status = PROMPT_CONTINUE;
 				else
@@ -195,51 +200,54 @@ MainLoop(FILE *source)
 		if (line == NULL)
 		{
 			if (pset.cur_cmd_interactive)
-            {
-                bool getout = true;
-
-                /* This tries to mimic bash's IGNOREEOF feature. */
-                const char * val = GetVariable(pset.vars, "IGNOREEOF");
-                if (val)
-                {
-                    long int maxeof;
-                    char * endptr;
-
-                    if (*val == '\0')
-                        maxeof = 10;
-                    else
-                    {
-                        maxeof = strtol(val, &endptr, 0);
-                        if (*endptr != '\0') /* string not valid as a number */
-                            maxeof = 10;
-                    }
-
-                    if (count_eof++ != maxeof)
-                        getout = false; /* not quite there yet */
-                }
-
-                if (getout)
-                {
-                    if (QUIET())
-                        putc('\n', stdout);
-                    else
-                        puts("\\q");
-                    break;
-                }
-                else
-                {
-                    if (!QUIET())
-                        printf("Use \"\\q\" to leave %s.\n", pset.progname);
-                    continue;
-                }
-            }
-            else /* not interactive */
-                break;
+			{
+				bool		getout = true;
+
+				/* This tries to mimic bash's IGNOREEOF feature. */
+				const char *val = GetVariable(pset.vars, "IGNOREEOF");
+
+				if (val)
+				{
+					long int	maxeof;
+					char	   *endptr;
+
+					if (*val == '\0')
+						maxeof = 10;
+					else
+					{
+						maxeof = strtol(val, &endptr, 0);
+						if (*endptr != '\0')	/* string not valid as a
+												 * number */
+							maxeof = 10;
+					}
+
+					if (count_eof++ != maxeof)
+						getout = false; /* not quite there yet */
+				}
+
+				if (getout)
+				{
+					if (QUIET())
+						putc('\n', stdout);
+					else
+						puts("\\q");
+					break;
+				}
+				else
+				{
+					if (!QUIET())
+						printf("Use \"\\q\" to leave %s.\n", pset.progname);
+					continue;
+				}
+			}
+			else
+/* not interactive */
+				break;
 		}
-        else
-            count_eof = 0;
+		else
+			count_eof = 0;
 
-        pset.lineno++;
+		pset.lineno++;
 
 		/* strip trailing backslashes, they don't have a clear meaning */
 		while (1)
@@ -260,10 +268,10 @@ MainLoop(FILE *source)
 		}
 
 		/* echo back if flag is set */
-        var = GetVariable(pset.vars, "ECHO");
-        if (!pset.cur_cmd_interactive && var && strcmp(var, "all")==0)
-            puts(line);
-        fflush(stdout);
+		var = GetVariable(pset.vars, "ECHO");
+		if (!pset.cur_cmd_interactive && var && strcmp(var, "all") == 0)
+			puts(line);
+		fflush(stdout);
 
 		len = strlen(line);
 		query_start = 0;
@@ -278,15 +286,16 @@ MainLoop(FILE *source)
 
 		success = true;
 		for (i = 0, prevlen = 0, thislen = (len > 0) ? PQmblen(line, pset.encoding) : 0;
-             i < len;
-             ADVANCE_1)
+			 i < len;
+			 ADVANCE_1)
 		{
 			/* was the previous character a backslash? */
-			bool was_bslash = (i > 0 && line[i - prevlen] == '\\');
-            if (was_bslash)
-                bslash_count++;
-            else
-                bslash_count = 0;
+			bool		was_bslash = (i > 0 && line[i - prevlen] == '\\');
+
+			if (was_bslash)
+				bslash_count++;
+			else
+				bslash_count = 0;
 
 			/* in quote? */
 			if (in_quote)
@@ -331,53 +340,57 @@ MainLoop(FILE *source)
 			else if (line[i] == ')' && paren_level > 0)
 				paren_level--;
 
-            /* colon -> substitute variable */
-            /* we need to be on the watch for the '::' operator */
-            else if (line[i] == ':' && !was_bslash
-                     && strspn(line+i+thislen, VALID_VARIABLE_CHARS)>0
-                     && !(prevlen>0 && line[i-prevlen] == ':')                     
-                )
-            {
+			/* colon -> substitute variable */
+			/* we need to be on the watch for the '::' operator */
+			else if (line[i] == ':' && !was_bslash
+				  && strspn(line + i + thislen, VALID_VARIABLE_CHARS) > 0
+					 && !(prevlen > 0 && line[i - prevlen] == ':')
+				)
+			{
 				size_t		in_length,
 							out_length;
 				const char *value;
 				char	   *new;
-                char       after;		/* the character after the variable name
-                                           will be temporarily overwritten */
+				char		after;		/* the character after the
+										 * variable name will be
+										 * temporarily overwritten */
 
 				in_length = strspn(&line[i + thislen], VALID_VARIABLE_CHARS);
 				after = line[i + thislen + in_length];
 				line[i + thislen + in_length] = '\0';
 
-                /* if the variable doesn't exist we'll leave the string as is */
+				/*
+				 * if the variable doesn't exist we'll leave the string as
+				 * is
+				 */
 				value = GetVariable(pset.vars, &line[i + thislen]);
-                if (value)
-                {
-                    out_length = strlen(value);
-
-                    new = malloc(len + out_length - (1 + in_length) + 1);
-                    if (!new)
-                    {
-                        psql_error("out of memory\n");
-                        exit(EXIT_FAILURE);
-                    }
-
-                    sprintf(new, "%.*s%s%c", i, line, value, after);
-                    if (after)
-                        strcat(new, line + i + 1 + in_length + 1);
-
-                    free(line);
-                    line = new;
-                    len = strlen(new);
-                    continue; /* reparse the just substituted */
-                }
-                else
-                {
-                    /* restore overwritten character */
-                    line[i + thislen + in_length] = after;
-                    /* move on ... */
-                }
-            }
+				if (value)
+				{
+					out_length = strlen(value);
+
+					new = malloc(len + out_length - (1 + in_length) + 1);
+					if (!new)
+					{
+						psql_error("out of memory\n");
+						exit(EXIT_FAILURE);
+					}
+
+					sprintf(new, "%.*s%s%c", i, line, value, after);
+					if (after)
+						strcat(new, line + i + 1 + in_length + 1);
+
+					free(line);
+					line = new;
+					len = strlen(new);
+					continue;	/* reparse the just substituted */
+				}
+				else
+				{
+					/* restore overwritten character */
+					line[i + thislen + in_length] = after;
+					/* move on ... */
+				}
+			}
 
 			/* semicolon? then send query */
 			else if (line[i] == ';' && !was_bslash && !paren_level)
@@ -386,6 +399,7 @@ MainLoop(FILE *source)
 				/* is there anything else on the line? */
 				if (line[query_start + strspn(line + query_start, " \t")] != '\0')
 				{
+
 					/*
 					 * insert a cosmetic newline, if this is not the first
 					 * line in the buffer
@@ -394,27 +408,29 @@ MainLoop(FILE *source)
 						appendPQExpBufferChar(query_buf, '\n');
 					/* append the line to the query buffer */
 					appendPQExpBufferStr(query_buf, line + query_start);
-                    appendPQExpBufferChar(query_buf, ';');
+					appendPQExpBufferChar(query_buf, ';');
 				}
 
 				/* execute query */
 				success = SendQuery(query_buf->data);
-                slashCmdStatus = success ? CMD_SEND : CMD_ERROR;
+				slashCmdStatus = success ? CMD_SEND : CMD_ERROR;
 
-                resetPQExpBuffer(previous_buf);
-                appendPQExpBufferStr(previous_buf, query_buf->data);
-                resetPQExpBuffer(query_buf);
+				resetPQExpBuffer(previous_buf);
+				appendPQExpBufferStr(previous_buf, query_buf->data);
+				resetPQExpBuffer(query_buf);
 				query_start = i + thislen;
 			}
 
-            /* if you have a burning need to send a semicolon or colon to
-               the backend ... */
-            else if (was_bslash && (line[i] == ';' || line[i] == ':'))
-            {
-                /* remove the backslash */
-                memmove(line + i - prevlen, line + i, len - i + 1);
-                len--;
-            }
+			/*
+			 * if you have a burning need to send a semicolon or colon to
+			 * the backend ...
+			 */
+			else if (was_bslash && (line[i] == ';' || line[i] == ':'))
+			{
+				/* remove the backslash */
+				memmove(line + i - prevlen, line + i, len - i + 1);
+				len--;
+			}
 
 			/* backslash command */
 			else if (was_bslash)
@@ -427,6 +443,7 @@ MainLoop(FILE *source)
 				/* is there anything else on the line for the command? */
 				if (line[query_start + strspn(line + query_start, " \t")] != '\0')
 				{
+
 					/*
 					 * insert a cosmetic newline, if this is not the first
 					 * line in the buffer
@@ -437,40 +454,41 @@ MainLoop(FILE *source)
 					appendPQExpBufferStr(query_buf, line + query_start);
 				}
 
-                /* handle backslash command */
-                slashCmdStatus = HandleSlashCmds(&line[i], 
-                                                 query_buf->len>0 ? query_buf : previous_buf,
-                                                 &end_of_cmd);
+				/* handle backslash command */
+				slashCmdStatus = HandleSlashCmds(&line[i],
+						   query_buf->len > 0 ? query_buf : previous_buf,
+												 &end_of_cmd);
 
 				success = slashCmdStatus != CMD_ERROR;
 
-                if ((slashCmdStatus == CMD_SEND || slashCmdStatus == CMD_NEWEDIT) &&
-                    query_buf->len == 0) {
-                    /* copy previous buffer to current for for handling */
-                    appendPQExpBufferStr(query_buf, previous_buf->data);
-                }
+				if ((slashCmdStatus == CMD_SEND || slashCmdStatus == CMD_NEWEDIT) &&
+					query_buf->len == 0)
+				{
+					/* copy previous buffer to current for for handling */
+					appendPQExpBufferStr(query_buf, previous_buf->data);
+				}
 
 				if (slashCmdStatus == CMD_SEND)
 				{
 					success = SendQuery(query_buf->data);
 					query_start = i + thislen;
 
-                    resetPQExpBuffer(previous_buf);
-                    appendPQExpBufferStr(previous_buf, query_buf->data);
-                    resetPQExpBuffer(query_buf);
+					resetPQExpBuffer(previous_buf);
+					appendPQExpBufferStr(previous_buf, query_buf->data);
+					resetPQExpBuffer(query_buf);
 				}
 
 				/* process anything left after the backslash command */
-                i += end_of_cmd - &line[i];
-                query_start = i;
+				i += end_of_cmd - &line[i];
+				query_start = i;
 			}
 
 
-            /* stop the script after error */
+			/* stop the script after error */
 			if (!success && die_on_error)
 				break;
 
-		} /* for (line) */
+		}						/* for (line) */
 
 
 		if (slashCmdStatus == CMD_TERMINATE)
@@ -495,10 +513,10 @@ MainLoop(FILE *source)
 		if (query_buf->data[0] != '\0' && GetVariableBool(pset.vars, "SINGLELINE"))
 		{
 			success = SendQuery(query_buf->data);
-            slashCmdStatus = success ? CMD_SEND : CMD_ERROR;
-            resetPQExpBuffer(previous_buf);
-            appendPQExpBufferStr(previous_buf, query_buf->data);
-            resetPQExpBuffer(query_buf);
+			slashCmdStatus = success ? CMD_SEND : CMD_ERROR;
+			resetPQExpBuffer(previous_buf);
+			appendPQExpBufferStr(previous_buf, query_buf->data);
+			resetPQExpBuffer(query_buf);
 		}
 
 
@@ -515,27 +533,27 @@ MainLoop(FILE *source)
 			successResult = EXIT_BADCONN;
 			break;
 		}
-	} /* while !endoffile/session */
-
-    /*
-     * Process query at the end of file without a semicolon
-     */
-    if (query_buf->len > 0 && !pset.cur_cmd_interactive)
-    {
-        success = SendQuery(query_buf->data);
-
-        if (!success && die_on_error)
-            successResult = EXIT_USER;
-        else if (pset.db == NULL)
-            successResult = EXIT_BADCONN;
-    }
-        
+	}							/* while !endoffile/session */
+
+	/*
+	 * Process query at the end of file without a semicolon
+	 */
+	if (query_buf->len > 0 && !pset.cur_cmd_interactive)
+	{
+		success = SendQuery(query_buf->data);
+
+		if (!success && die_on_error)
+			successResult = EXIT_USER;
+		else if (pset.db == NULL)
+			successResult = EXIT_BADCONN;
+	}
+
 	destroyPQExpBuffer(query_buf);
 	destroyPQExpBuffer(previous_buf);
 
 	pset.cur_cmd_source = prev_cmd_source;
 	pset.cur_cmd_interactive = prev_cmd_interactive;
-    pset.lineno = prev_lineno;
+	pset.lineno = prev_lineno;
 
 	return successResult;
 }	/* MainLoop() */
diff --git a/src/bin/psql/mainloop.h b/src/bin/psql/mainloop.h
index a9cc61b7f66b2a77877afa55ca47858eb6d79c98..d8bdf3087cd99cf7ebc4f356697d9dd1e45dcc81 100644
--- a/src/bin/psql/mainloop.h
+++ b/src/bin/psql/mainloop.h
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.h,v 1.8 2000/02/20 14:28:20 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.h,v 1.9 2000/04/12 17:16:22 momjian Exp $
  */
 #ifndef MAINLOOP_H
 #define MAINLOOP_H
@@ -14,8 +14,9 @@
 #include <setjmp.h>
 
 extern sigjmp_buf main_loop_jmp;
+
 #endif
 
-int MainLoop(FILE *source);
+int			MainLoop(FILE *source);
 
 #endif	 /* MAINLOOP_H */
diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c
index 82cb64b7cfef0e66d6d67256bf9202419ee6077e..b94b90ba36ff1e963dba249657471526786e5718 100644
--- a/src/bin/psql/print.c
+++ b/src/bin/psql/print.c
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.12 2000/02/16 13:15:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.13 2000/04/12 17:16:22 momjian Exp $
  */
 #include "postgres.h"
 #include "print.h"
@@ -35,20 +35,20 @@
 
 
 static void
-print_unaligned_text(const char *title, const char * const * headers,
-		     const char * const * cells, const char * const * footers,
-		     const char *opt_fieldsep, const char *opt_recordsep, bool opt_barebones,
-		     FILE *fout)
+print_unaligned_text(const char *title, const char *const * headers,
+				  const char *const * cells, const char *const * footers,
+ const char *opt_fieldsep, const char *opt_recordsep, bool opt_barebones,
+					 FILE *fout)
 {
 	unsigned int col_count = 0;
 	unsigned int i;
-	const char * const * ptr;
-    bool need_recordsep = false;
+	const char *const * ptr;
+	bool		need_recordsep = false;
 
 	if (!opt_fieldsep)
 		opt_fieldsep = "";
-    if (!opt_recordsep)
-        opt_recordsep = "";
+	if (!opt_recordsep)
+		opt_recordsep = "";
 
 	/* print title */
 	if (!opt_barebones && title)
@@ -66,22 +66,22 @@ print_unaligned_text(const char *title, const char * const * headers,
 		}
 	}
 	if (!opt_barebones)
-        need_recordsep = true;
+		need_recordsep = true;
 
 	/* print cells */
 	i = 0;
 	for (ptr = cells; *ptr; ptr++)
 	{
-        if (need_recordsep)
-        {
+		if (need_recordsep)
+		{
 			fputs(opt_recordsep, fout);
-            need_recordsep = false;
-        }
+			need_recordsep = false;
+		}
 		fputs(*ptr, fout);
 		if ((i + 1) % col_count)
 			fputs(opt_fieldsep, fout);
 		else
-            need_recordsep = true;
+			need_recordsep = true;
 		i++;
 	}
 
@@ -89,41 +89,41 @@ print_unaligned_text(const char *title, const char * const * headers,
 
 	if (!opt_barebones && footers)
 		for (ptr = footers; *ptr; ptr++)
-        {
-            if (need_recordsep)
-            {
-                fputs(opt_recordsep, fout);
-                need_recordsep = false;
-            }
+		{
+			if (need_recordsep)
+			{
+				fputs(opt_recordsep, fout);
+				need_recordsep = false;
+			}
 			fputs(*ptr, fout);
-            need_recordsep = true;
-        }
+			need_recordsep = true;
+		}
 
-    /* the last record needs to be concluded with a newline */
-    if (need_recordsep)
-        fputc('\n', fout);
+	/* the last record needs to be concluded with a newline */
+	if (need_recordsep)
+		fputc('\n', fout);
 }
 
 
 
 static void
-print_unaligned_vertical(const char *title, const char * const * headers,
-			 const char * const * cells, const char * const * footers,
-			 const char *opt_fieldsep, const char *opt_recordsep, bool opt_barebones,
-			 FILE *fout)
+print_unaligned_vertical(const char *title, const char *const * headers,
+				  const char *const * cells, const char *const * footers,
+ const char *opt_fieldsep, const char *opt_recordsep, bool opt_barebones,
+						 FILE *fout)
 {
 	unsigned int col_count = 0;
 	unsigned int i;
-	const char * const * ptr;
+	const char *const * ptr;
 
 	if (!opt_fieldsep)
 		opt_fieldsep = "";
-    if (!opt_recordsep)
-        opt_recordsep = "";
+	if (!opt_recordsep)
+		opt_recordsep = "";
 
 	/* print title */
 	if (!opt_barebones && title)
-        fputs(title, fout);
+		fputs(title, fout);
 
 	/* count columns */
 	for (ptr = headers; *ptr; ptr++)
@@ -132,30 +132,30 @@ print_unaligned_vertical(const char *title, const char * const * headers,
 	/* print records */
 	for (i = 0, ptr = cells; *ptr; i++, ptr++)
 	{
-        if (i!=0 || (!opt_barebones && title))
-        {
-            fputs(opt_recordsep, fout);
-            if (i % col_count == 0)
-                fputs(opt_recordsep, fout); /* another one */
-        }
-
-        fputs(headers[i % col_count], fout);
-        fputs(opt_fieldsep, fout);
-        fputs(*ptr, fout);
+		if (i != 0 || (!opt_barebones && title))
+		{
+			fputs(opt_recordsep, fout);
+			if (i % col_count == 0)
+				fputs(opt_recordsep, fout);		/* another one */
+		}
+
+		fputs(headers[i % col_count], fout);
+		fputs(opt_fieldsep, fout);
+		fputs(*ptr, fout);
 	}
 
 	/* print footers */
 	if (!opt_barebones && footers && *footers)
 	{
-        fputs(opt_recordsep, fout);
+		fputs(opt_recordsep, fout);
 		for (ptr = footers; *ptr; ptr++)
-        {
-            fputs(opt_recordsep, fout);
-            fputs(*ptr, fout);
-        }
+		{
+			fputs(opt_recordsep, fout);
+			fputs(*ptr, fout);
+		}
 	}
 
-    fputc('\n', fout);
+	fputc('\n', fout);
 }
 
 
@@ -202,17 +202,17 @@ _print_horizontal_line(const unsigned int col_count, const unsigned int *widths,
 
 
 static void
-print_aligned_text(const char *title, const char * const * headers,
-		   const char * const * cells, const char * const * footers,
-		   const char *opt_align, bool opt_barebones, unsigned short int opt_border,
-		   FILE *fout)
+print_aligned_text(const char *title, const char *const * headers,
+				   const char *const * cells, const char *const * footers,
+const char *opt_align, bool opt_barebones, unsigned short int opt_border,
+				   FILE *fout)
 {
 	unsigned int col_count = 0;
 	unsigned int i,
 				tmp;
 	unsigned int *widths,
 				total_w;
-	const char * const * ptr;
+	const char *const * ptr;
 
 	/* count columns */
 	for (ptr = headers; *ptr; ptr++)
@@ -268,8 +268,8 @@ print_aligned_text(const char *title, const char * const * headers,
 		{
 			/* centered */
 			fprintf(fout, "%-*s%s%-*s",
-                    (int) floor((widths[i] - strlen(headers[i])) / 2.0), "",
-                    headers[i], (int) ceil((widths[i] - strlen(headers[i])) / 2.0), "");
+				 (int) floor((widths[i] - strlen(headers[i])) / 2.0), "",
+					headers[i], (int) ceil((widths[i] - strlen(headers[i])) / 2.0), "");
 
 			if (i < col_count - 1)
 			{
@@ -346,24 +346,25 @@ print_aligned_text(const char *title, const char * const * headers,
 
 
 static void
-print_aligned_vertical(const char *title, const char * const * headers,
-		       const char * const * cells, const char * const * footers,
-		       bool opt_barebones, unsigned short int opt_border,
-		       FILE *fout)
+print_aligned_vertical(const char *title, const char *const * headers,
+				  const char *const * cells, const char *const * footers,
+					   bool opt_barebones, unsigned short int opt_border,
+					   FILE *fout)
 {
 	unsigned int col_count = 0;
 	unsigned int record = 1;
-	const char * const *ptr;
+	const char *const * ptr;
 	unsigned int i,
 				tmp,
 				hwidth = 0,
 				dwidth = 0;
 	char	   *divider;
 
-    if (cells[0] == NULL) {
-        puts("(No rows)\n");
-        return;
-    }
+	if (cells[0] == NULL)
+	{
+		puts("(No rows)\n");
+		return;
+	}
 
 	/* count columns and find longest header */
 	for (ptr = headers; *ptr; ptr++)
@@ -427,20 +428,21 @@ print_aligned_vertical(const char *title, const char * const * headers,
 				record_str_len = strlen(record_str);
 
 				if (record_str_len + opt_border > strlen(divider))
-                    fprintf(fout, "%.*s%s\n", opt_border, divider, record_str);
-                else
-                {
-                    char	   *div_copy = strdup(divider);
-
-                    if (!div_copy) {
-                        perror("malloc");
-                        exit(EXIT_FAILURE);
-                    }
-
-                    strncpy(div_copy + opt_border, record_str, record_str_len);
-                    fprintf(fout, "%s\n", div_copy);
-                    free(div_copy);
-                }
+					fprintf(fout, "%.*s%s\n", opt_border, divider, record_str);
+				else
+				{
+					char	   *div_copy = strdup(divider);
+
+					if (!div_copy)
+					{
+						perror("malloc");
+						exit(EXIT_FAILURE);
+					}
+
+					strncpy(div_copy + opt_border, record_str, record_str_len);
+					fprintf(fout, "%s\n", div_copy);
+					free(div_copy);
+				}
 				free(record_str);
 			}
 			else if (i != 0 || opt_border == 2)
@@ -517,15 +519,15 @@ html_escaped_print(const char *in, FILE *fout)
 
 
 static void
-print_html_text(const char *title, const char * const * headers,
-		const char * const * cells, const char * const * footers,
-		const char *opt_align, bool opt_barebones, unsigned short int opt_border,
-		const char *opt_table_attr,
-		FILE *fout)
+print_html_text(const char *title, const char *const * headers,
+				const char *const * cells, const char *const * footers,
+const char *opt_align, bool opt_barebones, unsigned short int opt_border,
+				const char *opt_table_attr,
+				FILE *fout)
 {
 	unsigned int col_count = 0;
 	unsigned int i;
-	const char * const *ptr;
+	const char *const * ptr;
 
 	fprintf(fout, "<table border=%d", opt_border);
 	if (opt_table_attr)
@@ -591,16 +593,16 @@ print_html_text(const char *title, const char * const * headers,
 
 
 static void
-print_html_vertical(const char *title, const char * const * headers,
-		    const char * const * cells, const char * const * footers,
-		    const char *opt_align, bool opt_barebones, unsigned short int opt_border,
-		    const char *opt_table_attr,
+print_html_vertical(const char *title, const char *const * headers,
+				  const char *const * cells, const char *const * footers,
+const char *opt_align, bool opt_barebones, unsigned short int opt_border,
+					const char *opt_table_attr,
 					FILE *fout)
 {
 	unsigned int col_count = 0;
 	unsigned int i;
 	unsigned int record = 1;
-	const char * const *ptr;
+	const char *const * ptr;
 
 	fprintf(fout, "<table border=%d", opt_border);
 	if (opt_table_attr)
@@ -700,15 +702,15 @@ latex_escaped_print(const char *in, FILE *fout)
 
 
 static void
-print_latex_text(const char *title, const char * const * headers,
-		 const char * const * cells, const char * const * footers,
-		 const char *opt_align, bool opt_barebones, unsigned short int opt_border,
-		 FILE *fout)
+print_latex_text(const char *title, const char *const * headers,
+				 const char *const * cells, const char *const * footers,
+const char *opt_align, bool opt_barebones, unsigned short int opt_border,
+				 FILE *fout)
 {
 	unsigned int col_count = 0;
 	unsigned int i;
 	const char *cp;
-	const char * const *ptr;
+	const char *const * ptr;
 
 
 	/* print title */
@@ -796,14 +798,14 @@ print_latex_text(const char *title, const char * const * headers,
 
 
 static void
-print_latex_vertical(const char *title, const char * const * headers,
-		     const char * const * cells, const char * const * footers,
-		     const char *opt_align, bool opt_barebones, unsigned short int opt_border,
-		     FILE *fout)
+print_latex_vertical(const char *title, const char *const * headers,
+				  const char *const * cells, const char *const * footers,
+const char *opt_align, bool opt_barebones, unsigned short int opt_border,
+					 FILE *fout)
 {
 	unsigned int col_count = 0;
 	unsigned int i;
-	const char * const *ptr;
+	const char *const * ptr;
 	unsigned int record = 1;
 
 	(void) opt_align;			/* currently unused parameter */
@@ -884,11 +886,11 @@ print_latex_vertical(const char *title, const char * const * headers,
 
 void
 printTable(const char *title,
-	   const char * const * headers,
-	   const char * const * cells,
-	   const char * const * footers,
-	   const char *align,
-	   const printTableOpt * opt, FILE *fout)
+		   const char *const * headers,
+		   const char *const * cells,
+		   const char *const * footers,
+		   const char *align,
+		   const printTableOpt *opt, FILE *fout)
 {
 	const char *default_footer[] = {NULL};
 	unsigned short int border = opt->border;
@@ -921,7 +923,7 @@ printTable(const char *title,
 		unsigned int col_count = 0,
 					row_count = 0,
 					lines;
-		const char * const *ptr;
+		const char *const * ptr;
 		int			result;
 		struct winsize screen_size;
 
@@ -1010,13 +1012,13 @@ printTable(const char *title,
 
 
 void
-printQuery(const PGresult *result, const printQueryOpt * opt, FILE *fout)
+printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout)
 {
 	int			nfields;
 	const char **headers;
 	const char **cells;
-	char **footers;
-	char 	   *align;
+	char	  **footers;
+	char	   *align;
 	int			i;
 
 	/* extract headers */
@@ -1102,8 +1104,8 @@ printQuery(const PGresult *result, const printQueryOpt * opt, FILE *fout)
 	/* call table printer */
 
 	printTable(opt->title, headers, cells,
-		   footers ? (const char * const *)footers : (const char * const *)(opt->footers),
-		   align, &opt->topt, fout);
+			   footers ? (const char *const *) footers : (const char *const *) (opt->footers),
+			   align, &opt->topt, fout);
 
 	free(headers);
 	free(cells);
diff --git a/src/bin/psql/print.h b/src/bin/psql/print.h
index 4706b8fba02e77c25ce9e441bc88e7a85e0794b6..d2c8980ba78215df1f407899e6f4898c09bf6115 100644
--- a/src/bin/psql/print.h
+++ b/src/bin/psql/print.h
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/print.h,v 1.7 2000/02/16 13:15:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/print.h,v 1.8 2000/04/12 17:16:23 momjian Exp $
  */
 #ifndef PRINT_H
 #define PRINT_H
@@ -32,9 +32,10 @@ typedef struct _printTableOpt
 	unsigned short int border;	/* Print a border around the table.
 								 * 0=none, 1=dividing lines, 2=full */
 	char	   *fieldSep;		/* field separator for unaligned text mode */
-    char       *recordSep;      /* record separator for unaligned text mode */
+	char	   *recordSep;		/* record separator for unaligned text
+								 * mode */
 	char	   *tableAttr;		/* attributes for HTML <table ...> */
-}			printTableOpt;
+} printTableOpt;
 
 
 /*
@@ -48,10 +49,10 @@ typedef struct _printTableOpt
  * - align is an 'l' or an 'r' for every column, if the output format needs it.
  *	 (You must specify this long enough. Otherwise anything could happen.)
 */
-void printTable(const char *title, const char * const * headers,
-		const char * const * cells, const char * const * footers,
-		const char *align,
-		const printTableOpt * opt, FILE *fout);
+void printTable(const char *title, const char *const * headers,
+		   const char *const * cells, const char *const * footers,
+		   const char *align,
+		   const printTableOpt *opt, FILE *fout);
 
 
 
@@ -63,7 +64,7 @@ typedef struct _printQueryOpt
 	char	   *title;			/* override title */
 	char	  **footers;		/* override footer (default is "(xx
 								 * rows)") */
-}			printQueryOpt;
+} printQueryOpt;
 
 /*
  * Use this to print query results
@@ -71,7 +72,7 @@ typedef struct _printQueryOpt
  * It calls the printTable above with all the things set straight.
  */
 void
-printQuery(const PGresult *result, const printQueryOpt * opt, FILE *fout);
+			printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout);
 
 
 #endif	 /* PRINT_H */
diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c
index b8b59eb15c530549e310ad982e0a0c406edc6a3e..9901b21652bb8e17dde681690203371f54ae6f54 100644
--- a/src/bin/psql/prompt.c
+++ b/src/bin/psql/prompt.c
@@ -3,8 +3,8 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.11 2000/03/11 13:56:24 petere Exp $
- */ 
+ * $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.12 2000/04/12 17:16:23 momjian Exp $
+ */
 #include "postgres.h"
 #include "prompt.h"
 
@@ -32,9 +32,9 @@
  * (might not be completely multibyte safe)
  *
  * Defined interpolations are:
- * %M - database server "hostname.domainname" (or "localhost" if this 
+ * %M - database server "hostname.domainname" (or "localhost" if this
  *	information is not available)
- * %m - like %M, but hostname only (before first dot) 
+ * %m - like %M, but hostname only (before first dot)
  * %> - database server port number
  * %n - database user name
  * %/ - current database
@@ -62,47 +62,48 @@
  */
 
 /*
- * We need hostname information, only if connection is via UNIX socket 
+ * We need hostname information, only if connection is via UNIX socket
  */
 #if !defined(WIN32) && !defined(__CYGWIN32__) && !defined(__QNX__)
 
 #define DOMAINNAME	1
 #define HOSTNAME	2
 
-/* 
- * Return full hostname for localhost. 
+/*
+ * Return full hostname for localhost.
  *	- informations are init only in firts time - not queries DNS or NIS
- *	  for every localhost() call 	
+ *	  for every localhost() call
  */
 static char *
-localhost(int type, char *buf, int siz)	
-{	
-	static struct hostent	*hp = NULL;
-	static int err = 0;
-	
-	if (hp==NULL && err==0)
-	{	
-		char hname[256];		
-		
+localhost(int type, char *buf, int siz)
+{
+	static struct hostent *hp = NULL;
+	static int	err = 0;
+
+	if (hp == NULL && err == 0)
+	{
+		char		hname[256];
+
 		if (gethostname(hname, 256) == 0)
 		{
 			if (!(hp = gethostbyname(hname)))
-				err = 1; 
+				err = 1;
 		}
 		else
-			err = 1;		
+			err = 1;
 	}
-	
-	if (hp==NULL) 
+
+	if (hp == NULL)
 		return strncpy(buf, "localhost", siz);
-	
+
 	strncpy(buf, hp->h_name, siz);		/* full aaa.bbb.ccc */
-	
-	if (type==HOSTNAME)
+
+	if (type == HOSTNAME)
 		buf[strcspn(buf, ".")] = '\0';
-	
-	return buf;	
+
+	return buf;
 }
+
 #endif
 
 char *
@@ -172,20 +173,21 @@ get_prompt(promptStatus_t status)
 								buf[strcspn(buf, ".")] = '\0';
 						}
 						/* UNIX socket */
-#if !defined(WIN32) && !defined(__CYGWIN32__) && !defined(__QNX__)						
-						else {
-							if (*p == 'm')	
+#if !defined(WIN32) && !defined(__CYGWIN32__) && !defined(__QNX__)
+						else
+						{
+							if (*p == 'm')
 								localhost(HOSTNAME, buf, MAX_PROMPT_SIZE);
 							else
 								localhost(DOMAINNAME, buf, MAX_PROMPT_SIZE);
 						}
-#endif					
+#endif
 					}
 					break;
 					/* DB server port number */
 				case '>':
 					if (pset.db && PQport(pset.db))
-                        strncpy(buf, PQport(pset.db), MAX_PROMPT_SIZE);
+						strncpy(buf, PQport(pset.db), MAX_PROMPT_SIZE);
 					break;
 					/* DB server user name */
 				case 'n':
@@ -236,9 +238,9 @@ get_prompt(promptStatus_t status)
 						case PROMPT_COMMENT:
 							buf[0] = '*';
 							break;
-                        case PROMPT_PAREN:
-                            buf[0] = '(';
-                            break;
+						case PROMPT_PAREN:
+							buf[0] = '(';
+							break;
 						default:
 							buf[0] = '\0';
 							break;
diff --git a/src/bin/psql/prompt.h b/src/bin/psql/prompt.h
index 46d3dab93ba76db850b4fe4f00a3ccb779af0cad..0c0c209ff30b77173931c90f9c3132d1346e6020 100644
--- a/src/bin/psql/prompt.h
+++ b/src/bin/psql/prompt.h
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/prompt.h,v 1.7 2000/02/16 13:15:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/prompt.h,v 1.8 2000/04/12 17:16:23 momjian Exp $
  */
 #ifndef PROMPT_H
 #define PROMPT_H
@@ -15,10 +15,10 @@ typedef enum _promptStatus
 	PROMPT_COMMENT,
 	PROMPT_SINGLEQUOTE,
 	PROMPT_DOUBLEQUOTE,
-    PROMPT_PAREN,
+	PROMPT_PAREN,
 	PROMPT_COPY
-}			promptStatus_t;
+} promptStatus_t;
 
-char *get_prompt(promptStatus_t status);
+char	   *get_prompt(promptStatus_t status);
 
 #endif	 /* PROMPT_H */
diff --git a/src/bin/psql/settings.h b/src/bin/psql/settings.h
index d56b0c77e9b211885321faf280d9006136341016..d5d306b158651322946029ef84a10277d7723c38 100644
--- a/src/bin/psql/settings.h
+++ b/src/bin/psql/settings.h
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/settings.h,v 1.9 2000/02/16 13:15:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/settings.h,v 1.10 2000/04/12 17:16:23 momjian Exp $
  */
 #ifndef SETTINGS_H
 #define SETTINGS_H
@@ -25,7 +25,7 @@
 typedef struct _psqlSettings
 {
 	PGconn	   *db;				/* connection to backend */
-    int         encoding;
+	int			encoding;
 	FILE	   *queryFout;		/* where to send the query results */
 	bool		queryFoutPipe;	/* queryFout is from a popen() */
 
@@ -44,12 +44,12 @@ typedef struct _psqlSettings
 								 * loop */
 	bool		cur_cmd_interactive;
 
-    char       *progname;       /* in case you renamed psql */
-    char       *inputfile;      /* for error reporting */
-    unsigned    lineno;         /* also for error reporting */
+	char	   *progname;		/* in case you renamed psql */
+	char	   *inputfile;		/* for error reporting */
+	unsigned	lineno;			/* also for error reporting */
 
-    bool        issuper;        /* is the current user a superuser?
-                                   (used to form the prompt) */
+	bool		issuper;		/* is the current user a superuser? (used
+								 * to form the prompt) */
 } PsqlSettings;
 
 extern PsqlSettings pset;
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index e0e3ea4a1c23eb4130269ef56ea2d2226122212a..74a3d216fc981118c00260aa0d17edcfbef4a17d 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.28 2000/03/18 22:48:29 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.29 2000/04/12 17:16:23 momjian Exp $
  */
 #include "postgres.h"
 
@@ -11,11 +11,11 @@
 
 #ifndef WIN32
 #include <unistd.h>
-#else /* WIN32 */
+#else							/* WIN32 */
 #include <io.h>
 #include <windows.h>
 #include <win32.h>
-#endif /* WIN32 */
+#endif	 /* WIN32 */
 
 #ifdef HAVE_GETOPT_H
 #include <getopt.h>
@@ -70,17 +70,17 @@ struct adhoc_opts
 	enum _actions action;
 	char	   *action_string;
 	bool		no_readline;
-    bool        no_psqlrc;
+	bool		no_psqlrc;
 };
 
 static void
-parse_psql_options(int argc, char *argv[], struct adhoc_opts * options);
+			parse_psql_options(int argc, char *argv[], struct adhoc_opts * options);
 
 static void
-process_psqlrc(void);
+			process_psqlrc(void);
 
 static void
-showVersion(void);
+			showVersion(void);
 
 
 
@@ -99,27 +99,27 @@ main(int argc, char *argv[])
 	char	   *password = NULL;
 	bool		need_pass;
 
-    if (!strrchr(argv[0], SEP_CHAR))
-        pset.progname = argv[0];
-    else
-        pset.progname = strrchr(argv[0], SEP_CHAR) + 1;
+	if (!strrchr(argv[0], SEP_CHAR))
+		pset.progname = argv[0];
+	else
+		pset.progname = strrchr(argv[0], SEP_CHAR) + 1;
 
 	pset.cur_cmd_source = stdin;
 	pset.cur_cmd_interactive = false;
-    pset.encoding = PQenv2encoding();
+	pset.encoding = PQenv2encoding();
 
 	pset.vars = CreateVariableSpace();
-    if (!pset.vars)
-    {
-        fprintf(stderr, "%s: out of memory\n", pset.progname);
-        exit(EXIT_FAILURE);
-    }
+	if (!pset.vars)
+	{
+		fprintf(stderr, "%s: out of memory\n", pset.progname);
+		exit(EXIT_FAILURE);
+	}
 	pset.popt.topt.format = PRINT_ALIGNED;
 	pset.queryFout = stdout;
 	pset.popt.topt.border = 1;
 	pset.popt.topt.pager = true;
 
-    SetVariable(pset.vars, "VERSION", PG_VERSION_STR);
+	SetVariable(pset.vars, "VERSION", PG_VERSION_STR);
 
 	pset.notty = (!isatty(fileno(stdin)) || !isatty(fileno(stdout)));
 
@@ -132,18 +132,19 @@ main(int argc, char *argv[])
 
 	parse_psql_options(argc, argv, &options);
 
-    if (!pset.popt.topt.fieldSep)
-        pset.popt.topt.fieldSep = xstrdup(DEFAULT_FIELD_SEP);
-    if (!pset.popt.topt.recordSep)
-        pset.popt.topt.recordSep = xstrdup(DEFAULT_RECORD_SEP);
+	if (!pset.popt.topt.fieldSep)
+		pset.popt.topt.fieldSep = xstrdup(DEFAULT_FIELD_SEP);
+	if (!pset.popt.topt.recordSep)
+		pset.popt.topt.recordSep = xstrdup(DEFAULT_RECORD_SEP);
 
 	if (options.username)
 	{
-        /*
-         * The \001 is a hack to support the deprecated -u option which issues
-         * a username prompt. The recommended option is -U followed by the name
-         * on the command line.
-         */
+
+		/*
+		 * The \001 is a hack to support the deprecated -u option which
+		 * issues a username prompt. The recommended option is -U followed
+		 * by the name on the command line.
+		 */
 		if (strcmp(options.username, "\001") == 0)
 			username = simple_prompt("Username: ", 100, true);
 		else
@@ -158,8 +159,8 @@ main(int argc, char *argv[])
 	{
 		need_pass = false;
 		pset.db = PQsetdbLogin(options.host, options.port, NULL, NULL,
-                               options.action == ACT_LIST_DB ? "template1" : options.dbname,
-                               username, password);
+			options.action == ACT_LIST_DB ? "template1" : options.dbname,
+							   username, password);
 
 		if (PQstatus(pset.db) == CONNECTION_BAD &&
 			strcmp(PQerrorMessage(pset.db), "fe_sendauth: no password supplied\n") == 0)
@@ -176,17 +177,18 @@ main(int argc, char *argv[])
 
 	if (PQstatus(pset.db) == CONNECTION_BAD)
 	{
-        fprintf(stderr, "%s: %s", pset.progname, PQerrorMessage(pset.db));
+		fprintf(stderr, "%s: %s", pset.progname, PQerrorMessage(pset.db));
 		PQfinish(pset.db);
 		exit(EXIT_BADCONN);
 	}
 
-    PQsetNoticeProcessor(pset.db, NoticeProcessor, NULL);
-    /*
-     * We need to save the encoding because we want to have it
-     * available even if the database connection goes bad.
-     */
-    pset.encoding = PQclientEncoding(pset.db);
+	PQsetNoticeProcessor(pset.db, NoticeProcessor, NULL);
+
+	/*
+	 * We need to save the encoding because we want to have it available
+	 * even if the database connection goes bad.
+	 */
+	pset.encoding = PQclientEncoding(pset.db);
 
 	if (options.action == ACT_LIST_DB)
 	{
@@ -196,79 +198,82 @@ main(int argc, char *argv[])
 		exit(success ? EXIT_SUCCESS : EXIT_FAILURE);
 	}
 
-    SetVariable(pset.vars, "DBNAME", PQdb(pset.db));
-    SetVariable(pset.vars, "USER", PQuser(pset.db));
-    SetVariable(pset.vars, "HOST", PQhost(pset.db));
-    SetVariable(pset.vars, "PORT", PQport(pset.db));
-    SetVariable(pset.vars, "ENCODING", pg_encoding_to_char(pset.encoding));
+	SetVariable(pset.vars, "DBNAME", PQdb(pset.db));
+	SetVariable(pset.vars, "USER", PQuser(pset.db));
+	SetVariable(pset.vars, "HOST", PQhost(pset.db));
+	SetVariable(pset.vars, "PORT", PQport(pset.db));
+	SetVariable(pset.vars, "ENCODING", pg_encoding_to_char(pset.encoding));
 
 #ifndef WIN32
 	pqsignal(SIGINT, handle_sigint);	/* control-C => cancel */
 #endif
 
 	/*
-     * Now find something to do
-     */
+	 * Now find something to do
+	 */
 
 	/*
-     * process file given by -f
-     */
+	 * process file given by -f
+	 */
 	if (options.action == ACT_FILE)
-    {
-        if (!options.no_psqlrc)
-            process_psqlrc();
+	{
+		if (!options.no_psqlrc)
+			process_psqlrc();
 
 		successResult = process_file(options.action_string);
-    }
+	}
+
 	/*
-     * process slash command if one was given to -c
-     */
+	 * process slash command if one was given to -c
+	 */
 	else if (options.action == ACT_SINGLE_SLASH)
-    {
-        const char * value;
+	{
+		const char *value;
 
-        if ((value = GetVariable(pset.vars, "ECHO")) && strcmp(value, "all")==0)
-            puts(options.action_string);
+		if ((value = GetVariable(pset.vars, "ECHO")) && strcmp(value, "all") == 0)
+			puts(options.action_string);
 		successResult = HandleSlashCmds(options.action_string, NULL, NULL) != CMD_ERROR
-            ? EXIT_SUCCESS : EXIT_FAILURE;
-    }
+			? EXIT_SUCCESS : EXIT_FAILURE;
+	}
+
 	/*
-     * If the query given to -c was a normal one, send it
-     */
+	 * If the query given to -c was a normal one, send it
+	 */
 	else if (options.action == ACT_SINGLE_QUERY)
-    {
-        const char * value;
+	{
+		const char *value;
 
-        if ((value = GetVariable(pset.vars, "ECHO")) && strcmp(value, "all")==0)
-            puts(options.action_string);
+		if ((value = GetVariable(pset.vars, "ECHO")) && strcmp(value, "all") == 0)
+			puts(options.action_string);
 		successResult = SendQuery(options.action_string)
-            ? EXIT_SUCCESS : EXIT_FAILURE;
-    }
+			? EXIT_SUCCESS : EXIT_FAILURE;
+	}
+
 	/*
-     * or otherwise enter interactive main loop
-     */
+	 * or otherwise enter interactive main loop
+	 */
 	else
-    {
-        pset.issuper = test_superuser(PQuser(pset.db));
-        if (!QUIET() && !pset.notty)
-        {
-            printf("Welcome to %s, the PostgreSQL interactive terminal.\n\n"
-                   "Type:  \\copyright for distribution terms\n"
-                   "       \\h for help with SQL commands\n"
-                   "       \\? for help on internal slash commands\n"
-                   "       \\g or terminate with semicolon to execute query\n"
-                   "       \\q to quit\n\n", pset.progname);
-        }
-
-        SetVariable(pset.vars, "PROMPT1", DEFAULT_PROMPT1);
-        SetVariable(pset.vars, "PROMPT2", DEFAULT_PROMPT2);
-        SetVariable(pset.vars, "PROMPT3", DEFAULT_PROMPT3);
-        if (!options.no_psqlrc)
-            process_psqlrc();
-        if (!pset.notty)
-            initializeInput(options.no_readline ? 0 : 1);
+	{
+		pset.issuper = test_superuser(PQuser(pset.db));
+		if (!QUIET() && !pset.notty)
+		{
+			printf("Welcome to %s, the PostgreSQL interactive terminal.\n\n"
+				   "Type:  \\copyright for distribution terms\n"
+				   "       \\h for help with SQL commands\n"
+				   "       \\? for help on internal slash commands\n"
+			  "       \\g or terminate with semicolon to execute query\n"
+				   "       \\q to quit\n\n", pset.progname);
+		}
+
+		SetVariable(pset.vars, "PROMPT1", DEFAULT_PROMPT1);
+		SetVariable(pset.vars, "PROMPT2", DEFAULT_PROMPT2);
+		SetVariable(pset.vars, "PROMPT3", DEFAULT_PROMPT3);
+		if (!options.no_psqlrc)
+			process_psqlrc();
+		if (!pset.notty)
+			initializeInput(options.no_readline ? 0 : 1);
 		successResult = MainLoop(stdin);
-    }
+	}
 
 	/* clean up */
 	PQfinish(pset.db);
@@ -286,8 +291,10 @@ main(int argc, char *argv[])
 #ifdef WIN32
 /* getopt is not in the standard includes on Win32 */
 int			getopt(int, char *const[], const char *);
+
 /* And it requires progname to be set */
-char        *__progname = "psql";
+char	   *__progname = "psql";
+
 #endif
 
 static void
@@ -295,8 +302,8 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
 {
 #ifdef HAVE_GETOPT_LONG
 	static struct option long_options[] =
-    {
-        {"echo-all", no_argument, NULL, 'a'},
+	{
+		{"echo-all", no_argument, NULL, 'a'},
 		{"no-align", no_argument, NULL, 'A'},
 		{"command", required_argument, NULL, 'c'},
 		{"dbname", required_argument, NULL, 'd'},
@@ -311,7 +318,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
 		{"port", required_argument, NULL, 'p'},
 		{"pset", required_argument, NULL, 'P'},
 		{"quiet", no_argument, NULL, 'q'},
-        {"record-separator", required_argument, NULL, 'R'},
+		{"record-separator", required_argument, NULL, 'R'},
 		{"single-step", no_argument, NULL, 's'},
 		{"single-line", no_argument, NULL, 'S'},
 		{"tuples-only", no_argument, NULL, 't'},
@@ -322,29 +329,31 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
 		{"version", no_argument, NULL, 'V'},
 		{"password", no_argument, NULL, 'W'},
 		{"expanded", no_argument, NULL, 'x'},
-        {"no-psqlrc", no_argument, NULL, 'X'},
+		{"no-psqlrc", no_argument, NULL, 'X'},
 		{"help", no_argument, NULL, '?'},
 	};
 
 	int			optindex;
-#endif /* HAVE_GETOPT_LONG */
+
+#endif	 /* HAVE_GETOPT_LONG */
 
 	extern char *optarg;
 	extern int	optind;
 	int			c;
-    bool        used_old_u_option = false;
+	bool		used_old_u_option = false;
 
 	memset(options, 0, sizeof *options);
 
 #ifdef HAVE_GETOPT_LONG
 	while ((c = getopt_long(argc, argv, "aAc:d:eEf:F:lh:Hno:p:P:qRsStT:uU:v:VWxX?", long_options, &optindex)) != -1)
-#else /* not HAVE_GETOPT_LONG */
+#else							/* not HAVE_GETOPT_LONG */
+
 	/*
 	 * Be sure to leave the '-' in here, so we can catch accidental long
 	 * options.
 	 */
 	while ((c = getopt(argc, argv, "aAc:d:eEf:F:lh:Hno:p:P:qRsStT:uU:v:VWxX?-")) != -1)
-#endif /* not HAVE_GETOPT_LONG */
+#endif	 /* not HAVE_GETOPT_LONG */
 	{
 		switch (c)
 		{
@@ -426,9 +435,9 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
 			case 'q':
 				SetVariableBool(pset.vars, "QUIET");
 				break;
-            case 'R':
-                pset.popt.topt.recordSep = xstrdup(optarg);
-                break;
+			case 'R':
+				pset.popt.topt.recordSep = xstrdup(optarg);
+				break;
 			case 's':
 				SetVariableBool(pset.vars, "SINGLESTEP");
 				break;
@@ -443,9 +452,10 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
 				break;
 			case 'u':
 				pset.getPassword = true;
-				options->username = "\001"; /* hopefully nobody has that username */
-                /* this option is out */
-                used_old_u_option = true;
+				options->username = "\001";		/* hopefully nobody has
+												 * that username */
+				/* this option is out */
+				used_old_u_option = true;
 				break;
 			case 'U':
 				options->username = optarg;
@@ -462,7 +472,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
 						if (!DeleteVariable(pset.vars, value))
 						{
 							fprintf(stderr, "%s: could not delete variable %s\n",
-                                    pset.progname, value);
+									pset.progname, value);
 							exit(EXIT_FAILURE);
 						}
 					}
@@ -472,7 +482,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
 						if (!SetVariable(pset.vars, value, equal_loc + 1))
 						{
 							fprintf(stderr, "%s: could not set variable %s\n",
-                                    pset.progname, value);
+									pset.progname, value);
 							exit(EXIT_FAILURE);
 						}
 					}
@@ -489,22 +499,22 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
 			case 'x':
 				pset.popt.topt.expanded = true;
 				break;
-            case 'X':
-                options->no_psqlrc = true;
-                break;
+			case 'X':
+				options->no_psqlrc = true;
+				break;
 			case '?':
-                /* Actual help option given */
-                if (strcmp(argv[optind-1], "-?")==0 || strcmp(argv[optind-1], "--help")==0)
-                {
-                    usage();
-                    exit(EXIT_SUCCESS);
-                }
-                /* unknown option reported by getopt */
-                else
-                {
-                    fputs("Try -? for help.\n", stderr);
-                    exit(EXIT_FAILURE);
-                }
+				/* Actual help option given */
+				if (strcmp(argv[optind - 1], "-?") == 0 || strcmp(argv[optind - 1], "--help") == 0)
+				{
+					usage();
+					exit(EXIT_SUCCESS);
+				}
+				/* unknown option reported by getopt */
+				else
+				{
+					fputs("Try -? for help.\n", stderr);
+					exit(EXIT_FAILURE);
+				}
 				break;
 #ifndef HAVE_GETOPT_LONG
 			case '-':
@@ -532,13 +542,13 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
 			options->username = argv[optind];
 		else if (!QUIET())
 			fprintf(stderr, "%s: warning: extra option %s ignored\n",
-                    pset.progname, argv[optind]);
+					pset.progname, argv[optind]);
 
 		optind++;
 	}
 
-    if (used_old_u_option && !QUIET())
-        fprintf(stderr, "%s: Warning: The -u option is deprecated. Use -U.\n", pset.progname);
+	if (used_old_u_option && !QUIET())
+		fprintf(stderr, "%s: Warning: The -u option is deprecated. Use -U.\n", pset.progname);
 
 }
 
@@ -565,7 +575,7 @@ process_psqlrc(void)
 		psqlrc = malloc(strlen(home) + 20);
 		if (!psqlrc)
 		{
-            fprintf(stderr, "%s: out of memory\n", pset.progname);
+			fprintf(stderr, "%s: out of memory\n", pset.progname);
 			exit(EXIT_FAILURE);
 		}
 
@@ -591,41 +601,41 @@ process_psqlrc(void)
 static void
 showVersion(void)
 {
-    puts("psql (PostgreSQL) " PG_RELEASE "." PG_VERSION "." PG_SUBVERSION);
+	puts("psql (PostgreSQL) " PG_RELEASE "." PG_VERSION "." PG_SUBVERSION);
 
 #if defined(USE_READLINE) || defined (USE_HISTORY) || defined(MULTIBYTE)
-    fputs("contains ", stdout);
+	fputs("contains ", stdout);
 
 #ifdef USE_READLINE
-    fputs("readline", stdout);
+	fputs("readline", stdout);
 #define _Feature
 #endif
 
 #ifdef USE_HISTORY
 #ifdef _Feature
-    fputs(", ", stdout);
+	fputs(", ", stdout);
 #else
 #define _Feature
 #endif
-    fputs("history", stdout);
+	fputs("history", stdout);
 #endif
 
 #ifdef MULTIBYTE
 #ifdef _Feature
-    fputs(", ", stdout);
+	fputs(", ", stdout);
 #else
 #define _Feature
 #endif
-    fputs("multibyte", stdout);
+	fputs("multibyte", stdout);
 #endif
-    
+
 #undef _Feature
 
-    puts(" support");
+	puts(" support");
 #endif
 
-    puts("Portions Copyright (c) 1996-2000, PostgreSQL, Inc");
-    puts("Portions Copyright (c) 1996 Regents of the University of California");
-    puts("Read the file COPYRIGHT or use the command \\copyright to see the");
-    puts("usage and distribution terms.");
+	puts("Portions Copyright (c) 1996-2000, PostgreSQL, Inc");
+	puts("Portions Copyright (c) 1996 Regents of the University of California");
+	puts("Read the file COPYRIGHT or use the command \\copyright to see the");
+	puts("usage and distribution terms.");
 }
diff --git a/src/bin/psql/stringutils.c b/src/bin/psql/stringutils.c
index 95b0501027377beda4b6739816c0d70662a74660..215572e5f1f740c1832f8516a17d37558d81d360 100644
--- a/src/bin/psql/stringutils.c
+++ b/src/bin/psql/stringutils.c
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/stringutils.c,v 1.25 2000/02/16 13:15:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/stringutils.c,v 1.26 2000/04/12 17:16:23 momjian Exp $
  */
 #include "postgres.h"
 #include "stringutils.h"
@@ -52,7 +52,7 @@ strtokx(const char *s,
 	char	   *cp = NULL;
 
 #ifndef MULTIBYTE
-    (void)encoding; /*not used*/
+	(void) encoding;			/* not used */
 #endif
 
 	if (s)
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 5aec29dc89c54f36a9894fccd1c2b12c3184a7f9..b7912709e36617eededffc2e26745628f37f48b5 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.16 2000/03/17 05:29:06 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.17 2000/04/12 17:16:23 momjian Exp $
  */
 
 /*-----------
@@ -24,12 +24,12 @@
 
   BUGS:
   * If you split your queries across lines, this whole things gets confused.
-    (To fix this, one would have to read psql's query buffer rather than
-    readline's line buffer, which would require some major revisions of
-    things.)
+	(To fix this, one would have to read psql's query buffer rather than
+	readline's line buffer, which would require some major revisions of
+	things.)
   * Table or attribute names with spaces in it will equally confuse it.
   * Quotes, parenthesis, and other funny characters are not handled all that
-    gracefully.
+	gracefully.
 -------------*/
 
 #include "postgres.h"
@@ -40,7 +40,7 @@
 /* If we don't have this, we might as well forget about the whole thing: */
 #ifdef USE_READLINE
 
-#include <ctype.h> /* toupper */
+#include <ctype.h>				/* toupper */
 #ifdef USE_ASSERT_CHECKING
 #include <assert.h>
 #endif
@@ -51,49 +51,56 @@
 #include "settings.h"
 
 #if defined(HAVE_FILENAME_COMPLETION_FUNCTION) && !defined(HAVE_FILENAME_COMPLETION_FUNCTION_DECL)
-char * filename_completion_function (char *, int);
+char	   *filename_completion_function(char *, int);
+
 #endif
 
 #define BUF_SIZE 2048
-#define ERROR_QUERY_TOO_LONG /* empty */
+#define ERROR_QUERY_TOO_LONG	/* empty */
 
 
 /* Forward declaration of functions */
-static char ** psql_completion(char *text, int start, int end);
-static char * create_command_generator(char *text, int state);
-static char * complete_from_query(char *text, int state);
-static char * complete_from_const(char *text, int state);
-static char * complete_from_list(char *text, int state);
-
-static PGresult * exec_query(char * query);
-char * quote_file_name(char *text, int match_type, char * quote_pointer);
+static char **psql_completion(char *text, int start, int end);
+static char *create_command_generator(char *text, int state);
+static char *complete_from_query(char *text, int state);
+static char *complete_from_const(char *text, int state);
+static char *complete_from_list(char *text, int state);
+
+static PGresult *exec_query(char *query);
+char	   *quote_file_name(char *text, int match_type, char *quote_pointer);
+
 /*static char * dequote_file_name(char *text, char quote_char);*/
-static char * previous_word(int point, int skip);
+static char *previous_word(int point, int skip);
 
 /* These variables are used to pass information into the completion functions.
    Realizing that this is the cardinal sin of programming, I don't see a better
    way. */
-char * completion_charp;      /* if you need to pass a string */
-char ** completion_charpp;    /* if you need to pass a list of strings */
-char * completion_info_charp; /* if you need to pass another string */
+char	   *completion_charp;	/* if you need to pass a string */
+char	  **completion_charpp;	/* if you need to pass a list of strings */
+char	   *completion_info_charp;		/* if you need to pass another
+										 * string */
 
 /* Store how many records from a database query we want to return at most
 (implemented via SELECT ... LIMIT xx). */
-static int completion_max_records;
+static int	completion_max_records;
 
 
 /* Initialize the readline library for our purposes. */
-void initialize_readline(void)
+void
+initialize_readline(void)
 {
-    rl_readline_name = pset.progname;
-    rl_attempted_completion_function = psql_completion;
+	rl_readline_name = pset.progname;
+	rl_attempted_completion_function = psql_completion;
+
+	rl_special_prefixes = "()'";
+	rl_basic_word_break_characters = "\t\n\"'`@$><=;|&{ ";
 
-    rl_special_prefixes = "()'";
-    rl_basic_word_break_characters = "\t\n\"'`@$><=;|&{ ";
+	completion_max_records = 100;
 
-    completion_max_records = 100;
-    /* There is a variable rl_completion_query_items for this but apparently
-       it's not defined everywhere. */
+	/*
+	 * There is a variable rl_completion_query_items for this but
+	 * apparently it's not defined everywhere.
+	 */
 }
 
 
@@ -103,27 +110,29 @@ void initialize_readline(void)
    If you change the order here or insert things, make sure to also adjust the
    referencing macros below.
 */
-typedef struct {
-    char * name;
-    char * query;
+typedef struct
+{
+	char	   *name;
+	char	   *query;
 } pgsql_thing_t;
 
 pgsql_thing_t words_after_create[] = {
-    { "AGGREGATE", "SELECT distinct aggname FROM pg_aggregate WHERE substr(aggname,1,%d)='%s'" },
-    { "DATABASE",  "SELECT datname FROM pg_database WHERE substr(datname,1,%d)='%s'" },
-    { "FUNCTION",  "SELECT distinct proname FROM pg_proc WHERE substr(proname,1,%d)='%s'" },
-    { "INDEX",     "SELECT relname FROM pg_class WHERE relkind='i' and substr(relname,1,%d)='%s'" },
-    { "OPERATOR",  NULL }, /* Querying for this is probably not such a good idea. */
-    { "RULE",      "SELECT rulename FROM pg_rules WHERE substr(rulename,1,%d)='%s'" },
-    { "SEQUENCE",  "SELECT relname FROM pg_class WHERE relkind='S' and substr(relname,1,%d)='%s'" },
-    { "TABLE",     "SELECT relname FROM pg_class WHERE relkind='r' and substr(relname,1,%d)='%s'" },
-    { "TEMP",      NULL }, /* for CREATE TEMP TABLE ... */
-    { "TRIGGER",   "SELECT tgname FROM pg_trigger WHERE substr(tgname,1,%d)='%s'" },
-    { "TYPE",      "SELECT typname FROM pg_type WHERE substr(typname,1,%d)='%s'" },
-    { "UNIQUE",    NULL }, /* for CREATE UNIQUE INDEX ... */
-    { "USER",      "SELECT usename FROM pg_user WHERE substr(usename,1,%d)='%s'" },
-    { "VIEW",      "SELECT viewname FROM pg_views WHERE substr(viewname,1,%d)='%s'" },
-    { NULL, NULL } /* end of list */
+	{"AGGREGATE", "SELECT distinct aggname FROM pg_aggregate WHERE substr(aggname,1,%d)='%s'"},
+	{"DATABASE", "SELECT datname FROM pg_database WHERE substr(datname,1,%d)='%s'"},
+	{"FUNCTION", "SELECT distinct proname FROM pg_proc WHERE substr(proname,1,%d)='%s'"},
+	{"INDEX", "SELECT relname FROM pg_class WHERE relkind='i' and substr(relname,1,%d)='%s'"},
+	{"OPERATOR", NULL},			/* Querying for this is probably not such
+								 * a good idea. */
+	{"RULE", "SELECT rulename FROM pg_rules WHERE substr(rulename,1,%d)='%s'"},
+	{"SEQUENCE", "SELECT relname FROM pg_class WHERE relkind='S' and substr(relname,1,%d)='%s'"},
+	{"TABLE", "SELECT relname FROM pg_class WHERE relkind='r' and substr(relname,1,%d)='%s'"},
+	{"TEMP", NULL},				/* for CREATE TEMP TABLE ... */
+	{"TRIGGER", "SELECT tgname FROM pg_trigger WHERE substr(tgname,1,%d)='%s'"},
+	{"TYPE", "SELECT typname FROM pg_type WHERE substr(typname,1,%d)='%s'"},
+	{"UNIQUE", NULL},			/* for CREATE UNIQUE INDEX ... */
+	{"USER", "SELECT usename FROM pg_user WHERE substr(usename,1,%d)='%s'"},
+	{"VIEW", "SELECT viewname FROM pg_views WHERE substr(viewname,1,%d)='%s'"},
+	{NULL, NULL}				/* end of list */
 };
 
 
@@ -157,22 +166,27 @@ do {completion_charp = Query_for_list_of_attributes; completion_info_charp = tab
    is some partially obscure list format that can be generated by the readline
    libraries completion_matches() function, so we don't have to worry about it.
 */
-char ** psql_completion(char *text, int start, int end)
+char	  **
+psql_completion(char *text, int start, int end)
 {
-    /* This is the variable we'll return. */
-    char **matches = NULL;
-    /* These are going to contain some scannage of the input line. */
-    char *prev_wd, *prev2_wd, *prev3_wd, *prev4_wd;
-
-    static char * sql_commands[] = {
-        "ABORT", "ALTER", "BEGIN", "CLOSE", "CLUSTER", "COMMIT", "COPY",
-        "CREATE", "DECLARE", "DELETE", "DROP", "EXPLAIN", "FETCH", "GRANT",
-        "INSERT", "LISTEN", "LOAD", "LOCK", "MOVE", "NOTIFY", "RESET",
-        "REVOKE", "ROLLBACK", "SELECT", "SET", "SHOW", "UNLISTEN", "UPDATE",
-        "VACUUM", NULL
-    };
-
-    static char * pgsql_variables[] = {
+	/* This is the variable we'll return. */
+	char	  **matches = NULL;
+
+	/* These are going to contain some scannage of the input line. */
+	char	   *prev_wd,
+			   *prev2_wd,
+			   *prev3_wd,
+			   *prev4_wd;
+
+	static char *sql_commands[] = {
+		"ABORT", "ALTER", "BEGIN", "CLOSE", "CLUSTER", "COMMIT", "COPY",
+		"CREATE", "DECLARE", "DELETE", "DROP", "EXPLAIN", "FETCH", "GRANT",
+		"INSERT", "LISTEN", "LOAD", "LOCK", "MOVE", "NOTIFY", "RESET",
+		"REVOKE", "ROLLBACK", "SELECT", "SET", "SHOW", "UNLISTEN", "UPDATE",
+		"VACUUM", NULL
+	};
+
+	static char *pgsql_variables[] = {
 		/* these SET arguments are known in gram.y */
 		"TRANSACTION ISOLATION LEVEL",
 		"NAMES",
@@ -198,390 +212,468 @@ char ** psql_completion(char *text, int start, int end)
 		"max_expr_depth",
 		"XactIsoLevel",
 		"PG_Options",
-        NULL
-    };
+		NULL
+	};
 
-    static char * backslash_commands[] = {
-        "\\connect", "\\copy", "\\d", "\\di", "\\di", "\\ds", "\\dS", "\\dv",
-        "\\da", "\\df", "\\do", "\\dt", "\\e", "\\echo", "\\encoding",
-        "\\g", "\\h", "\\i", "\\l",
-        "\\lo_import", "\\lo_export", "\\lo_list", "\\lo_unlink",
-        "\\o", "\\p", "\\pset", "\\q", "\\qecho", "\\r", "\\set", "\\t", "\\unset",
-        "\\x", "\\w", "\\z", "\\!", NULL
-    };
+	static char *backslash_commands[] = {
+		"\\connect", "\\copy", "\\d", "\\di", "\\di", "\\ds", "\\dS", "\\dv",
+		"\\da", "\\df", "\\do", "\\dt", "\\e", "\\echo", "\\encoding",
+		"\\g", "\\h", "\\i", "\\l",
+		"\\lo_import", "\\lo_export", "\\lo_list", "\\lo_unlink",
+		"\\o", "\\p", "\\pset", "\\q", "\\qecho", "\\r", "\\set", "\\t", "\\unset",
+		"\\x", "\\w", "\\z", "\\!", NULL
+	};
 
-    (void)end; /* not used */
+	(void) end;					/* not used */
 
 #ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
-        rl_completion_append_character = ' ';
+	rl_completion_append_character = ' ';
 #endif
 
-    /* Clear a few things. */
-    completion_charp = NULL;
-    completion_charpp = NULL;
-    completion_info_charp = NULL;
-
-    /* Scan the input line before our current position for the last four words.
-       According to those we'll make some smart decisions on what the user is
-       probably intending to type.
-       TODO: Use strtokx() to do this.
-    */
-    prev_wd = previous_word(start,0);
-    prev2_wd = previous_word(start,1);
-    prev3_wd = previous_word(start,2);
-    prev4_wd = previous_word(start,3);
-
-    /* If a backslash command was started, continue */
-    if (text[0]=='\\')
-        COMPLETE_WITH_LIST(backslash_commands);
-
-    /* If no previous word, suggest one of the basic sql commands */
-    else if (!prev_wd)
-        COMPLETE_WITH_LIST(sql_commands);
+	/* Clear a few things. */
+	completion_charp = NULL;
+	completion_charpp = NULL;
+	completion_info_charp = NULL;
+
+	/*
+	 * Scan the input line before our current position for the last four
+	 * words. According to those we'll make some smart decisions on what
+	 * the user is probably intending to type. TODO: Use strtokx() to do
+	 * this.
+	 */
+	prev_wd = previous_word(start, 0);
+	prev2_wd = previous_word(start, 1);
+	prev3_wd = previous_word(start, 2);
+	prev4_wd = previous_word(start, 3);
+
+	/* If a backslash command was started, continue */
+	if (text[0] == '\\')
+		COMPLETE_WITH_LIST(backslash_commands);
+
+	/* If no previous word, suggest one of the basic sql commands */
+	else if (!prev_wd)
+		COMPLETE_WITH_LIST(sql_commands);
 
 /* CREATE or DROP */
-    /* complete with something you can create or drop */
-    else if( strcasecmp(prev_wd, "CREATE") == 0 || strcasecmp(prev_wd, "DROP") == 0 )
-        matches = completion_matches(text, create_command_generator);
+	/* complete with something you can create or drop */
+	else if (strcasecmp(prev_wd, "CREATE") == 0 || strcasecmp(prev_wd, "DROP") == 0)
+		matches = completion_matches(text, create_command_generator);
 
 /* ALTER */
-    /* complete with what you can alter (TABLE or USER) */
-    else if( strcasecmp(prev_wd, "ALTER") == 0 ) {
-        char * list_ALTER[] = { "TABLE", "USER", NULL };
-        COMPLETE_WITH_LIST(list_ALTER);
-    }
-    /* If we detect ALTER TABLE <name>, suggest either "ADD" or "RENAME" */
-    else if( strcasecmp(prev3_wd, "ALTER")==0 && strcasecmp(prev2_wd, "TABLE")==0 ) {
-        char * list_ALTER2[] = { "ADD", "RENAME", NULL };
-        COMPLETE_WITH_LIST(list_ALTER2);
-    }
-    /* If we have TABLE <sth> ADD|RENAME, provide list of columns */
-    else if( strcasecmp(prev3_wd, "TABLE")==0 &&
-             (strcasecmp(prev_wd,"ADD")==0 || strcasecmp(prev_wd,"RENAME")==0) )
-        COMPLETE_WITH_ATTR(prev2_wd);
+	/* complete with what you can alter (TABLE or USER) */
+	else if (strcasecmp(prev_wd, "ALTER") == 0)
+	{
+		char	   *list_ALTER[] = {"TABLE", "USER", NULL};
+
+		COMPLETE_WITH_LIST(list_ALTER);
+	}
+	/* If we detect ALTER TABLE <name>, suggest either "ADD" or "RENAME" */
+	else if (strcasecmp(prev3_wd, "ALTER") == 0 && strcasecmp(prev2_wd, "TABLE") == 0)
+	{
+		char	   *list_ALTER2[] = {"ADD", "RENAME", NULL};
+
+		COMPLETE_WITH_LIST(list_ALTER2);
+	}
+	/* If we have TABLE <sth> ADD|RENAME, provide list of columns */
+	else if (strcasecmp(prev3_wd, "TABLE") == 0 &&
+			 (strcasecmp(prev_wd, "ADD") == 0 || strcasecmp(prev_wd, "RENAME") == 0))
+		COMPLETE_WITH_ATTR(prev2_wd);
 
 /* CLUSTER */
-    /* If the previous word is CLUSTER, produce list of indexes. */
-    else if( strcasecmp(prev_wd, "CLUSTER") == 0 )
-        COMPLETE_WITH_QUERY(Query_for_list_of_indexes);
-    /* If we have CLUSTER <sth>, then add "ON" */
-    else if( strcasecmp(prev2_wd, "CLUSTER") == 0 )
-        COMPLETE_WITH_CONST("ON");
-    /* If we have CLUSTER <sth> ON, then add the correct tablename as well. */
-    else if ( strcasecmp(prev3_wd, "CLUSTER")==0 && strcasecmp(prev_wd, "ON")==0 ) {
-        char query_buffer[BUF_SIZE]; /* Some room to build queries. */
-        if(snprintf(query_buffer, BUF_SIZE,
-                    "SELECT c1.relname FROM pg_class c1, pg_class c2, pg_index i WHERE c1.oid=i.indrelid and i.indexrelid=c2.oid and c2.relname='%s'",
-                    prev2_wd) == -1)
-            ERROR_QUERY_TOO_LONG;
-        else
-            COMPLETE_WITH_QUERY(query_buffer);
-    }
+	/* If the previous word is CLUSTER, produce list of indexes. */
+	else if (strcasecmp(prev_wd, "CLUSTER") == 0)
+		COMPLETE_WITH_QUERY(Query_for_list_of_indexes);
+	/* If we have CLUSTER <sth>, then add "ON" */
+	else if (strcasecmp(prev2_wd, "CLUSTER") == 0)
+		COMPLETE_WITH_CONST("ON");
+
+	/*
+	 * If we have CLUSTER <sth> ON, then add the correct tablename as
+	 * well.
+	 */
+	else if (strcasecmp(prev3_wd, "CLUSTER") == 0 && strcasecmp(prev_wd, "ON") == 0)
+	{
+		char		query_buffer[BUF_SIZE];		/* Some room to build
+												 * queries. */
+
+		if (snprintf(query_buffer, BUF_SIZE,
+					 "SELECT c1.relname FROM pg_class c1, pg_class c2, pg_index i WHERE c1.oid=i.indrelid and i.indexrelid=c2.oid and c2.relname='%s'",
+					 prev2_wd) == -1)
+			ERROR_QUERY_TOO_LONG;
+		else
+			COMPLETE_WITH_QUERY(query_buffer);
+	}
 
 /* COPY */
-    /* If we have COPY [BINARY] (which you'd have to type yourself), offer list of tables
-       (Also cover the analogous backslash command) */
-    else if( strcasecmp(prev_wd, "COPY")==0 ||
-             strcasecmp(prev_wd, "\\copy")==0 ||
-             (strcasecmp(prev2_wd,"COPY")==0 && strcasecmp(prev_wd,"BINARY")==0)  )
-        COMPLETE_WITH_QUERY(Query_for_list_of_tables);
-    /* If we have COPY|BINARY <sth>, complete it with "TO" or "FROM" */
-    else if( strcasecmp(prev2_wd, "COPY")==0 ||
-             strcasecmp(prev2_wd, "\\copy")==0 ||
-             strcasecmp(prev2_wd, "BINARY")==0 ) {
-        char * list_FROMTO[] = { "FROM", "TO", NULL };
-        COMPLETE_WITH_LIST(list_FROMTO);
-    }
+
+	/*
+	 * If we have COPY [BINARY] (which you'd have to type yourself), offer
+	 * list of tables (Also cover the analogous backslash command)
+	 */
+	else if (strcasecmp(prev_wd, "COPY") == 0 ||
+			 strcasecmp(prev_wd, "\\copy") == 0 ||
+			 (strcasecmp(prev2_wd, "COPY") == 0 && strcasecmp(prev_wd, "BINARY") == 0))
+		COMPLETE_WITH_QUERY(Query_for_list_of_tables);
+	/* If we have COPY|BINARY <sth>, complete it with "TO" or "FROM" */
+	else if (strcasecmp(prev2_wd, "COPY") == 0 ||
+			 strcasecmp(prev2_wd, "\\copy") == 0 ||
+			 strcasecmp(prev2_wd, "BINARY") == 0)
+	{
+		char	   *list_FROMTO[] = {"FROM", "TO", NULL};
+
+		COMPLETE_WITH_LIST(list_FROMTO);
+	}
 
 /* CREATE INDEX */
-    /* First off we complete CREATE UNIQUE with "INDEX" */
-    else if( strcasecmp(prev2_wd, "CREATE")==0 && strcasecmp(prev_wd, "UNIQUE")==0 )
-        COMPLETE_WITH_CONST("INDEX");
-    /* If we have CREATE|UNIQUE INDEX <sth>, then add "ON" */
-    else if( strcasecmp(prev2_wd, "INDEX") == 0 &&
-             (strcasecmp(prev3_wd,"CREATE")==0 || strcasecmp(prev3_wd,"UNIQUE")==0) )
-        COMPLETE_WITH_CONST("ON");
-    /* Complete ... INDEX <name> ON with a list of tables  */
-    else if( (strcasecmp(prev3_wd, "INDEX")==0 && strcasecmp(prev_wd, "ON")==0) || (0) )
-        COMPLETE_WITH_QUERY(Query_for_list_of_tables);
-    /* Complete INDEX <name> ON <table> with a list of table columns (which should really be in parens) */
-    else if( (strcasecmp(prev4_wd, "INDEX")==0 && strcasecmp(prev2_wd, "ON")==0) )
-        COMPLETE_WITH_ATTR(prev_wd);
-    /* same if you put in USING */
-    else if ((strcasecmp(prev4_wd,"ON")==0 && strcasecmp(prev2_wd,"USING")==0) )
-        COMPLETE_WITH_ATTR(prev3_wd);
-    /* Complete USING with an index method */
-    else if( strcasecmp(prev_wd, "USING")==0 ) {
-        char * index_mth[] = { "BTREE", "RTREE", "HASH", NULL };
-        COMPLETE_WITH_LIST(index_mth);
-    }
-    
+	/* First off we complete CREATE UNIQUE with "INDEX" */
+	else if (strcasecmp(prev2_wd, "CREATE") == 0 && strcasecmp(prev_wd, "UNIQUE") == 0)
+		COMPLETE_WITH_CONST("INDEX");
+	/* If we have CREATE|UNIQUE INDEX <sth>, then add "ON" */
+	else if (strcasecmp(prev2_wd, "INDEX") == 0 &&
+			 (strcasecmp(prev3_wd, "CREATE") == 0 || strcasecmp(prev3_wd, "UNIQUE") == 0))
+		COMPLETE_WITH_CONST("ON");
+	/* Complete ... INDEX <name> ON with a list of tables  */
+	else if ((strcasecmp(prev3_wd, "INDEX") == 0 && strcasecmp(prev_wd, "ON") == 0) || (0))
+		COMPLETE_WITH_QUERY(Query_for_list_of_tables);
+
+	/*
+	 * Complete INDEX <name> ON <table> with a list of table columns
+	 * (which should really be in parens)
+	 */
+	else if ((strcasecmp(prev4_wd, "INDEX") == 0 && strcasecmp(prev2_wd, "ON") == 0))
+		COMPLETE_WITH_ATTR(prev_wd);
+	/* same if you put in USING */
+	else if ((strcasecmp(prev4_wd, "ON") == 0 && strcasecmp(prev2_wd, "USING") == 0))
+		COMPLETE_WITH_ATTR(prev3_wd);
+	/* Complete USING with an index method */
+	else if (strcasecmp(prev_wd, "USING") == 0)
+	{
+		char	   *index_mth[] = {"BTREE", "RTREE", "HASH", NULL};
+
+		COMPLETE_WITH_LIST(index_mth);
+	}
+
 /* CREATE RULE */
-    /* Complete "CREATE RULE <sth>" with "AS" */
-    else if( strcasecmp(prev3_wd,"CREATE")==0 && strcasecmp(prev2_wd,"RULE")==0 )
-        COMPLETE_WITH_CONST("AS");
-    /* Complete "CREATE RULE <sth> AS with "ON" */
-    else if( strcasecmp(prev4_wd,"CREATE")==0 &&
-             strcasecmp(prev3_wd,"RULE")==0 &&
-             strcasecmp(prev_wd,"AS")==0 )
-        COMPLETE_WITH_CONST("ON");
-    /* Complete "RULE * AS ON" with SELECT|UPDATE|DELETE|INSERT */
-    else if( strcasecmp(prev4_wd,"RULE")==0 &&
-             strcasecmp(prev2_wd,"AS")==0 &&
-             strcasecmp(prev_wd,"ON")==0 ) {
-        char * rule_events[] = { "SELECT", "UPDATE", "INSERT", "DELETE", NULL };
-        COMPLETE_WITH_LIST(rule_events);
-    }
-    /* Complete "AS ON <sth with a 'T' :)>" with a "TO" */
-    else if( strcasecmp(prev3_wd,"AS")==0 &&
-             strcasecmp(prev2_wd,"ON")==0 &&
-             (toupper(prev_wd[4])=='T' || toupper(prev_wd[5])=='T') )
-        COMPLETE_WITH_CONST("TO");
-    /* Complete "AS ON <sth> TO" with a table name */
-    else if( strcasecmp(prev4_wd,"AS")==0 &&
-             strcasecmp(prev3_wd,"ON")==0 &&
-             strcasecmp(prev_wd,"TO")==0 )
-        COMPLETE_WITH_QUERY(Query_for_list_of_tables);
+	/* Complete "CREATE RULE <sth>" with "AS" */
+	else if (strcasecmp(prev3_wd, "CREATE") == 0 && strcasecmp(prev2_wd, "RULE") == 0)
+		COMPLETE_WITH_CONST("AS");
+	/* Complete "CREATE RULE <sth> AS with "ON" */
+	else if (strcasecmp(prev4_wd, "CREATE") == 0 &&
+			 strcasecmp(prev3_wd, "RULE") == 0 &&
+			 strcasecmp(prev_wd, "AS") == 0)
+		COMPLETE_WITH_CONST("ON");
+	/* Complete "RULE * AS ON" with SELECT|UPDATE|DELETE|INSERT */
+	else if (strcasecmp(prev4_wd, "RULE") == 0 &&
+			 strcasecmp(prev2_wd, "AS") == 0 &&
+			 strcasecmp(prev_wd, "ON") == 0)
+	{
+		char	   *rule_events[] = {"SELECT", "UPDATE", "INSERT", "DELETE", NULL};
+
+		COMPLETE_WITH_LIST(rule_events);
+	}
+	/* Complete "AS ON <sth with a 'T' :)>" with a "TO" */
+	else if (strcasecmp(prev3_wd, "AS") == 0 &&
+			 strcasecmp(prev2_wd, "ON") == 0 &&
+			 (toupper(prev_wd[4]) == 'T' || toupper(prev_wd[5]) == 'T'))
+		COMPLETE_WITH_CONST("TO");
+	/* Complete "AS ON <sth> TO" with a table name */
+	else if (strcasecmp(prev4_wd, "AS") == 0 &&
+			 strcasecmp(prev3_wd, "ON") == 0 &&
+			 strcasecmp(prev_wd, "TO") == 0)
+		COMPLETE_WITH_QUERY(Query_for_list_of_tables);
 
 /* CREATE TABLE */
-    /* Complete CREATE TEMP with "TABLE" */
-    else if( strcasecmp(prev2_wd, "CREATE")==0 && strcasecmp(prev_wd, "TEMP")==0 )
-        COMPLETE_WITH_CONST("TABLE");
+	/* Complete CREATE TEMP with "TABLE" */
+	else if (strcasecmp(prev2_wd, "CREATE") == 0 && strcasecmp(prev_wd, "TEMP") == 0)
+		COMPLETE_WITH_CONST("TABLE");
 
 /* CREATE TRIGGER */
-    /* is on the agenda . . . */
+	/* is on the agenda . . . */
 
 /* CREATE VIEW */
-    /* Complete "CREATE VIEW <name>" with "AS" */
-    else if( strcasecmp(prev3_wd,"CREATE")==0 && strcasecmp(prev2_wd,"VIEW")==0 )
-        COMPLETE_WITH_CONST("AS");
-    /* Complete "CREATE VIEW <sth> AS with "SELECT" */
-    else if( strcasecmp(prev4_wd,"CREATE")==0 &&
-             strcasecmp(prev3_wd,"VIEW")==0 &&
-             strcasecmp(prev_wd,"AS")==0 )
-        COMPLETE_WITH_CONST("SELECT");
+	/* Complete "CREATE VIEW <name>" with "AS" */
+	else if (strcasecmp(prev3_wd, "CREATE") == 0 && strcasecmp(prev2_wd, "VIEW") == 0)
+		COMPLETE_WITH_CONST("AS");
+	/* Complete "CREATE VIEW <sth> AS with "SELECT" */
+	else if (strcasecmp(prev4_wd, "CREATE") == 0 &&
+			 strcasecmp(prev3_wd, "VIEW") == 0 &&
+			 strcasecmp(prev_wd, "AS") == 0)
+		COMPLETE_WITH_CONST("SELECT");
 
 /* DELETE */
-    /* Complete DELETE with FROM (only if the word before that is not "ON" (cf.
-       rules) or "BEFORE" or "AFTER" (cf. triggers) ) */
-    else if( strcasecmp(prev_wd,"DELETE")==0 &&
-             !(strcasecmp(prev2_wd,"ON")==0 ||
-               strcasecmp(prev2_wd,"BEFORE")==0 ||
-               strcasecmp(prev2_wd,"AFTER")==0) )
-        COMPLETE_WITH_CONST("FROM");
-    /* Complete DELETE FROM with a list of tables */
-    else if( strcasecmp(prev2_wd,"DELETE")==0 && strcasecmp(prev_wd,"FROM")==0 )
-        COMPLETE_WITH_QUERY(Query_for_list_of_tables);
-    /* Complete DELETE FROM <table> with "WHERE" (perhaps a safe idea?) */
-    else if( strcasecmp(prev3_wd,"DELETE")==0 && strcasecmp(prev2_wd,"FROM")==0 )
-        COMPLETE_WITH_CONST("WHERE");
+
+	/*
+	 * Complete DELETE with FROM (only if the word before that is not "ON"
+	 * (cf. rules) or "BEFORE" or "AFTER" (cf. triggers) )
+	 */
+	else if (strcasecmp(prev_wd, "DELETE") == 0 &&
+			 !(strcasecmp(prev2_wd, "ON") == 0 ||
+			   strcasecmp(prev2_wd, "BEFORE") == 0 ||
+			   strcasecmp(prev2_wd, "AFTER") == 0))
+		COMPLETE_WITH_CONST("FROM");
+	/* Complete DELETE FROM with a list of tables */
+	else if (strcasecmp(prev2_wd, "DELETE") == 0 && strcasecmp(prev_wd, "FROM") == 0)
+		COMPLETE_WITH_QUERY(Query_for_list_of_tables);
+	/* Complete DELETE FROM <table> with "WHERE" (perhaps a safe idea?) */
+	else if (strcasecmp(prev3_wd, "DELETE") == 0 && strcasecmp(prev2_wd, "FROM") == 0)
+		COMPLETE_WITH_CONST("WHERE");
 
 /* EXPLAIN */
-    /* Complete EXPLAIN [VERBOSE] (which you'd have to type yourself) with the list of SQL commands */
-    else if( strcasecmp(prev_wd,"EXPLAIN")==0 ||
-             (strcasecmp(prev2_wd,"EXPLAIN")==0 && strcasecmp(prev_wd,"VERBOSE")==0) )
-        COMPLETE_WITH_LIST(sql_commands);
+
+	/*
+	 * Complete EXPLAIN [VERBOSE] (which you'd have to type yourself) with
+	 * the list of SQL commands
+	 */
+	else if (strcasecmp(prev_wd, "EXPLAIN") == 0 ||
+			 (strcasecmp(prev2_wd, "EXPLAIN") == 0 && strcasecmp(prev_wd, "VERBOSE") == 0))
+		COMPLETE_WITH_LIST(sql_commands);
 
 /* FETCH && MOVE */
-    /* Complete FETCH with one of FORWARD, BACKWARD, RELATIVE */
-    else if( strcasecmp(prev_wd,"FETCH")==0 || strcasecmp(prev_wd,"MOVE")==0 ) {
-        char * list_FETCH1[] = { "FORWARD", "BACKWARD", "RELATIVE", NULL };
-        COMPLETE_WITH_LIST(list_FETCH1);
-    }
-    /* Complete FETCH <sth> with one of ALL, NEXT, PRIOR */
-    else if( strcasecmp(prev2_wd,"FETCH")==0 || strcasecmp(prev2_wd,"MOVE")==0 ) {
-        char * list_FETCH2[] = { "ALL", "NEXT", "PRIOR", NULL };
-        COMPLETE_WITH_LIST(list_FETCH2);
-    }
-    /* Complete FETCH <sth1> <sth2> with "FROM" or "TO".
-       (Is there a difference? If not, remove one.) */
-    else if( strcasecmp(prev3_wd,"FETCH")==0 || strcasecmp(prev3_wd,"MOVE")==0 ) {
-        char * list_FROMTO[] = { "FROM", "TO", NULL };
-        COMPLETE_WITH_LIST(list_FROMTO);
-    }
+	/* Complete FETCH with one of FORWARD, BACKWARD, RELATIVE */
+	else if (strcasecmp(prev_wd, "FETCH") == 0 || strcasecmp(prev_wd, "MOVE") == 0)
+	{
+		char	   *list_FETCH1[] = {"FORWARD", "BACKWARD", "RELATIVE", NULL};
+
+		COMPLETE_WITH_LIST(list_FETCH1);
+	}
+	/* Complete FETCH <sth> with one of ALL, NEXT, PRIOR */
+	else if (strcasecmp(prev2_wd, "FETCH") == 0 || strcasecmp(prev2_wd, "MOVE") == 0)
+	{
+		char	   *list_FETCH2[] = {"ALL", "NEXT", "PRIOR", NULL};
+
+		COMPLETE_WITH_LIST(list_FETCH2);
+	}
+
+	/*
+	 * Complete FETCH <sth1> <sth2> with "FROM" or "TO". (Is there a
+	 * difference? If not, remove one.)
+	 */
+	else if (strcasecmp(prev3_wd, "FETCH") == 0 || strcasecmp(prev3_wd, "MOVE") == 0)
+	{
+		char	   *list_FROMTO[] = {"FROM", "TO", NULL};
+
+		COMPLETE_WITH_LIST(list_FROMTO);
+	}
 
 /* GRANT && REVOKE*/
-    /* Complete GRANT/REVOKE with a list of privileges */
-    else if( strcasecmp(prev_wd,"GRANT")==0 || strcasecmp(prev_wd,"REVOKE")==0 ) {
-        char * list_privileg[] = { "SELECT", "INSERT", "UPDATE", "DELETE", "RULE", "ALL", NULL };
-        COMPLETE_WITH_LIST(list_privileg);
-    }
-    /* Complete GRANT/REVOKE <sth> with "ON" */
-    else if( strcasecmp(prev2_wd,"GRANT")==0 || strcasecmp(prev2_wd,"REVOKE")==0 )
-        COMPLETE_WITH_CONST("ON");
-    /* Complete GRANT/REVOKE <sth> ON with a list of tables, views, sequences, and indexes */
-    else if( (strcasecmp(prev3_wd,"GRANT")==0 || strcasecmp(prev3_wd,"REVOKE")==0) &&
-             strcasecmp(prev_wd,"ON")==0 )
-        COMPLETE_WITH_QUERY("SELECT relname FROM pg_class WHERE relkind in ('r','i','s') and substr(relname,1,%d)='%s'");
-    /* Complete "GRANT * ON * " with "TO" */
-    else if( strcasecmp(prev4_wd,"GRANT")==0 && strcasecmp(prev2_wd,"ON")==0 )
-        COMPLETE_WITH_CONST("TO");
-    /* Complete "REVOKE * ON * " with "FROM" */
-    else if( strcasecmp(prev4_wd,"REVOKE")==0 && strcasecmp(prev2_wd,"ON")==0 )
-        COMPLETE_WITH_CONST("FROM");
-    /* TODO: to complete with user name we need prev5_wd -- wait for a more general solution there */
+	/* Complete GRANT/REVOKE with a list of privileges */
+	else if (strcasecmp(prev_wd, "GRANT") == 0 || strcasecmp(prev_wd, "REVOKE") == 0)
+	{
+		char	   *list_privileg[] = {"SELECT", "INSERT", "UPDATE", "DELETE", "RULE", "ALL", NULL};
+
+		COMPLETE_WITH_LIST(list_privileg);
+	}
+	/* Complete GRANT/REVOKE <sth> with "ON" */
+	else if (strcasecmp(prev2_wd, "GRANT") == 0 || strcasecmp(prev2_wd, "REVOKE") == 0)
+		COMPLETE_WITH_CONST("ON");
+
+	/*
+	 * Complete GRANT/REVOKE <sth> ON with a list of tables, views,
+	 * sequences, and indexes
+	 */
+	else if ((strcasecmp(prev3_wd, "GRANT") == 0 || strcasecmp(prev3_wd, "REVOKE") == 0) &&
+			 strcasecmp(prev_wd, "ON") == 0)
+		COMPLETE_WITH_QUERY("SELECT relname FROM pg_class WHERE relkind in ('r','i','s') and substr(relname,1,%d)='%s'");
+	/* Complete "GRANT * ON * " with "TO" */
+	else if (strcasecmp(prev4_wd, "GRANT") == 0 && strcasecmp(prev2_wd, "ON") == 0)
+		COMPLETE_WITH_CONST("TO");
+	/* Complete "REVOKE * ON * " with "FROM" */
+	else if (strcasecmp(prev4_wd, "REVOKE") == 0 && strcasecmp(prev2_wd, "ON") == 0)
+		COMPLETE_WITH_CONST("FROM");
+
+	/*
+	 * TODO: to complete with user name we need prev5_wd -- wait for a
+	 * more general solution there
+	 */
 
 /* INSERT */
-    /* Complete INSERT with "INTO" */
-    else if( strcasecmp(prev_wd,"INSERT")==0 )
-        COMPLETE_WITH_CONST("INTO");
-    /* Complete INSERT INTO with table names */
-    else if( strcasecmp(prev2_wd, "INSERT")==0 && strcasecmp(prev_wd,"INTO")==0 )
-      	COMPLETE_WITH_QUERY(Query_for_list_of_tables);
-    /* Complete INSERT INTO <table> with "VALUES" or "SELECT" */
-    else if( strcasecmp(prev3_wd, "INSERT")==0 && strcasecmp(prev2_wd,"INTO")==0 ) {
-        char * list_INSERT[] = { "SELECT", "VALUES", NULL };
-        COMPLETE_WITH_LIST(list_INSERT);
-    }
-    /* Insert an open parenthesis after "VALUES" */
-    else if( strcasecmp(prev_wd,"VALUES")==0 )
-        COMPLETE_WITH_CONST("(");
+	/* Complete INSERT with "INTO" */
+	else if (strcasecmp(prev_wd, "INSERT") == 0)
+		COMPLETE_WITH_CONST("INTO");
+	/* Complete INSERT INTO with table names */
+	else if (strcasecmp(prev2_wd, "INSERT") == 0 && strcasecmp(prev_wd, "INTO") == 0)
+		COMPLETE_WITH_QUERY(Query_for_list_of_tables);
+	/* Complete INSERT INTO <table> with "VALUES" or "SELECT" */
+	else if (strcasecmp(prev3_wd, "INSERT") == 0 && strcasecmp(prev2_wd, "INTO") == 0)
+	{
+		char	   *list_INSERT[] = {"SELECT", "VALUES", NULL};
+
+		COMPLETE_WITH_LIST(list_INSERT);
+	}
+	/* Insert an open parenthesis after "VALUES" */
+	else if (strcasecmp(prev_wd, "VALUES") == 0)
+		COMPLETE_WITH_CONST("(");
 
 /* LOCK */
-    /* Complete with list of tables */
-    else if( strcasecmp(prev_wd, "LOCK") == 0 )
-      	COMPLETE_WITH_QUERY(Query_for_list_of_tables);
-    /* (If you want more with LOCK, you better think about it yourself.) */
+	/* Complete with list of tables */
+	else if (strcasecmp(prev_wd, "LOCK") == 0)
+		COMPLETE_WITH_QUERY(Query_for_list_of_tables);
+	/* (If you want more with LOCK, you better think about it yourself.) */
 
 /* SELECT */
-    /* naah . . . */
+	/* naah . . . */
 
 /* SET, RESET, SHOW */
-    /* Complete with a variable name */
-    else if( (strcasecmp(prev_wd,"SET")==0 && strcasecmp(prev3_wd,"UPDATE")!=0) ||
-             strcasecmp(prev_wd,"RESET")==0 ||
-             strcasecmp(prev_wd,"SHOW")==0 )
-        COMPLETE_WITH_LIST(pgsql_variables);
-    /* Complete "SET TRANSACTION ISOLOLATION LEVEL" */
-    else if( strcasecmp(prev2_wd,"SET")==0 && strcasecmp(prev_wd,"TRANSACTION")==0 )
-        COMPLETE_WITH_CONST("ISOLATION");
-    else if( strcasecmp(prev3_wd,"SET")==0 &&
-             strcasecmp(prev2_wd,"TRANSACTION")==0 &&
-             strcasecmp(prev_wd,"ISOLATION")==0 )
-        COMPLETE_WITH_CONST("LEVEL");
-    else if( strcasecmp(prev4_wd,"SET")==0 &&
-             strcasecmp(prev3_wd,"TRANSACTION")==0 &&
-             strcasecmp(prev2_wd,"ISOLATION")==0 &&
-             strcasecmp(prev_wd,"LEVEL")==0 ) {
-        char * my_list[] = {"READ","SERIALIZED",NULL};
-        COMPLETE_WITH_LIST(my_list);
-    }
-    else if( strcasecmp(prev4_wd,"TRANSACTION")==0 &&
-             strcasecmp(prev3_wd,"ISOLATION")==0 &&
-             strcasecmp(prev2_wd,"LEVEL")==0 &&
-             strcasecmp(prev_wd,"READ")==0 )
-        COMPLETE_WITH_CONST("COMMITTED");
-    /* Complete SET <var> with "TO" */
-    else if( strcasecmp(prev2_wd,"SET")==0 &&
-             strcasecmp(prev4_wd,"UPDATE")!=0 )
-        COMPLETE_WITH_CONST("TO");
-    /* Suggest possible variable values */
-    else if( strcasecmp(prev3_wd,"SET")==0 &&
-             (strcasecmp(prev_wd,"TO")==0 || strcmp(prev_wd,"=")==0) ) {
-        if ( strcasecmp(prev2_wd,"DateStyle")==0 ) {
-            char * my_list[] = {"'ISO'", "'SQL'", "'Postgres'", "'European'", "'NonEuropean'", "'German'", "DEFAULT", NULL};
-            COMPLETE_WITH_LIST(my_list);
-        }
-        else if( strcasecmp(prev2_wd,"GEQO")==0 || strcasecmp(prev2_wd,"KSQO")==0 ) {
-            char * my_list[] = {"ON", "OFF", "DEFAULT", NULL};
-            COMPLETE_WITH_LIST(my_list);
-        }
-        else {
-            char * my_list[] = {"DEFAULT", NULL};
-            COMPLETE_WITH_LIST(my_list);
-        }
-    }
+	/* Complete with a variable name */
+	else if ((strcasecmp(prev_wd, "SET") == 0 && strcasecmp(prev3_wd, "UPDATE") != 0) ||
+			 strcasecmp(prev_wd, "RESET") == 0 ||
+			 strcasecmp(prev_wd, "SHOW") == 0)
+		COMPLETE_WITH_LIST(pgsql_variables);
+	/* Complete "SET TRANSACTION ISOLOLATION LEVEL" */
+	else if (strcasecmp(prev2_wd, "SET") == 0 && strcasecmp(prev_wd, "TRANSACTION") == 0)
+		COMPLETE_WITH_CONST("ISOLATION");
+	else if (strcasecmp(prev3_wd, "SET") == 0 &&
+			 strcasecmp(prev2_wd, "TRANSACTION") == 0 &&
+			 strcasecmp(prev_wd, "ISOLATION") == 0)
+		COMPLETE_WITH_CONST("LEVEL");
+	else if (strcasecmp(prev4_wd, "SET") == 0 &&
+			 strcasecmp(prev3_wd, "TRANSACTION") == 0 &&
+			 strcasecmp(prev2_wd, "ISOLATION") == 0 &&
+			 strcasecmp(prev_wd, "LEVEL") == 0)
+	{
+		char	   *my_list[] = {"READ", "SERIALIZED", NULL};
+
+		COMPLETE_WITH_LIST(my_list);
+	}
+	else if (strcasecmp(prev4_wd, "TRANSACTION") == 0 &&
+			 strcasecmp(prev3_wd, "ISOLATION") == 0 &&
+			 strcasecmp(prev2_wd, "LEVEL") == 0 &&
+			 strcasecmp(prev_wd, "READ") == 0)
+		COMPLETE_WITH_CONST("COMMITTED");
+	/* Complete SET <var> with "TO" */
+	else if (strcasecmp(prev2_wd, "SET") == 0 &&
+			 strcasecmp(prev4_wd, "UPDATE") != 0)
+		COMPLETE_WITH_CONST("TO");
+	/* Suggest possible variable values */
+	else if (strcasecmp(prev3_wd, "SET") == 0 &&
+		   (strcasecmp(prev_wd, "TO") == 0 || strcmp(prev_wd, "=") == 0))
+	{
+		if (strcasecmp(prev2_wd, "DateStyle") == 0)
+		{
+			char	   *my_list[] = {"'ISO'", "'SQL'", "'Postgres'", "'European'", "'NonEuropean'", "'German'", "DEFAULT", NULL};
+
+			COMPLETE_WITH_LIST(my_list);
+		}
+		else if (strcasecmp(prev2_wd, "GEQO") == 0 || strcasecmp(prev2_wd, "KSQO") == 0)
+		{
+			char	   *my_list[] = {"ON", "OFF", "DEFAULT", NULL};
+
+			COMPLETE_WITH_LIST(my_list);
+		}
+		else
+		{
+			char	   *my_list[] = {"DEFAULT", NULL};
+
+			COMPLETE_WITH_LIST(my_list);
+		}
+	}
 
 /* UPDATE */
-    /* If prev. word is UPDATE suggest a list of tables */
-    else if( strcasecmp(prev_wd, "UPDATE") == 0 )
-      	COMPLETE_WITH_QUERY(Query_for_list_of_tables);
-    /* Complete UPDATE <table> with "SET" */
-    else if( strcasecmp(prev2_wd, "UPDATE") == 0 )
-        COMPLETE_WITH_CONST("SET");
-    /* If the previous word is SET (and it wasn't caught above as the _first_
-       word) the word before it was (hopefully) a table name and we'll now make
-       a list of attributes. */
-    else if( strcasecmp(prev_wd, "SET") == 0 )
-        COMPLETE_WITH_ATTR(prev2_wd);
+	/* If prev. word is UPDATE suggest a list of tables */
+	else if (strcasecmp(prev_wd, "UPDATE") == 0)
+		COMPLETE_WITH_QUERY(Query_for_list_of_tables);
+	/* Complete UPDATE <table> with "SET" */
+	else if (strcasecmp(prev2_wd, "UPDATE") == 0)
+		COMPLETE_WITH_CONST("SET");
+
+	/*
+	 * If the previous word is SET (and it wasn't caught above as the
+	 * _first_ word) the word before it was (hopefully) a table name and
+	 * we'll now make a list of attributes.
+	 */
+	else if (strcasecmp(prev_wd, "SET") == 0)
+		COMPLETE_WITH_ATTR(prev2_wd);
 
 /* VACUUM */
-    else if( strcasecmp(prev_wd, "VACUUM") == 0 )
-        COMPLETE_WITH_QUERY("SELECT relname FROM pg_class WHERE relkind='r' and substr(relname,1,%d)='%s' UNION SELECT 'ANALYZE'::text");
-    else if( strcasecmp(prev2_wd, "VACUUM")==0 && strcasecmp(prev_wd, "ANALYZE")==0 )
-      	COMPLETE_WITH_QUERY(Query_for_list_of_tables);
+	else if (strcasecmp(prev_wd, "VACUUM") == 0)
+		COMPLETE_WITH_QUERY("SELECT relname FROM pg_class WHERE relkind='r' and substr(relname,1,%d)='%s' UNION SELECT 'ANALYZE'::text");
+	else if (strcasecmp(prev2_wd, "VACUUM") == 0 && strcasecmp(prev_wd, "ANALYZE") == 0)
+		COMPLETE_WITH_QUERY(Query_for_list_of_tables);
 
 
 /* ... FROM ... */
-    else if (strcasecmp(prev_wd, "FROM") == 0 )
-        COMPLETE_WITH_QUERY(Query_for_list_of_tables);
+	else if (strcasecmp(prev_wd, "FROM") == 0)
+		COMPLETE_WITH_QUERY(Query_for_list_of_tables);
 
 
 /* Backslash commands */
-    else if (strcmp(prev_wd, "\\connect")==0 || strcmp(prev_wd, "\\c")==0)
-        COMPLETE_WITH_QUERY(Query_for_list_of_databases);
-    else if (strcmp(prev_wd, "\\d")==0)
-        COMPLETE_WITH_QUERY(Query_for_list_of_tables);
-    else if (strcmp(prev_wd, "\\h")==0 || strcmp(prev_wd, "\\help")==0)
-        COMPLETE_WITH_LIST(sql_commands);
-    else if (strcmp(prev_wd, "\\pset")==0) {
-        char * my_list[] = { "format", "border", "expanded", "null", "fieldsep",
-                             "tuples_only", "title", "tableattr", "pager",
-                             "recordsep", NULL };
-        COMPLETE_WITH_LIST(my_list);
-    }
-    else if( strcmp(prev_wd, "\\e")==0 || strcmp(prev_wd, "\\edit")==0 ||
-             strcmp(prev_wd, "\\g")==0 ||
-             strcmp(prev_wd, "\\i")==0 || strcmp(prev_wd, "\\include")==0 ||
-             strcmp(prev_wd, "\\o")==0 || strcmp(prev_wd, "\\out")==0 ||
-             strcmp(prev_wd, "\\s")==0 ||
-             strcmp(prev_wd, "\\w")==0 || strcmp(prev_wd, "\\write")==0
-        ) {
+	else if (strcmp(prev_wd, "\\connect") == 0 || strcmp(prev_wd, "\\c") == 0)
+		COMPLETE_WITH_QUERY(Query_for_list_of_databases);
+	else if (strcmp(prev_wd, "\\d") == 0)
+		COMPLETE_WITH_QUERY(Query_for_list_of_tables);
+	else if (strcmp(prev_wd, "\\h") == 0 || strcmp(prev_wd, "\\help") == 0)
+		COMPLETE_WITH_LIST(sql_commands);
+	else if (strcmp(prev_wd, "\\pset") == 0)
+	{
+		char	   *my_list[] = {"format", "border", "expanded", "null", "fieldsep",
+			"tuples_only", "title", "tableattr", "pager",
+		"recordsep", NULL};
+
+		COMPLETE_WITH_LIST(my_list);
+	}
+	else if (strcmp(prev_wd, "\\e") == 0 || strcmp(prev_wd, "\\edit") == 0 ||
+			 strcmp(prev_wd, "\\g") == 0 ||
+			 strcmp(prev_wd, "\\i") == 0 || strcmp(prev_wd, "\\include") == 0 ||
+		  strcmp(prev_wd, "\\o") == 0 || strcmp(prev_wd, "\\out") == 0 ||
+			 strcmp(prev_wd, "\\s") == 0 ||
+		   strcmp(prev_wd, "\\w") == 0 || strcmp(prev_wd, "\\write") == 0
+		)
+	{
 #ifdef HAVE_FILENAME_COMPLETION_FUNCTION
-        matches = completion_matches(text, filename_completion_function);
+		matches = completion_matches(text, filename_completion_function);
 #else
-        /*
-         * This will probably have the same effect, but you never know what
-         * the heck some readline incarnation out there is going to do.
-         */
-        matches = NULL;
+
+		/*
+		 * This will probably have the same effect, but you never know
+		 * what the heck some readline incarnation out there is going to
+		 * do.
+		 */
+		matches = NULL;
 #endif
-    }
-
-
-    /* Finally, we look through the list of "things", such as TABLE, INDEX and
-       check if that was the previous word. If so, execute the query to get a
-       list of them. */
-    else {
-        int i;
-        for(i=0; words_after_create[i].name; i++)
-            if ( strcasecmp(prev_wd, words_after_create[i].name) == 0 ) {
-                COMPLETE_WITH_QUERY(words_after_create[i].query);
-                break;
-            }
-    }
-
-
-    /* If we still don't have anything to match we have to fabricate some sort
-       of default list. If we were to just return NULL, readline automatically
-       attempts filename completion, and that's usually no good. */
-    if (matches == NULL)
-    {
-        COMPLETE_WITH_CONST("");
+	}
+
+
+	/*
+	 * Finally, we look through the list of "things", such as TABLE, INDEX
+	 * and check if that was the previous word. If so, execute the query
+	 * to get a list of them.
+	 */
+	else
+	{
+		int			i;
+
+		for (i = 0; words_after_create[i].name; i++)
+			if (strcasecmp(prev_wd, words_after_create[i].name) == 0)
+			{
+				COMPLETE_WITH_QUERY(words_after_create[i].query);
+				break;
+			}
+	}
+
+
+	/*
+	 * If we still don't have anything to match we have to fabricate some
+	 * sort of default list. If we were to just return NULL, readline
+	 * automatically attempts filename completion, and that's usually no
+	 * good.
+	 */
+	if (matches == NULL)
+	{
+		COMPLETE_WITH_CONST("");
 #ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
-        rl_completion_append_character = '\0';
+		rl_completion_append_character = '\0';
 #endif
-    }
-	
+	}
 
-    /* free storage */
-    free(prev_wd);
-    free(prev2_wd);
-    free(prev3_wd);
-    free(prev4_wd);
 
-    /* Return our Grand List O' Matches */
-    return matches;
+	/* free storage */
+	free(prev_wd);
+	free(prev2_wd);
+	free(prev3_wd);
+	free(prev4_wd);
+
+	/* Return our Grand List O' Matches */
+	return matches;
 }
 
 
@@ -602,24 +694,27 @@ char ** psql_completion(char *text, int start, int end)
 /* This one gives you one from a list of things you can put after CREATE or DROP
    as defined above.
 */
-char * create_command_generator(char *text, int state)
+char *
+create_command_generator(char *text, int state)
 {
-    static int list_index, string_length;
-    char *name;
-
-    /* If this is the first time for this completion, init some values */
-    if (state == 0) {
-        list_index = 0;
-        string_length = strlen(text);
-    }
-
-    /* find something that matches */
-    while ( (name = words_after_create[list_index++].name) )
-        if ( strncasecmp(name, text, string_length) == 0 )
-            return xstrdup(name);
-
-    /* if nothing matches, return NULL */
-    return NULL;
+	static int	list_index,
+				string_length;
+	char	   *name;
+
+	/* If this is the first time for this completion, init some values */
+	if (state == 0)
+	{
+		list_index = 0;
+		string_length = strlen(text);
+	}
+
+	/* find something that matches */
+	while ((name = words_after_create[list_index++].name))
+		if (strncasecmp(name, text, string_length) == 0)
+			return xstrdup(name);
+
+	/* if nothing matches, return NULL */
+	return NULL;
 }
 
 
@@ -632,40 +727,47 @@ char * create_command_generator(char *text, int state)
    Ordinarily this would be used to get a list of matching tables or functions,
    etc.
 */
-char * complete_from_query(char *text, int state)
+char *
+complete_from_query(char *text, int state)
 {
-    static int list_index, string_length;
-    static PGresult *result = NULL;
-    char query_buffer[BUF_SIZE];
-    const char * item;
-
-    /* If this ist the first time for this completion, we fetch a list of our
-       "things" from the backend. */
-    if (state == 0) {
-        list_index = 0;
-        string_length = strlen(text);
-
-        /* Need to have a query */
-        if (completion_charp == NULL) return NULL;
-
-        if (snprintf(query_buffer, BUF_SIZE, completion_charp, string_length, text, completion_info_charp) == -1) {
-            ERROR_QUERY_TOO_LONG;
-            return NULL;
-        }
-
-        result = exec_query(query_buffer);
-    }
-
-    /* Find something that matches */
-    if( result && PQresultStatus(result) == PGRES_TUPLES_OK )
-        while( list_index < PQntuples(result) && (item = PQgetvalue(result, list_index++, 0)) )
-            if ( strncasecmp(text, item, string_length) == 0)
-                return xstrdup(item);
-
-    /* If nothing matches, free the db structure and return null */
-    PQclear(result);
-    result = NULL;
-    return NULL;
+	static int	list_index,
+				string_length;
+	static PGresult *result = NULL;
+	char		query_buffer[BUF_SIZE];
+	const char *item;
+
+	/*
+	 * If this ist the first time for this completion, we fetch a list of
+	 * our "things" from the backend.
+	 */
+	if (state == 0)
+	{
+		list_index = 0;
+		string_length = strlen(text);
+
+		/* Need to have a query */
+		if (completion_charp == NULL)
+			return NULL;
+
+		if (snprintf(query_buffer, BUF_SIZE, completion_charp, string_length, text, completion_info_charp) == -1)
+		{
+			ERROR_QUERY_TOO_LONG;
+			return NULL;
+		}
+
+		result = exec_query(query_buffer);
+	}
+
+	/* Find something that matches */
+	if (result && PQresultStatus(result) == PGRES_TUPLES_OK)
+		while (list_index < PQntuples(result) && (item = PQgetvalue(result, list_index++, 0)))
+			if (strncasecmp(text, item, string_length) == 0)
+				return xstrdup(item);
+
+	/* If nothing matches, free the db structure and return null */
+	PQclear(result);
+	result = NULL;
+	return NULL;
 }
 
 
@@ -673,27 +775,31 @@ char * complete_from_query(char *text, int state)
    of strings (if matching). This can be used if there are only a fixed number
    SQL words that can appear at certain spot.
 */
-char * complete_from_list(char *text, int state) {
-    static int string_length, list_index;
-    char * item;
+char *
+complete_from_list(char *text, int state)
+{
+	static int	string_length,
+				list_index;
+	char	   *item;
 
-    /* need to have a list */
+	/* need to have a list */
 #ifdef USE_ASSERT_CHECKING
-    assert(completion_charpp);
+	assert(completion_charpp);
 #endif
 
-    /* Initialization */
-    if (state == 0) {
-        list_index = 0;
-        string_length = strlen(text);
-    }
+	/* Initialization */
+	if (state == 0)
+	{
+		list_index = 0;
+		string_length = strlen(text);
+	}
 
-    while( (item = completion_charpp[list_index++]) )
-        if ( strncasecmp(text,item,string_length) == 0 )
-            return xstrdup(item);
+	while ((item = completion_charpp[list_index++]))
+		if (strncasecmp(text, item, string_length) == 0)
+			return xstrdup(item);
 
-    /* If no more matches, return null. */
-    return NULL;
+	/* If no more matches, return null. */
+	return NULL;
 }
 
 
@@ -703,16 +809,19 @@ char * complete_from_list(char *text, int state) {
    will be overwritten.
    The string to be passed must be in completion_charp.
 */
-char * complete_from_const(char *text, int state)
+char *
+complete_from_const(char *text, int state)
 {
-    (void)text; /* We don't care about what was entered already. */
+	(void) text;				/* We don't care about what was entered
+								 * already. */
+
 #ifdef USE_ASSERT_CHECKING
-    assert(completion_charp);
+	assert(completion_charp);
 #endif
-    if (state==0)
-        return xstrdup(completion_charp);
-    else
-        return NULL;
+	if (state == 0)
+		return xstrdup(completion_charp);
+	else
+		return NULL;
 }
 
 
@@ -725,34 +834,37 @@ char * complete_from_const(char *text, int state)
    Note that the query passed in here must not have a semicolon at the end
    because we need to append LIMIT xxx.
 */
-PGresult * exec_query(char * query)
+PGresult   *
+exec_query(char *query)
 {
-    PGresult * result;
-    char query_buffer[BUF_SIZE];
+	PGresult   *result;
+	char		query_buffer[BUF_SIZE];
 
-    if (query == NULL || !pset.db || PQstatus(pset.db) != CONNECTION_OK)
-        return NULL;
+	if (query == NULL || !pset.db || PQstatus(pset.db) != CONNECTION_OK)
+		return NULL;
 #ifdef USE_ASSERT_CHECKING
-    assert( query[strlen(query)-1] != ';' );
+	assert(query[strlen(query) - 1] != ';');
 #endif
 
-    if( snprintf(query_buffer, BUF_SIZE, "%s LIMIT %d;", query, completion_max_records) == -1 ) {
-        ERROR_QUERY_TOO_LONG;
-        return NULL;
-    }
+	if (snprintf(query_buffer, BUF_SIZE, "%s LIMIT %d;", query, completion_max_records) == -1)
+	{
+		ERROR_QUERY_TOO_LONG;
+		return NULL;
+	}
 
-    result = PQexec(pset.db, query);
+	result = PQexec(pset.db, query);
 
-    if (result != NULL && PQresultStatus(result) != PGRES_TUPLES_OK) {
+	if (result != NULL && PQresultStatus(result) != PGRES_TUPLES_OK)
+	{
 #if 0
-        psql_error("tab completion: %s failed - %s\n", 
-                   query, PQresStatus(PQresultStatus(result)));
+		psql_error("tab completion: %s failed - %s\n",
+				   query, PQresStatus(PQresultStatus(result)));
 #endif
-        PQclear(result);
-        result = NULL;
-    }
-    
-    return result;
+		PQclear(result);
+		result = NULL;
+	}
+
+	return result;
 }
 
 
@@ -762,52 +874,63 @@ PGresult * exec_query(char * query)
    TODO: Take account of quotes. (Right now, if you table names contain spaces
    you're screwed.)
 */
-char * previous_word(int point, int skip) {
-    int i, start=0, end=-1;
-    char * s;
-
-    while (skip-- >=0) {
-        /* first we look for a space before the current word */
-        for(i=point; i>=0; i--)
-            if (rl_line_buffer[i] == ' ')
-                break;
-
-        /* now find the first non-space which then constitutes the end */
-        for(; i>=0; i--)
-            if (rl_line_buffer[i] != ' ') {
-                end = i;
-                break;
-            }
-
-        /* If no end found we return null, because there is no word before the point */
-        if (end == -1)
-            return NULL;
-
-        /* Otherwise we now look for the start. The start is either the last
-           character before any space going backwards from the end, or it's
-           simply character 0 */
-        for (start=end; start>0; start--)
-            if (rl_line_buffer[start-1] == ' ')
-                break;
-
-        point=start;
-    }
-
-    /* make a copy */
-    s = (char *)malloc(end-start+2);
-    if (!s)
-    {
-        psql_error("out of memory\n");
-        if (!pset.cur_cmd_interactive)
-            exit(EXIT_FAILURE);
-        else
-            return NULL;
-    }
-
-    strncpy(s, &rl_line_buffer[start], end-start+1);
-    s[end-start+1] = '\0';
-
-    return s;
+char *
+previous_word(int point, int skip)
+{
+	int			i,
+				start = 0,
+				end = -1;
+	char	   *s;
+
+	while (skip-- >= 0)
+	{
+		/* first we look for a space before the current word */
+		for (i = point; i >= 0; i--)
+			if (rl_line_buffer[i] == ' ')
+				break;
+
+		/* now find the first non-space which then constitutes the end */
+		for (; i >= 0; i--)
+			if (rl_line_buffer[i] != ' ')
+			{
+				end = i;
+				break;
+			}
+
+		/*
+		 * If no end found we return null, because there is no word before
+		 * the point
+		 */
+		if (end == -1)
+			return NULL;
+
+		/*
+		 * Otherwise we now look for the start. The start is either the
+		 * last character before any space going backwards from the end,
+		 * or it's simply character 0
+		 */
+		for (start = end; start > 0; start--)
+			if (rl_line_buffer[start - 1] == ' ')
+				break;
+
+		point = start;
+	}
+
+	/* make a copy */
+	s = (char *) malloc(end - start + 2);
+	if (!s)
+	{
+		psql_error("out of memory\n");
+		if (!pset.cur_cmd_interactive)
+			exit(EXIT_FAILURE);
+		else
+			return NULL;
+	}
+
+	strncpy(s, &rl_line_buffer[start], end - start + 1);
+	s[end - start + 1] = '\0';
+
+	return s;
 }
 
 
@@ -819,41 +942,43 @@ char * previous_word(int point, int skip) {
  * psql internal. Currently disable because it is reported not to
  * cooperate with certain versions of readline.
  */
-char * quote_file_name(char *text, int match_type, char * quote_pointer)
+char *
+quote_file_name(char *text, int match_type, char *quote_pointer)
 {
-    char *s;
-    size_t length;
-
-    (void)quote_pointer; /* not used */
-
-    length = strlen(text) + ( match_type==SINGLE_MATCH ? 3 : 2 );
-    s = malloc(length);
-    s[0] = '\'';
-    strcpy(s+1, text);
-    if (match_type==SINGLE_MATCH)
-        s[length-2] = '\'';
-    s[length-1] = '\0';
-    return s;
+	char	   *s;
+	size_t		length;
+
+	(void) quote_pointer;		/* not used */
+
+	length = strlen(text) +(match_type == SINGLE_MATCH ? 3 : 2);
+	s = malloc(length);
+	s[0] = '\'';
+	strcpy(s + 1, text);
+	if (match_type == SINGLE_MATCH)
+		s[length - 2] = '\'';
+	s[length - 1] = '\0';
+	return s;
 }
 
 
 
-static char * dequote_file_name(char *text, char quote_char)
+static char *
+dequote_file_name(char *text, char quote_char)
 {
-    char *s;
-    size_t length;
+	char	   *s;
+	size_t		length;
 
-    if (!quote_char)
-        return xstrdup(text);
+	if (!quote_char)
+		return xstrdup(text);
 
-    length = strlen(text);
-    s = malloc(length-2+1);
-    strncpy(s, text+1, length-2);
-    s[length] = '\0';
+	length = strlen(text);
+	s = malloc(length - 2 + 1);
+	strncpy(s, text +1, length - 2);
+	s[length] = '\0';
 
-    return s;
+	return s;
 }
 
-#endif /* 0 */
+#endif	 /* 0 */
 
-#endif /* USE_READLINE */
+#endif	 /* USE_READLINE */
diff --git a/src/bin/psql/tab-complete.h b/src/bin/psql/tab-complete.h
index c7d44bd2f07a61995e1410edc1d682a5e340db87..98f3e9546f105743582bfcf569c6ff1fad2dc597 100644
--- a/src/bin/psql/tab-complete.h
+++ b/src/bin/psql/tab-complete.h
@@ -3,13 +3,13 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.h,v 1.4 2000/03/05 13:30:19 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.h,v 1.5 2000/04/12 17:16:23 momjian Exp $
  */
 #ifndef TAB_COMPLETE_H
 #define TAB_COMPLETE_H
 
 #include "postgres.h"
 
-void initialize_readline(void);
+void		initialize_readline(void);
 
 #endif
diff --git a/src/bin/psql/variables.c b/src/bin/psql/variables.c
index 667066cbfd858b22dae860ba36d2bb4e2fcb006f..c8d8760b7854d2710dab1ec546be4a5911aabc1d 100644
--- a/src/bin/psql/variables.c
+++ b/src/bin/psql/variables.c
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/variables.c,v 1.7 2000/02/16 13:15:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/variables.c,v 1.8 2000/04/12 17:16:23 momjian Exp $
  */
 #include "postgres.h"
 #include "variables.h"
@@ -113,7 +113,7 @@ SetVariable(VariableSpace space, const char *name, const char *value)
 bool
 SetVariableBool(VariableSpace space, const char *name)
 {
-    return SetVariable(space, name, "");
+	return SetVariable(space, name, "");
 }
 
 
diff --git a/src/bin/psql/variables.h b/src/bin/psql/variables.h
index d0f01a7d79174c577c44825d9352747f24ab6811..0814d71a9a4041c5f7e5966d22cf5dd8990590ae 100644
--- a/src/bin/psql/variables.h
+++ b/src/bin/psql/variables.h
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/variables.h,v 1.7 2000/02/16 13:15:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/variables.h,v 1.8 2000/04/12 17:16:23 momjian Exp $
  */
 
 /*
@@ -16,7 +16,7 @@
 #define VARIABLES_H
 
 #define VALID_VARIABLE_CHARS "abcdefghijklmnopqrstuvwxyz"\
-                             "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789_"
+							 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789_"
 
 struct _variable
 {
@@ -32,7 +32,7 @@ VariableSpace CreateVariableSpace(void);
 const char *GetVariable(VariableSpace space, const char *name);
 bool		GetVariableBool(VariableSpace space, const char *name);
 bool		SetVariable(VariableSpace space, const char *name, const char *value);
-bool        SetVariableBool(VariableSpace space, const char *name);
+bool		SetVariableBool(VariableSpace space, const char *name);
 bool		DeleteVariable(VariableSpace space, const char *name);
 void		DestroyVariableSpace(VariableSpace space);
 
diff --git a/src/include/access/gist.h b/src/include/access/gist.h
index dd0aa92e40dd2cfe811f6abef32031041ba2524f..8c3c7a75fd48e9c0c2527a13f2c285a5052c6429 100644
--- a/src/include/access/gist.h
+++ b/src/include/access/gist.h
@@ -152,7 +152,7 @@ typedef struct GISTENTRY
 ** macro to initialize a GISTENTRY
 */
 #define gistentryinit(e, pr, r, pg, o, b, l)\
-   {(e).pred = pr; (e).rel = r; (e).page = pg; (e).offset = o; (e).bytes = b; (e).leafkey = l;}
+   do {(e).pred = pr; (e).rel = r; (e).page = pg; (e).offset = o; (e).bytes = b; (e).leafkey = l;} while (0)
 
 /* defined in gist.c */
 #define TRLOWER(tr) (((tr)->bytes))
diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h
index d5d7a3c5acecd17ef0375d757d2a935ac7812f8d..dae57528c71e74c5385cbd115dc7e70b81e21337 100644
--- a/src/include/access/heapam.h
+++ b/src/include/access/heapam.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: heapam.h,v 1.51 2000/01/26 05:57:50 momjian Exp $
+ * $Id: heapam.h,v 1.52 2000/04/12 17:16:25 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -261,7 +261,7 @@ extern ItemPointer heap_get_latest_tid(Relation relation, Snapshot snapshot, Ite
 extern Oid	heap_insert(Relation relation, HeapTuple tup);
 extern int	heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid);
 extern int heap_update(Relation relation, ItemPointer otid, HeapTuple tup,
-			 ItemPointer ctid);
+			ItemPointer ctid);
 extern int	heap_mark4update(Relation relation, HeapTuple tup, Buffer *userbuf);
 extern void heap_markpos(HeapScanDesc scan);
 extern void heap_restrpos(HeapScanDesc scan);
diff --git a/src/include/access/htup.h b/src/include/access/htup.h
index 4337d541f142ae599e6ac101527c7ae4ce455426..784c5051a93c5083f0f73edd16bfcc9af283ca56 100644
--- a/src/include/access/htup.h
+++ b/src/include/access/htup.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: htup.h,v 1.28 2000/01/26 05:57:50 momjian Exp $
+ * $Id: htup.h,v 1.29 2000/04/12 17:16:26 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -81,15 +81,15 @@ extern long heap_sysoffset[];
  *	  he have to add something below...
  *
  * Change for 7.0:
- *    Up to now t_data could be NULL, the memory location directly following
- *    HeapTupleData or pointing into a buffer. Now, it could also point to
- *    a separate allocation that was done in the t_datamcxt memory context.
+ *	  Up to now t_data could be NULL, the memory location directly following
+ *	  HeapTupleData or pointing into a buffer. Now, it could also point to
+ *	  a separate allocation that was done in the t_datamcxt memory context.
  */
 typedef struct HeapTupleData
 {
 	uint32		t_len;			/* length of *t_data */
 	ItemPointerData t_self;		/* SelfItemPointer */
-	MemoryContext   t_datamcxt; /* */
+	MemoryContext t_datamcxt;	/* */
 	HeapTupleHeader t_data;		/* */
 } HeapTupleData;
 
@@ -127,9 +127,9 @@ typedef HeapTupleData *HeapTuple;
 #define HEAP_HASVARLENA			0x0002	/* has variable length
 										 * attribute(s) */
 #define HEAP_HASEXTERNAL		0x0004	/* has external stored */
-										/* attribute(s) */
+ /* attribute(s) */
 #define HEAP_HASCOMPRESSED		0x0008	/* has compressed stored */
-										/* attribute(s) */
+ /* attribute(s) */
 #define HEAP_HASEXTENDED		0x000C	/* the two above combined */
 #define HEAP_XMIN_COMMITTED		0x0100	/* t_xmin committed */
 #define HEAP_XMIN_INVALID		0x0200	/* t_xmin invalid/aborted */
diff --git a/src/include/access/ibit.h b/src/include/access/ibit.h
index 808a98c86381c2427cba0e0cbb38fbec569b4abc..50d688d5124383975889f4f06c3d7461741e581e 100644
--- a/src/include/access/ibit.h
+++ b/src/include/access/ibit.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: ibit.h,v 1.12 2000/01/26 05:57:50 momjian Exp $
+ * $Id: ibit.h,v 1.13 2000/04/12 17:16:26 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -18,7 +18,7 @@
 
 typedef struct IndexAttributeBitMapData
 {
-	bits8		bits[(INDEX_MAX_KEYS + 8 - 1)/8];
+	bits8		bits[(INDEX_MAX_KEYS + 8 - 1) / 8];
 } IndexAttributeBitMapData;
 
 typedef IndexAttributeBitMapData *IndexAttributeBitMap;
diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h
index 7262402dcb9c2ae750fa5cfe367ef68009803ab9..94d27b1a2305578ce34388862a41af2747fd0014 100644
--- a/src/include/access/nbtree.h
+++ b/src/include/access/nbtree.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: nbtree.h,v 1.34 2000/02/18 06:32:28 tgl Exp $
+ * $Id: nbtree.h,v 1.35 2000/04/12 17:16:26 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -204,11 +204,11 @@ typedef struct BTPageState
  * prototypes for functions in nbtinsert.c
  */
 extern InsertIndexResult _bt_doinsert(Relation rel, BTItem btitem,
-									  bool index_is_unique, Relation heapRel);
+			 bool index_is_unique, Relation heapRel);
 extern int32 _bt_tuplecompare(Relation rel, Size keysz, ScanKey scankey,
-							  IndexTuple tuple1, IndexTuple tuple2);
+				 IndexTuple tuple1, IndexTuple tuple2);
 extern bool _bt_itemcmp(Relation rel, Size keysz, ScanKey scankey,
-						BTItem item1, BTItem item2, StrategyNumber strat);
+			BTItem item1, BTItem item2, StrategyNumber strat);
 
 /*
  * prototypes for functions in nbtpage.c
@@ -272,7 +272,7 @@ extern bool _bt_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir);
  * prototypes for functions in nbtstrat.c
  */
 extern StrategyNumber _bt_getstrat(Relation rel, AttrNumber attno,
-								   RegProcedure proc);
+			 RegProcedure proc);
 
 /*
  * prototypes for functions in nbtutils.c
@@ -289,7 +289,7 @@ extern BTItem _bt_formitem(IndexTuple itup);
  * prototypes for functions in nbtsort.c
  */
 
-typedef struct BTSpool BTSpool;	/* opaque type known only within nbtsort.c */
+typedef struct BTSpool BTSpool; /* opaque type known only within nbtsort.c */
 
 extern BTSpool *_bt_spoolinit(Relation index, bool isunique);
 extern void _bt_spooldestroy(BTSpool *btspool);
diff --git a/src/include/access/rmgr.h b/src/include/access/rmgr.h
index d8bde166c2cb379d5e4a15097a1c8ff764133b4f..b2796985948b475528646bbd02d601c975e480dc 100644
--- a/src/include/access/rmgr.h
+++ b/src/include/access/rmgr.h
@@ -8,7 +8,7 @@
 #ifndef RMGR_H
 #define RMGR_H
 
-typedef uint8	RmgrId;
+typedef uint8 RmgrId;
 
 typedef struct RmgrData
 {
@@ -17,18 +17,18 @@ typedef struct RmgrData
 	char	   *(*rm_undo) ();	/* UNDO(XLogRecPtr rptr) */
 } RmgrData;
 
-extern RmgrData	   *RmgrTable;
+extern RmgrData *RmgrTable;
 
 /*
  * Built-in resource managers
  */
-#define	RM_XLOG_ID				0
-#define	RM_XACT_ID				1
-#define	RM_HEAP_ID				2
-#define	RM_BTREE_ID				3
-#define	RM_HASH_ID				4
-#define	RM_RTREE_ID				5
-#define	RM_GIST_ID				6
-#define	RM_MAX_ID				RM_GIST_ID
+#define RM_XLOG_ID				0
+#define RM_XACT_ID				1
+#define RM_HEAP_ID				2
+#define RM_BTREE_ID				3
+#define RM_HASH_ID				4
+#define RM_RTREE_ID				5
+#define RM_GIST_ID				6
+#define RM_MAX_ID				RM_GIST_ID
 
 #endif	 /* RMGR_H */
diff --git a/src/include/access/strat.h b/src/include/access/strat.h
index 26a59180cc2a2de4f9903a39c653ed5aa6518fd8..9406b88ac3d9ee1396f33d8b16f767f395736bea 100644
--- a/src/include/access/strat.h
+++ b/src/include/access/strat.h
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: strat.h,v 1.17 2000/01/26 05:57:51 momjian Exp $
+ * $Id: strat.h,v 1.18 2000/04/12 17:16:26 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -35,6 +35,8 @@ typedef struct StrategyTransformMapData
 								 *
 								 *
 								 *
+								 *
+								 *
 								 * STRUCTURE */
 
 typedef StrategyTransformMapData *StrategyTransformMap;
diff --git a/src/include/access/tupdesc.h b/src/include/access/tupdesc.h
index 525cd6267e114e904d9bbd1ab1f1becddf774518..dbdc27931a56973a06720624d3437ca761112af8 100644
--- a/src/include/access/tupdesc.h
+++ b/src/include/access/tupdesc.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: tupdesc.h,v 1.27 2000/01/31 04:35:54 tgl Exp $
+ * $Id: tupdesc.h,v 1.28 2000/04/12 17:16:26 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -51,7 +51,7 @@ typedef struct tupleDesc
 	Form_pg_attribute *attrs;
 	/* attrs[N] is a pointer to the description of Attribute Number N+1.  */
 	TupleConstr *constr;
-} *TupleDesc;
+}		   *TupleDesc;
 
 extern TupleDesc CreateTemplateTupleDesc(int natts);
 
diff --git a/src/include/access/tuptoaster.h b/src/include/access/tuptoaster.h
index dedc770db2290c7b0ca6c9253befb0f7387d8e0b..9c4f1a505785a55aad244f786855d1f0c9765b88 100644
--- a/src/include/access/tuptoaster.h
+++ b/src/include/access/tuptoaster.h
@@ -2,11 +2,11 @@
  *
  * tuptoaster.h
  *	  POSTGRES definitions for external and compressed storage
- *    of variable size attributes.
+ *	  of variable size attributes.
  *
  * Copyright (c) 2000, PostgreSQL Development Team
  *
- * $Id: tuptoaster.h,v 1.1 1999/12/21 00:06:42 wieck Exp $
+ * $Id: tuptoaster.h,v 1.2 2000/04/12 17:16:26 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -22,12 +22,12 @@
 #include "utils/rel.h"
 
 
-extern void heap_tuple_toast_attrs(Relation rel, 
-				HeapTuple newtup, HeapTuple oldtup);
+extern void heap_tuple_toast_attrs(Relation rel,
+					   HeapTuple newtup, HeapTuple oldtup);
 
-extern varattrib *heap_tuple_untoast_attr(varattrib *attr);
+extern varattrib *heap_tuple_untoast_attr(varattrib * attr);
 
-#endif /* TUPLE_TOASTER_ACTIVE */
+#endif	 /* TUPLE_TOASTER_ACTIVE */
 
 
 #endif	 /* TUPTOASTER_H */
diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h
index 5c8c0754246b044bdd1e072b8ecd0df5515a7a40..e2ab6e4f417bb9d7390236b218189af230584241 100644
--- a/src/include/access/xlog.h
+++ b/src/include/access/xlog.h
@@ -13,43 +13,43 @@
 
 typedef struct XLogRecPtr
 {
-	uint32		xlogid;		/* log file #, 0 based */
-	uint32		xrecoff;	/* offset of record in log file */
+	uint32		xlogid;			/* log file #, 0 based */
+	uint32		xrecoff;		/* offset of record in log file */
 } XLogRecPtr;
 
 typedef struct XLogRecord
 {
-	XLogRecPtr		xl_prev;		/* ptr to previous record in log */
-	XLogRecPtr		xl_xact_prev;	/* ptr to previous record of this xact */
-	TransactionId	xl_xid;			/* xact id */
-	uint16			xl_len;			/* len of record on this page */
-	uint8			xl_info;
-	RmgrId			xl_rmid;		/* resource manager inserted this record */
+	XLogRecPtr	xl_prev;		/* ptr to previous record in log */
+	XLogRecPtr	xl_xact_prev;	/* ptr to previous record of this xact */
+	TransactionId xl_xid;		/* xact id */
+	uint16		xl_len;			/* len of record on this page */
+	uint8		xl_info;
+	RmgrId		xl_rmid;		/* resource manager inserted this record */
 
 	/* ACTUAL LOG DATA FOLLOWS AT END OF STRUCT */
 
 } XLogRecord;
 
-#define	SizeOfXLogRecord	DOUBLEALIGN(sizeof(XLogRecord))
-#define	MAXLOGRECSZ			(2 * BLCKSZ)
+#define SizeOfXLogRecord	DOUBLEALIGN(sizeof(XLogRecord))
+#define MAXLOGRECSZ			(2 * BLCKSZ)
 /*
  * When there is no space on current page we continue on the next
  * page with subrecord.
  */
 typedef struct XLogSubRecord
 {
-	uint16			xl_len;
-	uint8			xl_info;
+	uint16		xl_len;
+	uint8		xl_info;
 
 	/* ACTUAL LOG DATA FOLLOWS AT END OF STRUCT */
 
 } XLogSubRecord;
 
-#define	SizeOfXLogSubRecord	DOUBLEALIGN(sizeof(XLogSubRecord))
+#define SizeOfXLogSubRecord DOUBLEALIGN(sizeof(XLogSubRecord))
 
-#define	XLR_TO_BE_CONTINUED		0x01
+#define XLR_TO_BE_CONTINUED		0x01
 
-#define	XLOG_PAGE_MAGIC	0x17345168
+#define XLOG_PAGE_MAGIC 0x17345168
 
 typedef struct XLogPageHeaderData
 {
@@ -57,14 +57,14 @@ typedef struct XLogPageHeaderData
 	uint16		xlp_info;
 } XLogPageHeaderData;
 
-#define	SizeOfXLogPHD	DOUBLEALIGN(sizeof(XLogPageHeaderData))
+#define SizeOfXLogPHD	DOUBLEALIGN(sizeof(XLogPageHeaderData))
 
 typedef XLogPageHeaderData *XLogPageHeader;
 
-#define	XLP_FIRST_IS_SUBRECORD	0x0001
+#define XLP_FIRST_IS_SUBRECORD	0x0001
 
-extern XLogRecPtr		XLogInsert(RmgrId rmid, char *hdr, uint32 hdrlen, 
-									char *buf, uint32 buflen);
-extern void				XLogFlush(XLogRecPtr RecPtr);
+extern XLogRecPtr XLogInsert(RmgrId rmid, char *hdr, uint32 hdrlen,
+		   char *buf, uint32 buflen);
+extern void XLogFlush(XLogRecPtr RecPtr);
 
-#endif	/* XLOG_H */
+#endif	 /* XLOG_H */
diff --git a/src/include/c.h b/src/include/c.h
index abc3923f9d2192d86225f8e3b24c9f5077eeb013..43c9643fd9b44494c76a121e21c8b48b144375e7 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: c.h,v 1.68 2000/04/12 05:29:10 momjian Exp $
+ * $Id: c.h,v 1.69 2000/04/12 17:16:24 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -531,9 +531,11 @@ typedef struct Exception
  *
  */
 #define Trap(condition, exception) \
-		{ if ((assert_enabled) && (condition)) \
+		do { \
+			if ((assert_enabled) && (condition)) \
 				ExceptionalCondition(CppAsString(condition), &(exception), \
-						(char*)NULL, __FILE__, __LINE__); }
+						(char*)NULL, __FILE__, __LINE__); \
+		} while (0)
 
 /*
  *	TrapMacro is the same as Trap but it's intended for use in macros:
@@ -577,9 +579,11 @@ extern int	assert_enabled;
  *
  */
 #define LogTrap(condition, exception, printArgs) \
-		{ if ((assert_enabled) && (condition)) \
+		do { \
+			if ((assert_enabled) && (condition)) \
 				ExceptionalCondition(CppAsString(condition), &(exception), \
-						vararg_format printArgs, __FILE__, __LINE__); }
+						vararg_format printArgs, __FILE__, __LINE__); \
+		} while (0)
 
 /*
  *	LogTrapMacro is the same as LogTrap but it's intended for use in macros:
@@ -673,9 +677,9 @@ extern int	assertTest(int val);
  *	overhead.
  *
  *	We got the 64 number by testing this against the stock memset() on
- *	BSD/OS 3.0. Larger values were slower.  bjm 1997/09/11
+ *	BSD/OS 3.0. Larger values were slower.	bjm 1997/09/11
  *
- *  I think the crossover point could be a good deal higher for
+ *	I think the crossover point could be a good deal higher for
  *	most platforms, actually.  tgl 2000-03-19
  */
 #define MemSet(start, val, len) \
@@ -792,10 +796,12 @@ extern char *vararg_format(const char *fmt,...);
 
 #ifndef HAVE_SNPRINTF_DECL
 extern int	snprintf(char *str, size_t count, const char *fmt,...);
+
 #endif
 
 #ifndef HAVE_VSNPRINTF_DECL
 extern int	vsnprintf(char *str, size_t count, const char *fmt, va_list args);
+
 #endif
 
 #ifndef HAVE_MEMMOVE
diff --git a/src/include/catalog/catalog.h b/src/include/catalog/catalog.h
index 8eaa1a9c8be83bfa8d92b36b2f420eccce0d2e37..5ed346681c52bc6cdbec3fd45f4b40e95bde754f 100644
--- a/src/include/catalog/catalog.h
+++ b/src/include/catalog/catalog.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: catalog.h,v 1.11 2000/04/09 04:43:14 tgl Exp $
+ * $Id: catalog.h,v 1.12 2000/04/12 17:16:27 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -18,7 +18,7 @@
 
 extern char *relpath(const char *relname);
 extern char *relpath_blind(const char *dbname, const char *relname,
-						   Oid dbid, Oid relid);
+			  Oid dbid, Oid relid);
 extern bool IsSystemRelationName(const char *relname);
 extern bool IsSharedSystemRelationName(const char *relname);
 extern Oid	newoid(void);
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 5af11daa5b72486195bfbc9bfa84e459d710f601..cafab73cde3f09df6d17fc3bd89582b0ad9df7df 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -1,4 +1,4 @@
-/*------------------------------------------------------------------------- 
+/*-------------------------------------------------------------------------
  *
  * catversion.h
  *	  "Catalog version number" for Postgres.
@@ -37,7 +37,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: catversion.h,v 1.19 2000/04/07 13:39:49 thomas Exp $
+ * $Id: catversion.h,v 1.20 2000/04/12 17:16:27 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -52,7 +52,7 @@
  * catalog changes on the same day...)
  */
 
-/*                          yyyymmddN */
-#define CATALOG_VERSION_NO  200004051
+/*							yyyymmddN */
+#define CATALOG_VERSION_NO	200004051
 
 #endif
diff --git a/src/include/catalog/heap.h b/src/include/catalog/heap.h
index 63d114726e71cd3545fce6046df219d69ca300e3..468eef4d3dfb3296ae05c7d8accc37e6789e0494 100644
--- a/src/include/catalog/heap.h
+++ b/src/include/catalog/heap.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: heap.h,v 1.28 2000/01/26 05:57:56 momjian Exp $
+ * $Id: heap.h,v 1.29 2000/04/12 17:16:27 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -19,24 +19,25 @@
 typedef struct RawColumnDefault
 {
 	AttrNumber	attnum;			/* attribute to attach default to */
-	Node	   *raw_default;	/* default value (untransformed parse tree) */
+	Node	   *raw_default;	/* default value (untransformed parse
+								 * tree) */
 } RawColumnDefault;
 
-extern Oid RelnameFindRelid(const char *relname);
+extern Oid	RelnameFindRelid(const char *relname);
 extern Relation heap_create(char *relname, TupleDesc att,
-			    bool isnoname, bool istemp, bool storage_create);
+			bool isnoname, bool istemp, bool storage_create);
 extern bool heap_storage_create(Relation rel);
 
-extern Oid heap_create_with_catalog(char *relname, TupleDesc tupdesc, 
-				    char relkind, bool istemp);
+extern Oid heap_create_with_catalog(char *relname, TupleDesc tupdesc,
+						 char relkind, bool istemp);
 
 extern void heap_drop_with_catalog(const char *relname);
 extern void heap_truncate(char *relname);
 extern void heap_drop(Relation rel);
 
 extern void AddRelationRawConstraints(Relation rel,
-				      List *rawColDefaults,
-				      List *rawConstraints);
+						  List *rawColDefaults,
+						  List *rawConstraints);
 
 extern void InitNoNameRelList(void);
 extern void DropNoNameRels(void);
diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h
index b65e2ad98ebaed593881198add8c5d6a61c1ea56..4a74367421ff333eaef6ff0e25cbb71a33104ad1 100644
--- a/src/include/catalog/index.h
+++ b/src/include/catalog/index.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: index.h,v 1.22 2000/02/18 09:29:19 inoue Exp $
+ * $Id: index.h,v 1.23 2000/04/12 17:16:27 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -68,4 +68,5 @@ extern bool activate_index(Oid indexId, bool activate);
 extern bool reindex_index(Oid indexId, bool force);
 extern bool activate_indexes_of_a_table(Oid relid, bool activate);
 extern bool reindex_relation(Oid relid, bool force);
+
 #endif	 /* INDEX_H */
diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h
index 7440bf6152d75ec7e80da9a7a72838b823561808..3aea1db0fb0fc1183ee378f05cb93d7581f59a83 100644
--- a/src/include/catalog/indexing.h
+++ b/src/include/catalog/indexing.h
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: indexing.h,v 1.36 2000/01/26 05:57:56 momjian Exp $
+ * $Id: indexing.h,v 1.37 2000/04/12 17:16:27 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -35,7 +35,7 @@
 #define Num_pg_opclass_indices		2
 #define Num_pg_operator_indices		2
 #define Num_pg_proc_indices			2
-#define Num_pg_relcheck_indices 	1
+#define Num_pg_relcheck_indices		1
 #define Num_pg_rewrite_indices		2
 #define Num_pg_shadow_indices		2
 #define Num_pg_statistic_indices	1
@@ -114,22 +114,22 @@ extern char *IndexedCatalogNames[];
 extern void CatalogOpenIndices(int nIndices, char **names, Relation *idescs);
 extern void CatalogCloseIndices(int nIndices, Relation *idescs);
 extern void CatalogIndexInsert(Relation *idescs,
-					int nIndices,
-					Relation heapRelation,
-					HeapTuple heapTuple);
+				   int nIndices,
+				   Relation heapRelation,
+				   HeapTuple heapTuple);
 extern bool CatalogHasIndex(char *catName, Oid catId);
 
 extern HeapTuple AccessMethodOpidIndexScan(Relation heapRelation,
-					Oid claid, Oid opopr, Oid opid);
+						  Oid claid, Oid opopr, Oid opid);
 extern HeapTuple AccessMethodStrategyIndexScan(Relation heapRelation,
-					Oid opid, Oid claid, int2 opstrategy);
+							  Oid opid, Oid claid, int2 opstrategy);
 extern HeapTuple AggregateNameTypeIndexScan(Relation heapRelation,
-					char *aggName, Oid aggType);
+						   char *aggName, Oid aggType);
 extern HeapTuple AmNameIndexScan(Relation heapRelation, char *amName);
 extern HeapTuple AttributeRelidNameIndexScan(Relation heapRelation,
-					Oid relid, char *attname);
+							Oid relid, char *attname);
 extern HeapTuple AttributeRelidNumIndexScan(Relation heapRelation,
-					Oid relid, AttrNumber attnum);
+						   Oid relid, AttrNumber attnum);
 extern HeapTuple ClassNameIndexScan(Relation heapRelation, char *relName);
 extern HeapTuple ClassNameIndexScan(Relation heapRelation, char *relName);
 extern HeapTuple ClassOidIndexScan(Relation heapRelation, Oid relId);
@@ -137,25 +137,25 @@ extern HeapTuple GroupNameIndexScan(Relation heapRelation, char *groName);
 extern HeapTuple GroupSysidIndexScan(Relation heapRelation, int4 sysId);
 extern HeapTuple IndexRelidIndexScan(Relation heapRelation, Oid relid);
 extern HeapTuple InheritsRelidSeqnoIndexScan(Relation heapRelation, Oid relid,
-					int4 seqno);
+							int4 seqno);
 extern HeapTuple LanguageNameIndexScan(Relation heapRelation, char *lanName);
 extern HeapTuple LanguageOidIndexScan(Relation heapRelation, Oid lanId);
 extern HeapTuple ListenerRelnamePidIndexScan(Relation heapRelation, char *relName, int4 pid);
 extern HeapTuple OpclassDeftypeIndexScan(Relation heapRelation, Oid defType);
 extern HeapTuple OpclassNameIndexScan(Relation heapRelation, char *opcName);
 extern HeapTuple OperatorNameIndexScan(Relation heapRelation,
-					char *oprName, Oid oprLeft, Oid oprRight, char oprKind);
+				 char *oprName, Oid oprLeft, Oid oprRight, char oprKind);
 extern HeapTuple OperatorOidIndexScan(Relation heapRelation, Oid oprId);
 extern HeapTuple ProcedureNameIndexScan(Relation heapRelation,
-					char *procName, int2 nargs, Oid *argTypes);
+					   char *procName, int2 nargs, Oid *argTypes);
 extern HeapTuple ProcedureOidIndexScan(Relation heapRelation, Oid procId);
 extern HeapTuple RewriteOidIndexScan(Relation heapRelation, Oid rewriteId);
 extern HeapTuple RewriteRulenameIndexScan(Relation heapRelation,
-					char *ruleName);
+						 char *ruleName);
 extern HeapTuple ShadowNameIndexScan(Relation heapRelation, char *useName);
 extern HeapTuple ShadowSysidIndexScan(Relation heapRelation, int4 sysId);
 extern HeapTuple StatisticRelidAttnumIndexScan(Relation heapRelation,
-				 Oid relId, AttrNumber attNum);
+							  Oid relId, AttrNumber attNum);
 extern HeapTuple TypeNameIndexScan(Relation heapRelation, char *typeName);
 extern HeapTuple TypeOidIndexScan(Relation heapRelation, Oid typeId);
 
diff --git a/src/include/catalog/pg_aggregate.h b/src/include/catalog/pg_aggregate.h
index c953d33d00a2b27668886214feed6f1380c811d1..0cae51dec647c8f371dd287d20282c3fa0033210 100644
--- a/src/include/catalog/pg_aggregate.h
+++ b/src/include/catalog/pg_aggregate.h
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_aggregate.h,v 1.24 2000/03/14 23:06:42 thomas Exp $
+ * $Id: pg_aggregate.h,v 1.25 2000/04/12 17:16:27 momjian Exp $
  *
  * NOTES
  *	  the genbki.sh script reads this file and generates .bki
@@ -132,7 +132,7 @@ DATA(insert OID = 0 ( min	PGUID date_smaller		- - 1082 1082 0 1082 _null_ _null_
 DATA(insert OID = 0 ( min	PGUID time_smaller		- - 1083 1083 0 1083 _null_ _null_ ));
 DATA(insert OID = 0 ( min	PGUID timetz_smaller	- - 1266 1266 0 1266 _null_ _null_ ));
 DATA(insert OID = 0 ( min	PGUID cashsmaller		- -  790  790 0  790 _null_ _null_ ));
-DATA(insert OID = 0 ( min	PGUID timestamp_smaller	- - 1184 1184 0 1184 _null_ _null_ ));
+DATA(insert OID = 0 ( min	PGUID timestamp_smaller - - 1184 1184 0 1184 _null_ _null_ ));
 DATA(insert OID = 0 ( min	PGUID interval_smaller	- - 1186 1186 0 1186 _null_ _null_ ));
 DATA(insert OID = 0 ( min	PGUID text_smaller		- -   25   25 0   25 _null_ _null_ ));
 DATA(insert OID = 0 ( min	PGUID numeric_smaller	- - 1700 1700 0 1700 _null_ _null_ ));
diff --git a/src/include/catalog/pg_am.h b/src/include/catalog/pg_am.h
index dfebc0e8c8f46b6f3c3c949d4add0fb0bd77deee..6e4366b37f9b3e72ff1afd42e17605d5176e988a 100644
--- a/src/include/catalog/pg_am.h
+++ b/src/include/catalog/pg_am.h
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_am.h,v 1.14 2000/02/17 03:39:47 tgl Exp $
+ * $Id: pg_am.h,v 1.15 2000/04/12 17:16:27 momjian Exp $
  *
  * NOTES
  *		the genbki.sh script reads this file and generates .bki
@@ -38,13 +38,13 @@ CATALOG(pg_am)
 {
 	NameData	amname;			/* access method name */
 	int4		amowner;		/* usesysid of creator */
-	int2		amstrategies;	/* total NUMBER of strategies by which
-								 * we can traverse/search this AM */
-	int2		amsupport;		/* total NUMBER of support functions
-								 * that this AM uses */
-	int2		amorderstrategy; /* if this AM has a sort order, the
-								  * strategy number of the sort operator.
-								  * Zero if AM is not ordered. */
+	int2		amstrategies;	/* total NUMBER of strategies by which we
+								 * can traverse/search this AM */
+	int2		amsupport;		/* total NUMBER of support functions that
+								 * this AM uses */
+	int2		amorderstrategy;/* if this AM has a sort order, the
+								 * strategy number of the sort operator.
+								 * Zero if AM is not ordered. */
 	regproc		amgettuple;		/* "next valid tuple" function */
 	regproc		aminsert;		/* "insert this tuple" function */
 	regproc		amdelete;		/* "delete this tuple" function */
@@ -62,7 +62,7 @@ CATALOG(pg_am)
 	regproc		ambuild;		/* "build new index" function */
 	regproc		amcreate;		/* - deprecated */
 	regproc		amdestroy;		/* - deprecated */
-	regproc		amcostestimate;	/* estimate cost of an indexscan */
+	regproc		amcostestimate; /* estimate cost of an indexscan */
 } FormData_pg_am;
 
 /* ----------------
diff --git a/src/include/catalog/pg_amop.h b/src/include/catalog/pg_amop.h
index 3f8859dd21611671072c91cca332840f48f5d36b..001472522988830c89d07e8b84f0040c5f8cdc01 100644
--- a/src/include/catalog/pg_amop.h
+++ b/src/include/catalog/pg_amop.h
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_amop.h,v 1.32 2000/03/14 23:06:43 thomas Exp $
+ * $Id: pg_amop.h,v 1.33 2000/04/12 17:16:28 momjian Exp $
  *
  * NOTES
  *	 the genbki.sh script reads this file and generates .bki
@@ -365,7 +365,7 @@ DATA(insert OID = 0 (  403 1690 1695 4 ));
 DATA(insert OID = 0 (  403 1690   59 5 ));
 
 /*
- *    nbtree lztext
+ *	  nbtree lztext
  */
 
 DATA(insert OID = 0 (  403 1663 1659 1 ));
diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h
index 54f3adc9ee1dfc9c31462e4450a926a2094917e3..6edd86b1f2ea6e5f4329a523f68cbf2d345e825f 100644
--- a/src/include/catalog/pg_attribute.h
+++ b/src/include/catalog/pg_attribute.h
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_attribute.h,v 1.54 2000/03/09 05:00:26 inoue Exp $
+ * $Id: pg_attribute.h,v 1.55 2000/04/12 17:16:28 momjian Exp $
  *
  * NOTES
  *	  the genbki.sh script reads this file and generates .bki
@@ -41,9 +41,11 @@
  */
 CATALOG(pg_attribute) BOOTSTRAP
 {
-	Oid			attrelid;		/* OID of relation containing this attribute */
+	Oid			attrelid;		/* OID of relation containing this
+								 * attribute */
 	NameData	attname;
 	Oid			atttypid;
+
 	/*
 	 * atttypid is the OID of the instance in Catalog Class pg_type that
 	 * defines the data type of this attribute (e.g. int4).  Information
@@ -53,19 +55,21 @@ CATALOG(pg_attribute) BOOTSTRAP
 	 */
 
 	float4		attdisbursion;
+
 	/*
-	 * attdisbursion is the disbursion statistic of the column (0.0 to 1.0),
-	 * or zero if the statistic has not been calculated, or -1.0
-	 * if VACUUM found that the column contains no duplicate entries
-	 * (in which case the disbursion should be taken as 1.0/numberOfRows
-	 * for the current table size).  The -1.0 hack is useful because the
-	 * number of rows may be updated more often than attdisbursion is.
-	 * We assume that the column will retain its no-duplicate-entry
-	 * property.  (Perhaps this should be driven off the existence of a
-	 * UNIQUE index for the column, instead of being a statistical guess?)
+	 * attdisbursion is the disbursion statistic of the column (0.0 to
+	 * 1.0), or zero if the statistic has not been calculated, or -1.0 if
+	 * VACUUM found that the column contains no duplicate entries (in
+	 * which case the disbursion should be taken as 1.0/numberOfRows for
+	 * the current table size).  The -1.0 hack is useful because the
+	 * number of rows may be updated more often than attdisbursion is. We
+	 * assume that the column will retain its no-duplicate-entry property.
+	 * (Perhaps this should be driven off the existence of a UNIQUE index
+	 * for the column, instead of being a statistical guess?)
 	 */
 
 	int2		attlen;
+
 	/*
 	 * attlen is a copy of the typlen field from pg_type for this
 	 * attribute.  See atttypid above.	See struct Form_pg_type for
@@ -73,6 +77,7 @@ CATALOG(pg_attribute) BOOTSTRAP
 	 */
 
 	int2		attnum;
+
 	/*
 	 * attnum is the "attribute number" for the attribute:	A value that
 	 * uniquely identifies this attribute within its class. For user
@@ -90,6 +95,7 @@ CATALOG(pg_attribute) BOOTSTRAP
 	int4		attnelems;		/* number of dimensions, if an array type */
 
 	int4		attcacheoff;
+
 	/*
 	 * fastgetattr() uses attcacheoff to cache byte offsets of attributes
 	 * in heap tuples.	The value actually stored in pg_attribute (-1)
@@ -99,36 +105,39 @@ CATALOG(pg_attribute) BOOTSTRAP
 	 */
 
 	int4		atttypmod;
+
 	/*
-	 * atttypmod records type-specific data supplied at table creation time
-	 * (for example, the max length of a varchar field).  It is passed to
-	 * type-specific input and output functions as the third argument.
-	 * The value will generally be -1 for types that do not need typmod.
+	 * atttypmod records type-specific data supplied at table creation
+	 * time (for example, the max length of a varchar field).  It is
+	 * passed to type-specific input and output functions as the third
+	 * argument. The value will generally be -1 for types that do not need
+	 * typmod.
 	 */
 
 	bool		attbyval;
+
 	/*
 	 * attbyval is a copy of the typbyval field from pg_type for this
 	 * attribute.  See atttypid above.	See struct Form_pg_type for
 	 * definition.
 	 */
-	
+
 	char		attstorage;
+
 	/*
-	 * attstorage tells for VARLENA attributes, what the heap
-	 * access methods can do to it if a given tuple doesn't fit into
-	 * a page. Possible values are
-	 *     'p': Value must be stored plain allways
-	 *     'e': Value can be stored in "secondary" relation (if relation
-	 *          has rellongrelid attached)
-	 *     'c': Value can be stored compressed inline
-	 *     'x': Value can be stored compressed inline or in "secondary".
+	 * attstorage tells for VARLENA attributes, what the heap access
+	 * methods can do to it if a given tuple doesn't fit into a page.
+	 * Possible values are 'p': Value must be stored plain allways 'e':
+	 * Value can be stored in "secondary" relation (if relation has
+	 * rellongrelid attached) 'c': Value can be stored compressed inline
+	 * 'x': Value can be stored compressed inline or in "secondary".
 	 *
 	 * Note: compressed storage
 	 */
 
 	bool		attisset;
 	char		attalign;
+
 	/*
 	 * attalign is a copy of the typalign field from pg_type for this
 	 * attribute.  See atttypid above.	See struct Form_pg_type for
@@ -136,8 +145,10 @@ CATALOG(pg_attribute) BOOTSTRAP
 	 */
 
 	bool		attnotnull;
+
 	/* This flag represents the "NOT NULL" constraint */
 	bool		atthasdef;
+
 	/* Has DEFAULT value or not */
 } FormData_pg_attribute;
 
@@ -182,16 +193,16 @@ typedef FormData_pg_attribute *Form_pg_attribute;
 /*
  *	CONSTANT and MACROS for DROP COLUMN implementation
  */
-#define	DROP_COLUMN_OFFSET	-20
-#define	COLUMN_IS_DROPPED(attribute)	((attribute)->attnum <= DROP_COLUMN_OFFSET)
-#define	DROPPED_COLUMN_INDEX(attidx)	(DROP_COLUMN_OFFSET - attidx)
-#define	ATTRIBUTE_DROP_COLUMN(attribute) \
+#define DROP_COLUMN_OFFSET	-20
+#define COLUMN_IS_DROPPED(attribute)	((attribute)->attnum <= DROP_COLUMN_OFFSET)
+#define DROPPED_COLUMN_INDEX(attidx)	(DROP_COLUMN_OFFSET - attidx)
+#define ATTRIBUTE_DROP_COLUMN(attribute) \
 	Assert((attribute)->attnum > 0); \
 	(attribute)->attnum = DROPPED_COLUMN_INDEX((attribute)->attnum); \
 	(attribute)->atttypid = (Oid) -1; \
 	(attribute)->attnotnull = false; \
-	(attribute)->atthasdef = false; 
-#endif	/* _DROP_COLUMN_HACK__ */
+	(attribute)->atthasdef = false;
+#endif	 /* _DROP_COLUMN_HACK__ */
 /* ----------------
  *		SCHEMA_ macros for declaring hardcoded tuple descriptors.
  *		these are used in utils/cache/relcache.c
@@ -286,7 +297,7 @@ DATA(insert OID = 0 ( 1262 cmax				29 0  4  -6 0 -1 -1 t p f i f f));
 { 1255, {"pronargs"},			21, 0,	2,	7, 0, -1, -1, '\001', 'p', '\0', 's', '\0', '\0' }, \
 { 1255, {"proretset"},			16, 0,	1,	8, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \
 { 1255, {"prorettype"},			26, 0,	4,	9, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \
-{ 1255, {"proargtypes"},		30, 0, INDEX_MAX_KEYS*4, 10, 0, -1, -1,	'\0', 'p', '\0', 'i', '\0', '\0' }, \
+{ 1255, {"proargtypes"},		30, 0, INDEX_MAX_KEYS*4, 10, 0, -1, -1, '\0', 'p', '\0', 'i', '\0', '\0' }, \
 { 1255, {"probyte_pct"},		23, 0,	4, 11, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \
 { 1255, {"properbyte_cpu"},		23, 0,	4, 12, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \
 { 1255, {"propercall_cpu"},		23, 0,	4, 13, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \
@@ -365,7 +376,7 @@ DATA(insert OID = 0 ( 1261 cmax				29 0  4  -6 0 -1 -1 t p f i f f));
 { 1249, {"attcacheoff"},  23, 0,	4,	8, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \
 { 1249, {"atttypmod"},	  23, 0,	4,	9, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \
 { 1249, {"attbyval"},	  16, 0,	1, 10, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \
-{ 1249, {"attstorage"},	  18, 0,	1, 11, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \
+{ 1249, {"attstorage"},   18, 0,	1, 11, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \
 { 1249, {"attisset"},	  16, 0,	1, 12, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \
 { 1249, {"attalign"},	  18, 0,	1, 13, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \
 { 1249, {"attnotnull"},  16, 0, 1, 14, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \
@@ -490,7 +501,7 @@ DATA(insert OID = 0 ( 1219 tgconstrrelid	26 0  4   8 0 -1 -1 t p f i f f));
 DATA(insert OID = 0 ( 1219 tgdeferrable		16 0  1   9 0 -1 -1 t p f c f f));
 DATA(insert OID = 0 ( 1219 tginitdeferred	16 0  1   10 0 -1 -1 t p f c f f));
 DATA(insert OID = 0 ( 1219 tgnargs			21 0  2   11 0 -1 -1 t p f s f f));
-DATA(insert OID = 0 ( 1219 tgattr			22 0  INDEX_MAX_KEYS*2  12 0 -1 -1 f p f i f f));
+DATA(insert OID = 0 ( 1219 tgattr			22 0  INDEX_MAX_KEYS*2	12 0 -1 -1 f p f i f f));
 DATA(insert OID = 0 ( 1219 tgargs			17 0 -1   13 0 -1 -1 f p f i f f));
 DATA(insert OID = 0 ( 1219 ctid				27 0  6  -1 0 -1 -1 f p f i f f));
 DATA(insert OID = 0 ( 1219 oid				26 0  4  -2 0 -1 -1 t p f i f f));
diff --git a/src/include/catalog/pg_description.h b/src/include/catalog/pg_description.h
index 96caec1a2631d9185f9a188ca01238bb5971312a..391f88fb5c3c1a9b1d25381de91ea541316146fb 100644
--- a/src/include/catalog/pg_description.h
+++ b/src/include/catalog/pg_description.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_description.h,v 1.10 2000/01/26 05:57:57 momjian Exp $
+ * $Id: pg_description.h,v 1.11 2000/04/12 17:16:28 momjian Exp $
  *
  * NOTES
  *		the genbki.sh script reads this file and generates .bki
@@ -66,4 +66,3 @@ typedef FormData_pg_description *Form_pg_description;
  */
 
 #endif	 /* PG_DESCRIPTION_H */
-
diff --git a/src/include/catalog/pg_inheritproc.h b/src/include/catalog/pg_inheritproc.h
index c3bb7f165c1406b8c99c4abadc3cb2cfce17055a..90d182ec1813889797ba01e9f2407aeb3472fba5 100644
--- a/src/include/catalog/pg_inheritproc.h
+++ b/src/include/catalog/pg_inheritproc.h
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_inheritproc.h,v 1.8 2000/01/26 05:57:57 momjian Exp $
+ * $Id: pg_inheritproc.h,v 1.9 2000/04/12 17:16:28 momjian Exp $
  *
  * NOTES
  *	  the genbki.sh script reads this file and generates .bki
@@ -52,8 +52,8 @@ typedef FormData_pg_inheritproc *Form_pg_inheritproc;
  */
 #define Natts_pg_inheritproc			4
 #define Anum_pg_inheritproc_inhproname	1
-#define Anum_pg_inheritproc_inhargrelid	2
-#define Anum_pg_inheritproc_inhdefrelid	3
+#define Anum_pg_inheritproc_inhargrelid 2
+#define Anum_pg_inheritproc_inhdefrelid 3
 #define Anum_pg_inheritproc_inhproc		4
 
 
diff --git a/src/include/catalog/pg_opclass.h b/src/include/catalog/pg_opclass.h
index 617bb0f4d319b8238961a989ec68b180ceb88b7d..1ff443a53f572d636a0e83e976c6e88eeec1737d 100644
--- a/src/include/catalog/pg_opclass.h
+++ b/src/include/catalog/pg_opclass.h
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_opclass.h,v 1.31 2000/03/14 23:06:43 thomas Exp $
+ * $Id: pg_opclass.h,v 1.32 2000/04/12 17:16:28 momjian Exp $
  *
  * NOTES
  *	  the genbki.sh script reads this file and generates .bki
@@ -63,66 +63,66 @@ typedef FormData_pg_opclass *Form_pg_opclass;
  * (see the README in this directory), so just put zeros
  * in, which are invalid OID's anyway.  --djm
  */
-DATA(insert OID =  421 (	int2_ops         21   ));
+DATA(insert OID =  421 (	int2_ops		 21   ));
 DESCR("");
-DATA(insert OID =  422 (	box_ops         603   ));
+DATA(insert OID =  422 (	box_ops			603   ));
 DESCR("");
-DATA(insert OID =  423 (	float8_ops      701   ));
+DATA(insert OID =  423 (	float8_ops		701   ));
 DESCR("");
-DATA(insert OID =  424 (	int24_ops         0   ));
+DATA(insert OID =  424 (	int24_ops		  0   ));
 DESCR("");
-DATA(insert OID =  425 (	int42_ops         0   ));
+DATA(insert OID =  425 (	int42_ops		  0   ));
 DESCR("");
-DATA(insert OID =  426 (	int4_ops         23   ));
+DATA(insert OID =  426 (	int4_ops		 23   ));
 DESCR("");
 #define INT4_OPS_OID 426
-DATA(insert OID =  427 (	oid_ops          26   ));
+DATA(insert OID =  427 (	oid_ops			 26   ));
 DESCR("");
-DATA(insert OID =  428 (	float4_ops      700   ));
+DATA(insert OID =  428 (	float4_ops		700   ));
 DESCR("");
-DATA(insert OID =  429 (	char_ops         18   ));
+DATA(insert OID =  429 (	char_ops		 18   ));
 DESCR("");
-DATA(insert OID =  431 (	text_ops         25   ));
+DATA(insert OID =  431 (	text_ops		 25   ));
 DESCR("");
-DATA(insert OID =  432 (	abstime_ops     702   ));
+DATA(insert OID =  432 (	abstime_ops		702   ));
 DESCR("");
-DATA(insert OID =  433 (	bigbox_ops      603   ));
+DATA(insert OID =  433 (	bigbox_ops		603   ));
 DESCR("");
-DATA(insert OID =  434 (	poly_ops        604   ));
+DATA(insert OID =  434 (	poly_ops		604   ));
 DESCR("");
-DATA(insert OID =  435 (	oidvector_ops    30   ));
+DATA(insert OID =  435 (	oidvector_ops	 30   ));
 DESCR("");
-DATA(insert OID =  714 (	circle_ops      718   ));
+DATA(insert OID =  714 (	circle_ops		718   ));
 DESCR("");
-DATA(insert OID =  754 (	int8_ops         20   ));
+DATA(insert OID =  754 (	int8_ops		 20   ));
 DESCR("");
-DATA(insert OID = 1076 (	bpchar_ops     1042   ));
+DATA(insert OID = 1076 (	bpchar_ops	   1042   ));
 DESCR("");
 DATA(insert OID = 1077 (	varchar_ops    1043   ));
 DESCR("");
-DATA(insert OID = 1114 (	date_ops       1082   ));
+DATA(insert OID = 1114 (	date_ops	   1082   ));
 DESCR("");
-DATA(insert OID = 1115 (	time_ops       1083   ));
+DATA(insert OID = 1115 (	time_ops	   1083   ));
 DESCR("");
-DATA(insert OID = 1181 (	name_ops         19   ));
+DATA(insert OID = 1181 (	name_ops		 19   ));
 DESCR("");
 DATA(insert OID = 1312 (	timestamp_ops  1184   ));
 DESCR("");
 DATA(insert OID = 1313 (	interval_ops   1186   ));
 DESCR("");
-DATA(insert OID = 810  (	macaddr_ops     829   ));
+DATA(insert OID = 810  (	macaddr_ops		829   ));
 DESCR("");
-DATA(insert OID = 935  (	inet_ops        869   ));
+DATA(insert OID = 935  (	inet_ops		869   ));
 DESCR("");
-DATA(insert OID = 652  (	cidr_ops        650   ));
+DATA(insert OID = 652  (	cidr_ops		650   ));
 DESCR("");
 DATA(insert OID = 1768 (	numeric_ops    1700   ));
 DESCR("");
-DATA(insert OID = 1663 (	lztext_ops     1625   ));
+DATA(insert OID = 1663 (	lztext_ops	   1625   ));
 DESCR("");
-DATA(insert OID = 1690 (	bool_ops         16   ));
+DATA(insert OID = 1690 (	bool_ops		 16   ));
 DESCR("");
-DATA(insert OID = 1399 (	timetz_ops     1266   ));
+DATA(insert OID = 1399 (	timetz_ops	   1266   ));
 DESCR("");
 
 #endif	 /* PG_OPCLASS_H */
diff --git a/src/include/catalog/pg_operator.h b/src/include/catalog/pg_operator.h
index 2150bac98de664ef45809555dbf54e5682d71159..538d0095258c428d680b4353ce9bfd43d5102a3d 100644
--- a/src/include/catalog/pg_operator.h
+++ b/src/include/catalog/pg_operator.h
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_operator.h,v 1.74 2000/04/08 02:13:00 thomas Exp $
+ * $Id: pg_operator.h,v 1.75 2000/04/12 17:16:29 momjian Exp $
  *
  * NOTES
  *	  the genbki.sh script reads this file and generates .bki
@@ -139,7 +139,7 @@ DATA(insert OID = 399 (  "="	   PGUID 0 b t f  1026	1026  16  399 0  0	0 array_e
 DATA(insert OID = 400 (  "="	   PGUID 0 b t f  1027	1027  16  400 0  0	0 array_eq eqsel eqjoinsel ));
 DATA(insert OID = 401 (  "="	   PGUID 0 b t f  1034	1034  16  401 0  0	0 array_eq eqsel eqjoinsel ));
 
-DATA(insert OID = 387 ( "="	   PGUID 0 b t t  27  27  16 387  0  0  0 tideq eqsel eqjoinsel ));
+DATA(insert OID = 387 ( "="    PGUID 0 b t t  27  27  16 387  0  0	0 tideq eqsel eqjoinsel ));
 #define TIDEqualOperator   387
 DATA(insert OID = 388 (  "!"	   PGUID 0 r t f  20   0  20   0   0   0   0 int8fac - - ));
 DATA(insert OID = 389 (  "!!"	   PGUID 0 l t f   0  20  20   0   0   0   0 int8fac - - ));
@@ -281,13 +281,13 @@ DATA(insert OID = 1283 (  ";"	   PGUID 0 l t f   0 701 701   0   0   0   0 dlog1
 DATA(insert OID = 1284 (  "|"	   PGUID 0 l t f   0 704 702	0  0   0   0 tintervalstart - - ));
 DATA(insert OID = 606 (  "<#>"	   PGUID 0 b t f 702 702 704	0  0   0   0 mktinterval - - ));
 DATA(insert OID = 607 (  "="	   PGUID 0 b t t  26  26  16 607 608 609 609 oideq eqsel eqjoinsel ));
-#define MIN_OIDCMP 607 /* used by cache code */
+#define MIN_OIDCMP 607			/* used by cache code */
 DATA(insert OID = 608 (  "<>"	   PGUID 0 b t f  26  26  16 608 607  0  0 oidne neqsel neqjoinsel ));
 DATA(insert OID = 609 (  "<"	   PGUID 0 b t f  26  26  16 610 612  0  0 int4lt scalarltsel scalarltjoinsel ));
 DATA(insert OID = 610 (  ">"	   PGUID 0 b t f  26  26  16 609 611  0  0 int4gt scalargtsel scalargtjoinsel ));
 DATA(insert OID = 611 (  "<="	   PGUID 0 b t f  26  26  16 612 610  0  0 int4le scalarltsel scalarltjoinsel ));
 DATA(insert OID = 612 (  ">="	   PGUID 0 b t f  26  26  16 611 609  0  0 int4ge scalargtsel scalargtjoinsel ));
-#define MAX_OIDCMP 612 /* used by cache code */
+#define MAX_OIDCMP 612			/* used by cache code */
 
 DATA(insert OID = 644 (  "<>"	   PGUID 0 b t f  30  30  16 644 649   0   0 oidvectorne neqsel neqjoinsel ));
 DATA(insert OID = 645 (  "<"	   PGUID 0 b t f  30  30  16 646 648   0   0 oidvectorlt - - ));
@@ -520,11 +520,11 @@ DATA(insert OID = 1134 (  "<="		PGUID 0 b t f  701	700  16 1125 1133  0 0 float8
 DATA(insert OID = 1135 (  ">="		PGUID 0 b t f  701	700  16 1124 1132  0 0 float84ge scalargtsel scalargtjoinsel ));
 
 /* int4 and oid equality */
-DATA(insert OID = 1136 (  "="		PGUID 0 b t t   23   26   16 1137 0 0 0 int4eqoid eqsel eqjoinsel ));
-DATA(insert OID = 1137 (  "="		PGUID 0 b t t   26   23   16 1136 0 0 0 oideqint4 eqsel eqjoinsel ));
+DATA(insert OID = 1136 (  "="		PGUID 0 b t t	23	 26   16 1137 0 0 0 int4eqoid eqsel eqjoinsel ));
+DATA(insert OID = 1137 (  "="		PGUID 0 b t t	26	 23   16 1136 0 0 0 oideqint4 eqsel eqjoinsel ));
 
-DATA(insert OID = 1158 (  "!"		PGUID 0 r t f   21    0   23 0 0 0 0 int2fac - - ));
-DATA(insert OID = 1175 (  "!!"		PGUID 0 l t f    0   21   23 0 0 0 0 int2fac - - ));
+DATA(insert OID = 1158 (  "!"		PGUID 0 r t f	21	  0   23 0 0 0 0 int2fac - - ));
+DATA(insert OID = 1175 (  "!!"		PGUID 0 l t f	 0	 21   23 0 0 0 0 int2fac - - ));
 
 /* LIKE hacks by Keith Parks. */
 DATA(insert OID = 1207 (  "~~"	  PGUID 0 b t f  19   25  16 0 1208 0 0 namelike eqsel eqjoinsel ));
@@ -676,10 +676,10 @@ DATA(insert OID = 1203 (  "<"	   PGUID 0 b t f 869 869	 16 1205 1206 0 0 network
 DATA(insert OID = 1204 (  "<="	   PGUID 0 b t f 869 869	 16 1206 1205 0 0 network_le scalarltsel scalarltjoinsel ));
 DATA(insert OID = 1205 (  ">"	   PGUID 0 b t f 869 869	 16 1203 1204 0 0 network_gt scalargtsel scalargtjoinsel ));
 DATA(insert OID = 1206 (  ">="	   PGUID 0 b t f 869 869	 16 1204 1203 0 0 network_ge scalargtsel scalargtjoinsel ));
-DATA(insert OID = 931  (  "<<"	   PGUID 0 b t f 869 869	 16 933     0 0 0 network_sub - - ));
-DATA(insert OID = 932  (  "<<="    PGUID 0 b t f 869 869	 16 934     0 0 0 network_subeq - - ));
-DATA(insert OID = 933  (  ">>"	   PGUID 0 b t f 869 869	 16 931     0 0 0 network_sup - - ));
-DATA(insert OID = 934  (  ">>="    PGUID 0 b t f 869 869	 16 932     0 0 0 network_supeq - - ));
+DATA(insert OID = 931  (  "<<"	   PGUID 0 b t f 869 869	 16 933		0 0 0 network_sub - - ));
+DATA(insert OID = 932  (  "<<="    PGUID 0 b t f 869 869	 16 934		0 0 0 network_subeq - - ));
+DATA(insert OID = 933  (  ">>"	   PGUID 0 b t f 869 869	 16 931		0 0 0 network_sup - - ));
+DATA(insert OID = 934  (  ">>="    PGUID 0 b t f 869 869	 16 932		0 0 0 network_supeq - - ));
 
 /* CIDR type */
 DATA(insert OID = 820 (  "="	   PGUID 0 b t f 650 650	 16 820 821 0 0 network_eq eqsel eqjoinsel ));
@@ -694,7 +694,7 @@ DATA(insert OID = 828 (  ">>"	   PGUID 0 b t f 650 650	 16 826   0 0 0 network_s
 DATA(insert OID = 1004 ( ">>="	   PGUID 0 b t f 650 650	 16 827   0 0 0 network_supeq - - ));
 
 /* NUMERIC type - OID's 1700-1799 */
-DATA(insert OID = 1751 (  "-"	   PGUID 0 l t f    0 1700 1700    0    0 0 0 numeric_uminus - - ));
+DATA(insert OID = 1751 (  "-"	   PGUID 0 l t f	0 1700 1700    0	0 0 0 numeric_uminus - - ));
 DATA(insert OID = 1752 (  "="	   PGUID 0 b t f 1700 1700	 16 1752 1753 1754 1754 numeric_eq eqsel eqjoinsel ));
 DATA(insert OID = 1753 (  "<>"	   PGUID 0 b t f 1700 1700	 16 1753 1752 0 0 numeric_ne neqsel neqjoinsel ));
 DATA(insert OID = 1754 (  "<"	   PGUID 0 b t f 1700 1700	 16 1756 1757 0 0 numeric_lt scalarltsel scalarltjoinsel ));
@@ -709,12 +709,12 @@ DATA(insert OID = 1762 (  "%"	   PGUID 0 b t f 1700 1700 1700    0	0 0 0 numeric
 DATA(insert OID = 1763 (  "@"	   PGUID 0 l t f	0 1700 1700    0	0 0 0 numeric_abs - - ));
 
 /* LZTEXT type */
-DATA(insert OID = 1657 (  "="    PGUID 0 b t f 1625 1625   16 1657 1658 1659 1659 lztext_eq eqsel eqjoinsel ));
-DATA(insert OID = 1658 (  "<>"       PGUID 0 b t f 1625 1625   16 1658 1657 0 0 lztext_ne neqsel neqjoinsel ));
-DATA(insert OID = 1659 (  "<"    PGUID 0 b t f 1625 1625   16 1661 1662 0 0 lztext_lt intltsel intltjoinsel ));
-DATA(insert OID = 1660 (  "<="       PGUID 0 b t f 1625 1625   16 1662 1661 0 0 lztext_le intltsel intltjoinsel ));
-DATA(insert OID = 1661 (  ">"    PGUID 0 b t f 1625 1625   16 1659 1660 0 0 lztext_gt intgtsel intgtjoinsel ));
-DATA(insert OID = 1662 (  ">="       PGUID 0 b t f 1625 1625   16 1660 1659 0 0 lztext_ge intgtsel intgtjoinsel ));
+DATA(insert OID = 1657 (  "="	 PGUID 0 b t f 1625 1625   16 1657 1658 1659 1659 lztext_eq eqsel eqjoinsel ));
+DATA(insert OID = 1658 (  "<>"		 PGUID 0 b t f 1625 1625   16 1658 1657 0 0 lztext_ne neqsel neqjoinsel ));
+DATA(insert OID = 1659 (  "<"	 PGUID 0 b t f 1625 1625   16 1661 1662 0 0 lztext_lt intltsel intltjoinsel ));
+DATA(insert OID = 1660 (  "<="		 PGUID 0 b t f 1625 1625   16 1662 1661 0 0 lztext_le intltsel intltjoinsel ));
+DATA(insert OID = 1661 (  ">"	 PGUID 0 b t f 1625 1625   16 1659 1660 0 0 lztext_gt intgtsel intgtjoinsel ));
+DATA(insert OID = 1662 (  ">="		 PGUID 0 b t f 1625 1625   16 1660 1659 0 0 lztext_ge intgtsel intgtjoinsel ));
 
 DATA(insert OID = 1784 (  "="	  PGUID 0 b t f 1560 1560	16 1784 1785 1786 1786 biteq eqsel eqjoinsel ));
 DATA(insert OID = 1785 (  "<>"	  PGUID 0 b t f 1560 1560	16 1785 1784	0	 0 bitne neqsel neqjoinsel ));
@@ -722,7 +722,7 @@ DATA(insert OID = 1786 (  "<"	  PGUID 0 b t f 1560 1560	16 1787 1789	0	 0 bitlt
 DATA(insert OID = 1787 (  ">"	  PGUID 0 b t f 1560 1560	16 1786 1788	0	 0 bitgt intgtsel intgtjoinsel ));
 DATA(insert OID = 1788 (  "<="	  PGUID 0 b t f 1560 1560	16 1789 1787	0	 0 bitle intltsel intltjoinsel ));
 DATA(insert OID = 1789 (  ">="	  PGUID 0 b t f 1560 1560	16 1788 1786	0	 0 bitge intgtsel intgtjoinsel ));
-DATA(insert OID = 1790 (  "<=>"	  PGUID 0 b t f 1560 1560	23	  0    0	0	 0 bitcmp - - ));
+DATA(insert OID = 1790 (  "<=>"   PGUID 0 b t f 1560 1560	23	  0    0	0	 0 bitcmp - - ));
 DATA(insert OID = 1791 (  "&"	  PGUID 0 b t f 1560 1560 1560	  0    0	0	 0 bitand - - ));
 DATA(insert OID = 1792 (  "|"	  PGUID 0 b t f 1560 1560 1560	  0    0	0	 0 bitor - - ));
 DATA(insert OID = 1793 (  "^"	  PGUID 0 b t f 1560 1560 1560	  0    0	0	 0 bitxor - - ));
@@ -737,7 +737,7 @@ DATA(insert OID = 1806 (  "<"	  PGUID 0 b t f 1562 1562	16 1807 1809	0	 0 varbit
 DATA(insert OID = 1807 (  ">"	  PGUID 0 b t f 1562 1562	16 1806 1808	0	 0 varbitgt intgtsel intgtjoinsel ));
 DATA(insert OID = 1808 (  "<="	  PGUID 0 b t f 1562 1562	16 1809 1807	0	 0 varbitle intltsel intltjoinsel ));
 DATA(insert OID = 1809 (  ">="	  PGUID 0 b t f 1562 1562	16 1808 1806	0	 0 varbitge intgtsel intgtjoinsel ));
-DATA(insert OID = 1810 (  "<=>"	  PGUID 0 b t f 1562 1562	23	  0    0	0	 0 varbitcmp - - ));
+DATA(insert OID = 1810 (  "<=>"   PGUID 0 b t f 1562 1562	23	  0    0	0	 0 varbitcmp - - ));
 DATA(insert OID = 1811 (  "&"	  PGUID 0 b t f 1562 1562 1562	  0    0	0	 0 varbitand - - ));
 DATA(insert OID = 1812 (  "|"	  PGUID 0 b t f 1562 1562 1562	  0    0	0	 0 varbitor - - ));
 DATA(insert OID = 1813 (  "^"	  PGUID 0 b t f 1562 1562 1562	  0    0	0	 0 varbitxor - - ));
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index c38c1c84a4332bbeb2792ea8cd26795090d5ad95..34d4494b238a6b83328c49e7d4e6915c5ab32e71 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_proc.h,v 1.131 2000/04/08 02:13:00 thomas Exp $
+ * $Id: pg_proc.h,v 1.132 2000/04/12 17:16:29 momjian Exp $
  *
  * NOTES
  *	  The script catalog/genbki.sh reads this file and generates .bki
@@ -94,7 +94,7 @@ typedef FormData_pg_proc *Form_pg_proc;
 /* keep the following ordered by OID so that later changes can be made easier */
 
 /* OIDS 1 - 99 */
-DATA(insert OID = 12  (  update_pg_pwd     PGUID 11 f t f 0 f 0  ""  100 0 0 100  update_pg_pwd - ));
+DATA(insert OID = 12  (  update_pg_pwd	   PGUID 11 f t f 0 f 0  ""  100 0 0 100  update_pg_pwd - ));
 DESCR("update pg_pwd file");
 
 DATA(insert OID = 1242 (  boolin		   PGUID 11 f t t 1 f 16 "0" 100 0 0  100  boolin - ));
@@ -406,7 +406,7 @@ DATA(insert OID = 194 (  rt_box_inter	   PGUID 11 f t t 2 f 603 "603 603" 100 0
 DESCR("r-tree");
 DATA(insert OID = 195 (  rt_box_size	   PGUID 11 f t t 2 f 700 "603 700" 100 0 0 100  rt_box_size - ));
 DESCR("r-tree");
-DATA(insert OID = 196 (  rt_bigbox_size	   PGUID 11 f t t 2 f 700 "603 700" 100 0 0 100  rt_bigbox_size - ));
+DATA(insert OID = 196 (  rt_bigbox_size    PGUID 11 f t t 2 f 700 "603 700" 100 0 0 100  rt_bigbox_size - ));
 DESCR("r-tree");
 DATA(insert OID = 197 (  rt_poly_union	   PGUID 11 f t t 2 f 604 "604 604" 100 0 0 100  rt_poly_union - ));
 DESCR("r-tree");
@@ -552,19 +552,19 @@ DATA(insert OID = 264 (  tintervalct	   PGUID 11 f t f 2 f 16 "704 704" 100 0 0
 DESCR("less-than");
 DATA(insert OID = 265 (  tintervalov	   PGUID 11 f t f 2 f 16 "704 704" 100 0 0 100	tintervalov - ));
 DESCR("overlaps");
-DATA(insert OID = 266 (  tintervalleneq	   PGUID 11 f t f 2 f 16 "704 703" 100 0 0 100	tintervalleneq - ));
+DATA(insert OID = 266 (  tintervalleneq    PGUID 11 f t f 2 f 16 "704 703" 100 0 0 100	tintervalleneq - ));
 DESCR("length equal");
-DATA(insert OID = 267 (  tintervallenne	   PGUID 11 f t f 2 f 16 "704 703" 100 0 0 100	tintervallenne - ));
+DATA(insert OID = 267 (  tintervallenne    PGUID 11 f t f 2 f 16 "704 703" 100 0 0 100	tintervallenne - ));
 DESCR("length not equal to");
-DATA(insert OID = 268 (  tintervallenlt	   PGUID 11 f t f 2 f 16 "704 703" 100 0 0 100	tintervallenlt - ));
+DATA(insert OID = 268 (  tintervallenlt    PGUID 11 f t f 2 f 16 "704 703" 100 0 0 100	tintervallenlt - ));
 DESCR("length less-than");
-DATA(insert OID = 269 (  tintervallengt	   PGUID 11 f t f 2 f 16 "704 703" 100 0 0 100	tintervallengt - ));
+DATA(insert OID = 269 (  tintervallengt    PGUID 11 f t f 2 f 16 "704 703" 100 0 0 100	tintervallengt - ));
 DESCR("length greater-than");
-DATA(insert OID = 270 (  tintervallenle	   PGUID 11 f t f 2 f 16 "704 703" 100 0 0 100	tintervallenle - ));
+DATA(insert OID = 270 (  tintervallenle    PGUID 11 f t f 2 f 16 "704 703" 100 0 0 100	tintervallenle - ));
 DESCR("length less-than-or-equal");
-DATA(insert OID = 271 (  tintervallenge	   PGUID 11 f t f 2 f 16 "704 703" 100 0 0 100	tintervallenge - ));
+DATA(insert OID = 271 (  tintervallenge    PGUID 11 f t f 2 f 16 "704 703" 100 0 0 100	tintervallenge - ));
 DESCR("length greater-than-or-equal");
-DATA(insert OID = 272 (  tintervalstart	   PGUID 11 f t f 1 f 702 "704" 100 0 0 100  tintervalstart - ));
+DATA(insert OID = 272 (  tintervalstart    PGUID 11 f t f 1 f 702 "704" 100 0 0 100  tintervalstart - ));
 DESCR("start of interval");
 DATA(insert OID = 273 (  tintervalend	   PGUID 11 f t f 1 f 702 "704" 100 0 0 100  tintervalend - ));
 DESCR("");
@@ -717,11 +717,11 @@ DATA(insert OID = 341 (  poly_left		   PGUID 11 f t t 2 f 16 "604 604" 100 0 1 0
 DESCR("is left of");
 DATA(insert OID = 342 (  poly_overleft	   PGUID 11 f t t 2 f 16 "604 604" 100 0 1 0  poly_overleft - ));
 DESCR("overlaps, but does not extend to right of");
-DATA(insert OID = 343 (  poly_overright	   PGUID 11 f t t 2 f 16 "604 604" 100 0 1 0  poly_overright - ));
+DATA(insert OID = 343 (  poly_overright    PGUID 11 f t t 2 f 16 "604 604" 100 0 1 0  poly_overright - ));
 DESCR("overlaps, but does not extend to left of");
 DATA(insert OID = 344 (  poly_right		   PGUID 11 f t t 2 f 16 "604 604" 100 0 1 0  poly_right - ));
 DESCR("is left of");
-DATA(insert OID = 345 (  poly_contained	   PGUID 11 f t t 2 f 16 "604 604" 100 0 1 0  poly_contained - ));
+DATA(insert OID = 345 (  poly_contained    PGUID 11 f t t 2 f 16 "604 604" 100 0 1 0  poly_contained - ));
 DESCR("contained in");
 DATA(insert OID = 346 (  poly_overlap	   PGUID 11 f t t 2 f 16 "604 604" 100 0 1 0  poly_overlap - ));
 DESCR("overlaps");
@@ -746,7 +746,7 @@ DATA(insert OID = 355 (  btfloat8cmp	   PGUID 11 f t t 2 f 23 "701 701" 100 0 0
 DESCR("btree less-equal-greater");
 DATA(insert OID = 356 (  btoidcmp		   PGUID 11 f t t 2 f 23 "26 26" 100 0 0 100  btoidcmp - ));
 DESCR("btree less-equal-greater");
-DATA(insert OID = 404 (  btoidvectorcmp	   PGUID 11 f t t 2 f 23 "30 30" 100 0 0 100  btoidvectorcmp - ));
+DATA(insert OID = 404 (  btoidvectorcmp    PGUID 11 f t t 2 f 23 "30 30" 100 0 0 100  btoidvectorcmp - ));
 DESCR("btree less-equal-greater");
 DATA(insert OID = 357 (  btabstimecmp	   PGUID 11 f t f 2 f 23 "702 702" 100 0 0 100	btabstimecmp - ));
 DESCR("btree less-equal-greater");
@@ -773,7 +773,7 @@ DATA(insert OID = 367 (  close_pb		   PGUID 11 f t t 2 f 600 "600 603" 100 0 0 1
 DESCR("closest point on box");
 DATA(insert OID = 368 (  close_sb		   PGUID 11 f t t 2 f 600 "601 603" 100 0 0 100  close_sb - ));
 DESCR("closest point to line segment on box");
-DATA(insert OID = 369 (  on_ps			   PGUID 11 f t t 2 f 16 "600 601" 100 0 0 100  on_ps - ));
+DATA(insert OID = 369 (  on_ps			   PGUID 11 f t t 2 f 16 "600 601" 100 0 0 100	on_ps - ));
 DESCR("point contained in segment");
 DATA(insert OID = 370 (  path_distance	   PGUID 11 f t t 2 f 701 "602 602" 100 0 1 0  path_distance - ));
 DESCR("distance between paths");
@@ -1267,13 +1267,13 @@ DATA(insert OID = 989 (  point_vert		   PGUID 11 f t t 2 f 16 "600 600" 100 0 0
 DESCR("vertical?");
 DATA(insert OID = 990 (  point_horiz	   PGUID 11 f t t 2 f 16 "600 600" 100 0 0 100	point_horiz - ));
 DESCR("horizontal?");
-DATA(insert OID = 991 (  point_distance	   PGUID 11 f t t 2 f 701 "600 600" 100 0 0 100  point_distance - ));
+DATA(insert OID = 991 (  point_distance    PGUID 11 f t t 2 f 701 "600 600" 100 0 0 100  point_distance - ));
 DESCR("distance between");
 DATA(insert OID = 992 (  slope			   PGUID 11 f t t 2 f 701 "600 600" 100 0 0 100  point_slope - ));
 DESCR("slope between points");
 DATA(insert OID = 993 (  lseg			   PGUID 11 f t t 2 f 601 "600 600" 100 0 0 100  lseg_construct - ));
 DESCR("convert points to line segment");
-DATA(insert OID = 994 (  lseg_intersect	   PGUID 11 f t t 2 f 16 "601 601" 100 0 0 100	lseg_intersect - ));
+DATA(insert OID = 994 (  lseg_intersect    PGUID 11 f t t 2 f 16 "601 601" 100 0 0 100	lseg_intersect - ));
 DESCR("intersects?");
 DATA(insert OID = 995 (  lseg_parallel	   PGUID 11 f t t 2 f 16 "601 601" 100 0 0 100	lseg_parallel - ));
 DESCR("parallel?");
@@ -1406,7 +1406,7 @@ DESCR("divide");
 
 DATA(insert OID = 1150 (  timestamp_in	   PGUID 11 f t f 1 f 1184 "0" 100 0 0 100	timestamp_in - ));
 DESCR("(internal)");
-DATA(insert OID = 1151 (  timestamp_out	   PGUID 11 f t f 1 f	23 "0" 100 0 0 100	timestamp_out - ));
+DATA(insert OID = 1151 (  timestamp_out    PGUID 11 f t f 1 f	23 "0" 100 0 0 100	timestamp_out - ));
 DESCR("(internal)");
 DATA(insert OID = 1152 (  timestamp_eq	   PGUID 11 f t f 2 f	16 "1184 1184" 100 0 0 100	timestamp_eq - ));
 DESCR("equal");
@@ -1441,53 +1441,53 @@ DATA(insert OID = 1167 (  interval_gt	   PGUID 11 f t f 2 f 16 "1186 1186" 100 0
 DESCR("greater-than");
 DATA(insert OID = 1168 (  interval_um	   PGUID 11 f t f 1 f 1186 "1186" 100 0 0 100  interval_um - ));
 DESCR("subtract");
-DATA(insert OID = 1169 (  interval_pl	   PGUID 11 f t f 2 f 1186 "1186 1186" 100 0 0 100  interval_pl - ));
+DATA(insert OID = 1169 (  interval_pl	   PGUID 11 f t f 2 f 1186 "1186 1186" 100 0 0 100	interval_pl - ));
 DESCR("addition");
-DATA(insert OID = 1170 (  interval_mi	   PGUID 11 f t f 2 f 1186 "1186 1186" 100 0 0 100  interval_mi - ));
+DATA(insert OID = 1170 (  interval_mi	   PGUID 11 f t f 2 f 1186 "1186 1186" 100 0 0 100	interval_mi - ));
 DESCR("subtract");
 DATA(insert OID = 1171 (  date_part		   PGUID 11 f t f 2 f  701 "25 1184" 100 0 0 100  timestamp_part - ));
 DESCR("extract field from timestamp");
 DATA(insert OID = 1172 (  date_part		   PGUID 11 f t f 2 f  701 "25 1186" 100 0 0 100  interval_part - ));
 DESCR("extract field from interval");
 
-DATA(insert OID = 1173 (  timestamp		   PGUID 11 f t f 1 f 1184  "702" 100 0 0 100  abstime_timestamp - ));
+DATA(insert OID = 1173 (  timestamp		   PGUID 11 f t f 1 f 1184	"702" 100 0 0 100  abstime_timestamp - ));
 DESCR("convert abstime to timestamp");
 DATA(insert OID = 1174 (  timestamp		   PGUID 11 f t f 1 f 1184 "1082" 100 0 0 100  date_timestamp - ));
 DESCR("convert date to timestamp");
-DATA(insert OID = 1176 (  timestamp		   PGUID 11 f t f 2 f 1184 "1082 1083" 100 0 0 100  datetime_timestamp - ));
+DATA(insert OID = 1176 (  timestamp		   PGUID 11 f t f 2 f 1184 "1082 1083" 100 0 0 100	datetime_timestamp - ));
 DESCR("convert date and time to timestamp");
-DATA(insert OID = 1177 (  interval		   PGUID 11 f t f 1 f 1186  "703" 100 0 0 100  reltime_interval - ));
+DATA(insert OID = 1177 (  interval		   PGUID 11 f t f 1 f 1186	"703" 100 0 0 100  reltime_interval - ));
 DESCR("convert reltime to interval");
 DATA(insert OID = 1178 (  date			   PGUID 11 f t f 1 f 1082 "1184" 100 0 0 100  timestamp_date - ));
 DESCR("convert timestamp to date");
-DATA(insert OID = 1179 (  date			   PGUID 11 f t f 1 f 1082  "702" 100 0 0 100  abstime_date - ));
+DATA(insert OID = 1179 (  date			   PGUID 11 f t f 1 f 1082	"702" 100 0 0 100  abstime_date - ));
 DESCR("convert abstime to date");
 DATA(insert OID = 1180 (  abstime		   PGUID 11 f t f 1 f  702 "1184" 100 0 0 100  timestamp_abstime - ));
 DESCR("convert timestamp to abstime");
 
 DATA(insert OID = 1188 (  timestamp_mi		PGUID 11 f t f 2 f 1186 "1184 1184" 100 0 0 100  timestamp_mi - ));
 DESCR("subtract");
-DATA(insert OID = 1189 (  timestamp_pl_span	PGUID 11 f t f 2 f 1184 "1184 1186" 100 0 0 100  timestamp_pl_span - ));
+DATA(insert OID = 1189 (  timestamp_pl_span PGUID 11 f t f 2 f 1184 "1184 1186" 100 0 0 100  timestamp_pl_span - ));
 DESCR("plus");
-DATA(insert OID = 1190 (  timestamp_mi_span	PGUID 11 f t f 2 f 1184 "1184 1186" 100 0 0 100  timestamp_mi_span - ));
+DATA(insert OID = 1190 (  timestamp_mi_span PGUID 11 f t f 2 f 1184 "1184 1186" 100 0 0 100  timestamp_mi_span - ));
 DESCR("minus");
 DATA(insert OID = 1191 (  timestamp			PGUID 11 f t f 1 f 1184 "25" 100 0 0 100  text_timestamp - ));
 DESCR("convert text to timestamp");
-DATA(insert OID = 1192 (  text				PGUID 11 f t f 1 f   25 "1184" 100 0 0 100  timestamp_text - ));
+DATA(insert OID = 1192 (  text				PGUID 11 f t f 1 f	 25 "1184" 100 0 0 100	timestamp_text - ));
 DESCR("convert timestamp to text");
-DATA(insert OID = 1193 (  text				PGUID 11 f t f 1 f   25 "1186" 100 0 0 100  interval_text - ));
+DATA(insert OID = 1193 (  text				PGUID 11 f t f 1 f	 25 "1186" 100 0 0 100	interval_text - ));
 DESCR("convert interval to text");
-DATA(insert OID = 1194 (  reltime			PGUID 11 f t f 1 f  703 "1186" 100 0 0 100  interval_reltime - ));
+DATA(insert OID = 1194 (  reltime			PGUID 11 f t f 1 f	703 "1186" 100 0 0 100	interval_reltime - ));
 DESCR("convert interval to reltime");
-DATA(insert OID = 1195 (  timestamp_smaller	PGUID 11 f t f 2 f 1184 "1184 1184" 100 0 0 100  timestamp_smaller - ));
+DATA(insert OID = 1195 (  timestamp_smaller PGUID 11 f t f 2 f 1184 "1184 1184" 100 0 0 100  timestamp_smaller - ));
 DESCR("smaller of two");
 DATA(insert OID = 1196 (  timestamp_larger	PGUID 11 f t f 2 f 1184 "1184 1184" 100 0 0 100  timestamp_larger - ));
 DESCR("larger of two");
 DATA(insert OID = 1197 (  interval_smaller	PGUID 11 f t f 2 f 1186 "1186 1186" 100 0 0 100  interval_smaller - ));
 DESCR("smaller of two");
-DATA(insert OID = 1198 (  interval_larger   PGUID 11 f t f 2 f 1186 "1186 1186" 100 0 0 100  interval_larger - ));
+DATA(insert OID = 1198 (  interval_larger	PGUID 11 f t f 2 f 1186 "1186 1186" 100 0 0 100  interval_larger - ));
 DESCR("larger of two");
-DATA(insert OID = 1199 (  age			    PGUID 11 f t f 2 f 1186 "1184 1184" 100 0 0 100  timestamp_age - ));
+DATA(insert OID = 1199 (  age				PGUID 11 f t f 2 f 1186 "1184 1184" 100 0 0 100  timestamp_age - ));
 DESCR("date difference preserving months and years");
 
 /* OIDS 1200 - 1299 */
@@ -1527,7 +1527,7 @@ DESCR("convert text to interval");
 
 DATA(insert OID = 1271 (  overlaps		   PGUID 11 f t t 4 f 16 "1266 1266 1266 1266" 100 0 1 0  overlaps_timetz - ));
 DESCR("SQL92 interval comparison");
-DATA(insert OID = 1272 (  datetime_pl	   PGUID 11 f t f 2 f 1184 "1082 1083" 100 0 0 100  datetime_timestamp - ));
+DATA(insert OID = 1272 (  datetime_pl	   PGUID 11 f t f 2 f 1184 "1082 1083" 100 0 0 100	datetime_timestamp - ));
 DESCR("convert date and time to timestamp");
 
 DATA(insert OID = 1274 (  int84pl		   PGUID 11 f t t 2 f 20 "20 23" 100 0 0 100  int84pl - ));
@@ -1564,11 +1564,11 @@ DESCR("latest tid of a tuple");
 DATA(insert OID = 1294 ( currtid2		   PGUID 11 f t f 2 f 27 "25 27" 100 0 0 100  currtid_byrelname - ));
 DESCR("latest tid of a tuple");
 
-DATA(insert OID = 1296 (  timedate_pl	   PGUID 14 f t f 2 f 1184 "1083 1082" 100 0 0 100  "select datetime_pl($2, $1)" - ));
+DATA(insert OID = 1296 (  timedate_pl	   PGUID 14 f t f 2 f 1184 "1083 1082" 100 0 0 100	"select datetime_pl($2, $1)" - ));
 DESCR("convert time and date to timestamp");
-DATA(insert OID = 1297 (  datetimetz_pl	   PGUID 11 f t f 2 f 1184 "1082 1266" 100 0 0 100  datetimetz_timestamp - ));
+DATA(insert OID = 1297 (  datetimetz_pl    PGUID 11 f t f 2 f 1184 "1082 1266" 100 0 0 100	datetimetz_timestamp - ));
 DESCR("convert date and time with time zone to timestamp");
-DATA(insert OID = 1298 (  timetzdate_pl	   PGUID 14 f t f 2 f 1184 "1266 1082" 100 0 0 100  "select datetimetz_pl($2, $1)" - ));
+DATA(insert OID = 1298 (  timetzdate_pl    PGUID 14 f t f 2 f 1184 "1266 1082" 100 0 0 100	"select datetimetz_pl($2, $1)" - ));
 DESCR("convert time with time zone and date to timestamp");
 DATA(insert OID = 1299 (  now			   PGUID 11 f t f 0 f 1184 "0" 100 0 0 100	now - ));
 DESCR("current transaction time");
@@ -1584,22 +1584,22 @@ DESCR("restriction selectivity for containment comparison operators");
 DATA(insert OID = 1303 (  contjoinsel	   PGUID 11 f t f 5 f 701 "26 26 21 26 21" 100 0 0 100	contjoinsel - ));
 DESCR("join selectivity for containment comparison operators");
 
-DATA(insert OID = 1304 ( overlaps			 PGUID 11 f t t 4 f 16 "1184 1184 1184 1184" 100 0 1 0  overlaps_timestamp - ));
+DATA(insert OID = 1304 ( overlaps			 PGUID 11 f t t 4 f 16 "1184 1184 1184 1184" 100 0 1 0	overlaps_timestamp - ));
 DESCR("SQL92 interval comparison");
-DATA(insert OID = 1305 ( overlaps			 PGUID 14 f t t 4 f 16 "1184 1186 1184 1186" 100 0 1 0  "select overlaps($1, ($1 + $2), $3, ($3 + $4))" - ));
+DATA(insert OID = 1305 ( overlaps			 PGUID 14 f t t 4 f 16 "1184 1186 1184 1186" 100 0 1 0	"select overlaps($1, ($1 + $2), $3, ($3 + $4))" - ));
 DESCR("SQL92 interval comparison");
-DATA(insert OID = 1306 ( overlaps			 PGUID 14 f t t 4 f 16 "1184 1184 1184 1186" 100 0 1 0  "select overlaps($1, $2, $3, ($3 + $4))" - ));
+DATA(insert OID = 1306 ( overlaps			 PGUID 14 f t t 4 f 16 "1184 1184 1184 1186" 100 0 1 0	"select overlaps($1, $2, $3, ($3 + $4))" - ));
 DESCR("SQL92 interval comparison");
-DATA(insert OID = 1307 ( overlaps			 PGUID 14 f t t 4 f 16 "1184 1186 1184 1184" 100 0 1 0  "select overlaps($1, ($1 + $2), $3, $4)" - ));
+DATA(insert OID = 1307 ( overlaps			 PGUID 14 f t t 4 f 16 "1184 1186 1184 1184" 100 0 1 0	"select overlaps($1, ($1 + $2), $3, $4)" - ));
 DESCR("SQL92 interval comparison");
 
-DATA(insert OID = 1308 ( overlaps			 PGUID 11 f t t 4 f 16 "1083 1083 1083 1083" 100 0 1 0  overlaps_time - ));
+DATA(insert OID = 1308 ( overlaps			 PGUID 11 f t t 4 f 16 "1083 1083 1083 1083" 100 0 1 0	overlaps_time - ));
 DESCR("SQL92 interval comparison");
-DATA(insert OID = 1309 ( overlaps			 PGUID 14 f t t 4 f 16 "1083 1186 1083 1186" 100 0 1 0  "select overlaps($1, ($1 + $2), $3, ($3 + $4))" - ));
+DATA(insert OID = 1309 ( overlaps			 PGUID 14 f t t 4 f 16 "1083 1186 1083 1186" 100 0 1 0	"select overlaps($1, ($1 + $2), $3, ($3 + $4))" - ));
 DESCR("SQL92 interval comparison");
-DATA(insert OID = 1310 ( overlaps			 PGUID 14 f t t 4 f 16 "1083 1083 1083 1186" 100 0 1 0  "select overlaps($1, $2, $3, ($3 + $4))" - ));
+DATA(insert OID = 1310 ( overlaps			 PGUID 14 f t t 4 f 16 "1083 1083 1083 1186" 100 0 1 0	"select overlaps($1, $2, $3, ($3 + $4))" - ));
 DESCR("SQL92 interval comparison");
-DATA(insert OID = 1311 ( overlaps			 PGUID 14 f t t 4 f 16 "1083 1186 1083 1083" 100 0 1 0  "select overlaps($1, ($1 + $2), $3, $4)" - ));
+DATA(insert OID = 1311 ( overlaps			 PGUID 14 f t t 4 f 16 "1083 1186 1083 1083" 100 0 1 0	"select overlaps($1, ($1 + $2), $3, $4)" - ));
 DESCR("SQL92 interval comparison");
 
 DATA(insert OID = 1314 (  timestamp_cmp		 PGUID 11 f t f 2 f   23 "1184 1184" 100 0 0 100  timestamp_cmp - ));
@@ -1662,7 +1662,7 @@ DATA(insert OID = 1357 (  timetz_gt		   PGUID 11 f t t 2 f 16 "1266 1266" 100 0
 DESCR("greater-than");
 DATA(insert OID = 1358 (  timetz_cmp	   PGUID 11 f t t 2 f 23 "1266 1266" 100 0 0 100  timetz_cmp - ));
 DESCR("less-equal-greater");
-DATA(insert OID = 1359 (  timestamp		   PGUID 11 f t f 2 f 1184 "1082 1266" 100 0 0 100  datetimetz_timestamp - ));
+DATA(insert OID = 1359 (  timestamp		   PGUID 11 f t f 2 f 1184 "1082 1266" 100 0 0 100	datetimetz_timestamp - ));
 DESCR("convert date and time with time zone to timestamp");
 
 DATA(insert OID = 1362 (  time				 PGUID 14 f t t 1 f 1083 "1083" 100 0 0 100  "select $1" - ));
@@ -1697,7 +1697,7 @@ DATA(insert OID = 1377 (  time_larger	   PGUID 11 f t t 2 f 1083 "1083 1083" 100
 DESCR("larger of two");
 DATA(insert OID = 1378 (  time_smaller	   PGUID 11 f t t 2 f 1083 "1083 1083" 100 0 0 100	time_smaller - ));
 DESCR("smaller of two");
-DATA(insert OID = 1379 (  timetz_larger	   PGUID 11 f t t 2 f 1083 "1266 1266" 100 0 0 100	timetz_larger - ));
+DATA(insert OID = 1379 (  timetz_larger    PGUID 11 f t t 2 f 1083 "1266 1266" 100 0 0 100	timetz_larger - ));
 DESCR("larger of two");
 DATA(insert OID = 1380 (  timetz_smaller   PGUID 11 f t t 2 f 1083 "1266 1266" 100 0 0 100	timetz_smaller - ));
 DESCR("smaller of two");
@@ -1760,17 +1760,17 @@ DESCR("convert (no-op)");
 DATA(insert OID = 1405 (  int4		   PGUID 14 f t t 1 f	23	 "23" 100 0 0 100  "select $1" - ));
 DESCR("convert (no-op)");
 
-DATA(insert OID = 1406 (  isvertical		PGUID 11 f t t 2 f  16 "600 600" 100 0 0 100	point_vert - ));
+DATA(insert OID = 1406 (  isvertical		PGUID 11 f t t 2 f	16 "600 600" 100 0 0 100	point_vert - ));
 DESCR("vertical?");
-DATA(insert OID = 1407 (  ishorizontal		PGUID 11 f t t 2 f  16 "600 600" 100 0 0 100	point_horiz - ));
+DATA(insert OID = 1407 (  ishorizontal		PGUID 11 f t t 2 f	16 "600 600" 100 0 0 100	point_horiz - ));
 DESCR("horizontal?");
-DATA(insert OID = 1408 (  isparallel		PGUID 11 f t t 2 f  16 "601 601" 100 0 0 100	lseg_parallel - ));
+DATA(insert OID = 1408 (  isparallel		PGUID 11 f t t 2 f	16 "601 601" 100 0 0 100	lseg_parallel - ));
 DESCR("parallel?");
-DATA(insert OID = 1409 (  isperp			PGUID 11 f t t 2 f  16 "601 601" 100 0 0 100	lseg_perp - ));
+DATA(insert OID = 1409 (  isperp			PGUID 11 f t t 2 f	16 "601 601" 100 0 0 100	lseg_perp - ));
 DESCR("perpendicular?");
-DATA(insert OID = 1410 (  isvertical		PGUID 11 f t t 1 f  16 "601" 100 0 0 100	lseg_vertical - ));
+DATA(insert OID = 1410 (  isvertical		PGUID 11 f t t 1 f	16 "601" 100 0 0 100	lseg_vertical - ));
 DESCR("vertical?");
-DATA(insert OID = 1411 (  ishorizontal		PGUID 11 f t t 1 f  16 "601" 100 0 0 100	lseg_horizontal - ));
+DATA(insert OID = 1411 (  ishorizontal		PGUID 11 f t t 1 f	16 "601" 100 0 0 100	lseg_horizontal - ));
 DESCR("horizontal?");
 DATA(insert OID = 1412 (  isparallel		PGUID 11 f t t 2 f	16 "628 628" 100 0 0 100  line_parallel - ));
 DESCR("lines parallel?");
@@ -1797,7 +1797,7 @@ DATA(insert OID = 1426 (  path_contain_pt	PGUID 14 f t t 2 f	16 "602 600" 100 0
 DESCR("path contains point?");
 DATA(insert OID = 1428 (  poly_contain_pt	PGUID 11 f t t 2 f	16 "604 600" 100 0 0 100  poly_contain_pt - ));
 DESCR("polygon contains point?");
-DATA(insert OID = 1429 (  pt_contained_poly	PGUID 11 f t t 2 f	16 "600 604" 100 0 0 100  pt_contained_poly - ));
+DATA(insert OID = 1429 (  pt_contained_poly PGUID 11 f t t 2 f	16 "600 604" 100 0 0 100  pt_contained_poly - ));
 DESCR("point contained by polygon?");
 
 DATA(insert OID = 1430 (  isclosed			PGUID 11 f t t 1 f	16 "602" 100 0 0 100  path_isclosed - ));
@@ -1902,9 +1902,9 @@ DATA(insert OID = 1475 (  polygon			PGUID 11 f t t 2 f 604 "23 718" 100 0 1 0  c
 DESCR("convert vertex count and circle to polygon");
 DATA(insert OID = 1476 (  dist_pc			PGUID 11 f t t 2 f 701 "600 718" 100 0 1 0	dist_pc - ));
 DESCR("distance between point and circle");
-DATA(insert OID = 1477 (  circle_contain_pt	PGUID 11 f t t 2 f  16 "718 600" 100 0 0 100  circle_contain_pt - ));
+DATA(insert OID = 1477 (  circle_contain_pt PGUID 11 f t t 2 f	16 "718 600" 100 0 0 100  circle_contain_pt - ));
 DESCR("circle contains point?");
-DATA(insert OID = 1478 (  pt_contained_circle	PGUID 11 f t t 2 f  16 "600 718" 100 0 0 100  pt_contained_circle - ));
+DATA(insert OID = 1478 (  pt_contained_circle	PGUID 11 f t t 2 f	16 "600 718" 100 0 0 100  pt_contained_circle - ));
 DESCR("point inside circle?");
 DATA(insert OID = 1479 (  circle			PGUID 11 f t t 1 f 718 "603" 100 0 1 0	box_circle - ));
 DESCR("convert box to circle");
@@ -1955,7 +1955,7 @@ DESCR("lines horizontal?");
 
 DATA(insert OID = 1530 (  length			PGUID 11 f t t 1 f 701 "601" 100 0 1 0	lseg_length - ));
 DESCR("distance between endpoints");
-DATA(insert OID = 1531 (  length			PGUID 11 f t t 1 f 701 "602" 100 0 1 0  path_length - ));
+DATA(insert OID = 1531 (  length			PGUID 11 f t t 1 f 701 "602" 100 0 1 0	path_length - ));
 DESCR("sum of path segments");
 
 
@@ -1982,7 +1982,7 @@ DESCR("number of points in polygon");
 
 DATA(insert OID = 1564 (  zpbit_in			PGUID 11 f t t 1 f 1560 "0" 100 0 0 100  zpbit_in - ));
 DESCR("(internal)");
-DATA(insert OID = 1565 (  zpbit_out			PGUID 11 f t t 1 f   23 "0" 100 0 0 100  zpbit_out - ));
+DATA(insert OID = 1565 (  zpbit_out			PGUID 11 f t t 1 f	 23 "0" 100 0 0 100  zpbit_out - ));
 DESCR("(internal)");
 
 DATA(insert OID = 1569 (  like				PGUID 11 f t t 2 f 16 "25 25" 100 0 1 0  textlike - ));
@@ -1998,16 +1998,16 @@ DESCR("convert int8 to int8 (no-op)");
 
 
 /* SEQUENCEs nextval & currval functions */
-DATA(insert OID = 1574 (  nextval			PGUID 11 f t f 1 f 23 "25" 100 0 0 100  nextval - ));
+DATA(insert OID = 1574 (  nextval			PGUID 11 f t f 1 f 23 "25" 100 0 0 100	nextval - ));
 DESCR("sequence next value");
-DATA(insert OID = 1575 (  currval			PGUID 11 f t f 1 f 23 "25" 100 0 0 100  currval - ));
+DATA(insert OID = 1575 (  currval			PGUID 11 f t f 1 f 23 "25" 100 0 0 100	currval - ));
 DESCR("sequence current value");
 DATA(insert OID = 1576 (  setval			PGUID 11 f t f 2 f 23 "25 23" 100 0 0 100  setval - ));
 DESCR("sequence set value");
 
 DATA(insert OID = 1579 (  varbit_in			PGUID 11 f t t 1 f 1562 "0" 100 0 0 100  varbit_in - ));
 DESCR("(internal)");
-DATA(insert OID = 1580 (  varbit_out		PGUID 11 f t t 1 f   23 "0" 100 0 0 100  varbit_out - ));
+DATA(insert OID = 1580 (  varbit_out		PGUID 11 f t t 1 f	 23 "0" 100 0 0 100  varbit_out - ));
 DESCR("(internal)");
 
 DATA(insert OID = 1581 (  biteq				PGUID 11 f t t 2 f 16 "1560 1560" 100 0 1 0  biteq - ));
@@ -2025,9 +2025,9 @@ DESCR("less than");
 DATA(insert OID = 1596 (  bitcmp			PGUID 11 f t t 2 f 23 "1560 1560" 100 0 1 0  bitcmp - ));
 DESCR("compare");
 
-DATA(insert OID = 1598 (  random			PGUID 11 f t f 0 f 701 "0" 100 0 0 100  drandom - ));
+DATA(insert OID = 1598 (  random			PGUID 11 f t f 0 f 701 "0" 100 0 0 100	drandom - ));
 DESCR("radians to degrees");
-DATA(insert OID = 1599 (  setseed			PGUID 11 f t t 1 f  23 "701" 100 0 0 100  setseed - ));
+DATA(insert OID = 1599 (  setseed			PGUID 11 f t t 1 f	23 "701" 100 0 0 100  setseed - ));
 DESCR("radians to degrees");
 
 /* OIDS 1600 - 1699 */
@@ -2052,55 +2052,55 @@ DATA(insert OID = 1608 (  degrees			PGUID 11 f t t 1 f 701 "701" 100 0 0 100  de
 DESCR("radians to degrees");
 DATA(insert OID = 1609 (  radians			PGUID 11 f t t 1 f 701 "701" 100 0 0 100  radians - ));
 DESCR("radians to degrees");
-DATA(insert OID = 1610 (  pi				PGUID 11 f t t 0 f 701 "0" 100 0 0 100  dpi - ));
+DATA(insert OID = 1610 (  pi				PGUID 11 f t t 0 f 701 "0" 100 0 0 100	dpi - ));
 DESCR("PI");
 
-DATA(insert OID = 1618 (  interval_mul		PGUID 11 f t t 2 f 1186 "1186 701" 100 0 0 100  interval_mul - ));
+DATA(insert OID = 1618 (  interval_mul		PGUID 11 f t t 2 f 1186 "1186 701" 100 0 0 100	interval_mul - ));
 DESCR("multiply interval");
 DATA(insert OID = 1619 (  varchar			PGUID 11 f t t 1 f 1043 "23" 100 0 0 100  int4_text - ));
 DESCR("convert int4 to varchar");
 
-DATA(insert OID = 1620 (  ascii				PGUID 11 f t t 1 f 23 "25" 100 0 0 100  ascii - ));
+DATA(insert OID = 1620 (  ascii				PGUID 11 f t t 1 f 23 "25" 100 0 0 100	ascii - ));
 DESCR("convert first char to int4");
-DATA(insert OID = 1621 (  ichar				PGUID 11 f t t 1 f 25 "23" 100 0 0 100  ichar - ));
+DATA(insert OID = 1621 (  ichar				PGUID 11 f t t 1 f 25 "23" 100 0 0 100	ichar - ));
 DESCR("convert int4 to char");
 DATA(insert OID = 1622 (  repeat			PGUID 11 f t t 2 f 25 "25 23" 100 0 0 100  repeat - ));
 DESCR("replicate string int4 times");
 
 DATA(insert OID = 1623 (  varchar			PGUID 11 f t t 1 f 1043 "20" 100 0 0 100  int8_text - ));
 DESCR("convert int8 to varchar");
-DATA(insert OID = 1624 (  mul_d_interval	PGUID 11 f t t 2 f 1186 "701 1186" 100 0 0 100  mul_d_interval - ));
+DATA(insert OID = 1624 (  mul_d_interval	PGUID 11 f t t 2 f 1186 "701 1186" 100 0 0 100	mul_d_interval - ));
 
 /* OID's 1625 - 1639 LZTEXT data type */
-DATA(insert OID = 1626 ( lztextin             PGUID 11 f t t 1 f 1625 "0" 100 0 0 100  lztextin - ));
+DATA(insert OID = 1626 ( lztextin			  PGUID 11 f t t 1 f 1625 "0" 100 0 0 100  lztextin - ));
 DESCR("(internal)");
-DATA(insert OID = 1627 ( lztextout            PGUID 11 f t t 1 f 23 "0" 100 0 0 100  lztextout - ));
+DATA(insert OID = 1627 ( lztextout			  PGUID 11 f t t 1 f 23 "0" 100 0 0 100  lztextout - ));
 DESCR("(internal)");
-DATA(insert OID = 1629 ( text                 PGUID 11 f t t 1 f 25 "1625" 100 0 0 100  lztext_text -));
+DATA(insert OID = 1629 ( text				  PGUID 11 f t t 1 f 25 "1625" 100 0 0 100	lztext_text -));
 DESCR("convert lztext to text");
-DATA(insert OID = 1631 ( lztext               PGUID 11 f t t 1 f 1625 "25" 100 0 0 100  text_lztext -));
+DATA(insert OID = 1631 ( lztext				  PGUID 11 f t t 1 f 1625 "25" 100 0 0 100	text_lztext -));
 DESCR("convert text to lztext");
-DATA(insert OID = 1632 ( lztext               PGUID 14 f t t 1 f 1625 "1625" 100 0 0 100  "select $1" -));
+DATA(insert OID = 1632 ( lztext				  PGUID 14 f t t 1 f 1625 "1625" 100 0 0 100  "select $1" -));
 DESCR("convert text to lztext");
-DATA(insert OID = 1633 ( char_length          PGUID 11 f t t 1 f 23 "1625" 100 0 1 0  lztextlen - ));
+DATA(insert OID = 1633 ( char_length		  PGUID 11 f t t 1 f 23 "1625" 100 0 1 0  lztextlen - ));
 DESCR("length");
-DATA(insert OID = 1634 ( length               PGUID 11 f t t 1 f 23 "1625" 100 0 1 0  lztextlen - ));
+DATA(insert OID = 1634 ( length				  PGUID 11 f t t 1 f 23 "1625" 100 0 1 0  lztextlen - ));
 DESCR("length");
-DATA(insert OID = 1635 ( octet_length         PGUID 11 f t t 1 f 23 "1625" 100 0 1 0  lztextoctetlen - ));
+DATA(insert OID = 1635 ( octet_length		  PGUID 11 f t t 1 f 23 "1625" 100 0 1 0  lztextoctetlen - ));
 DESCR("octet length");
-DATA(insert OID = 1636 ( lztext_cmp           PGUID 11 f t t 2 f 23 "1625 1625" 100 0 1 0  lztext_cmp - ));
+DATA(insert OID = 1636 ( lztext_cmp			  PGUID 11 f t t 2 f 23 "1625 1625" 100 0 1 0  lztext_cmp - ));
 DESCR("compare lztext");
-DATA(insert OID = 1637 ( lztext_eq            PGUID 11 f t t 2 f 16 "1625 1625" 100 0 1 0  lztext_eq - ));
+DATA(insert OID = 1637 ( lztext_eq			  PGUID 11 f t t 2 f 16 "1625 1625" 100 0 1 0  lztext_eq - ));
 DESCR("equal");
-DATA(insert OID = 1638 ( lztext_ne            PGUID 11 f t t 2 f 16 "1625 1625" 100 0 1 0  lztext_ne - ));
+DATA(insert OID = 1638 ( lztext_ne			  PGUID 11 f t t 2 f 16 "1625 1625" 100 0 1 0  lztext_ne - ));
 DESCR("not equal");
-DATA(insert OID = 1639 ( lztext_gt            PGUID 11 f t t 2 f 16 "1625 1625" 100 0 1 0  lztext_gt - ));
+DATA(insert OID = 1639 ( lztext_gt			  PGUID 11 f t t 2 f 16 "1625 1625" 100 0 1 0  lztext_gt - ));
 DESCR("greater-than");
-DATA(insert OID = 1664 ( lztext_ge            PGUID 11 f t t 2 f 16 "1625 1625" 100 0 1 0  lztext_ge - ));
+DATA(insert OID = 1664 ( lztext_ge			  PGUID 11 f t t 2 f 16 "1625 1625" 100 0 1 0  lztext_ge - ));
 DESCR("greater-than-or-equal");
-DATA(insert OID = 1665 ( lztext_lt            PGUID 11 f t t 2 f 16 "1625 1625" 100 0 1 0  lztext_lt - ));
+DATA(insert OID = 1665 ( lztext_lt			  PGUID 11 f t t 2 f 16 "1625 1625" 100 0 1 0  lztext_lt - ));
 DESCR("less-than");
-DATA(insert OID = 1656 ( lztext_le            PGUID 11 f t t 2 f 16 "1625 1625" 100 0 1 0  lztext_le - ));
+DATA(insert OID = 1656 ( lztext_le			  PGUID 11 f t t 2 f 16 "1625 1625" 100 0 1 0  lztext_le - ));
 DESCR("less-than-or-equal");
 
 /* Oracle Compatibility Related Functions - By Edmund Mergl <E.Mergl@bawue.de> */
@@ -2160,15 +2160,15 @@ DATA(insert OID = 1643 (  pg_get_indexdef	   PGUID 11 f t f 1 f 25 "26" 100 0 0
 DESCR("index description");
 
 /* Generic referential integrity constraint triggers */
-DATA(insert OID = 1644 (  RI_FKey_check_ins	    PGUID 11 f t f 0 f 0 "" 100 0 0 100  RI_FKey_check_ins - ));
+DATA(insert OID = 1644 (  RI_FKey_check_ins		PGUID 11 f t f 0 f 0 "" 100 0 0 100  RI_FKey_check_ins - ));
 DESCR("referential integrity FOREIGN KEY ... REFERENCES");
-DATA(insert OID = 1645 (  RI_FKey_check_upd	    PGUID 11 f t f 0 f 0 "" 100 0 0 100  RI_FKey_check_upd - ));
+DATA(insert OID = 1645 (  RI_FKey_check_upd		PGUID 11 f t f 0 f 0 "" 100 0 0 100  RI_FKey_check_upd - ));
 DESCR("referential integrity FOREIGN KEY ... REFERENCES");
-DATA(insert OID = 1646 (  RI_FKey_cascade_del   PGUID 11 f t f 0 f 0 "" 100 0 0 100  RI_FKey_cascade_del - ));
+DATA(insert OID = 1646 (  RI_FKey_cascade_del	PGUID 11 f t f 0 f 0 "" 100 0 0 100  RI_FKey_cascade_del - ));
 DESCR("referential integrity ON DELETE CASCADE");
-DATA(insert OID = 1647 (  RI_FKey_cascade_upd   PGUID 11 f t f 0 f 0 "" 100 0 0 100  RI_FKey_cascade_upd - ));
+DATA(insert OID = 1647 (  RI_FKey_cascade_upd	PGUID 11 f t f 0 f 0 "" 100 0 0 100  RI_FKey_cascade_upd - ));
 DESCR("referential integrity ON UPDATE CASCADE");
-DATA(insert OID = 1648 (  RI_FKey_restrict_del  PGUID 11 f t f 0 f 0 "" 100 0 0 100  RI_FKey_restrict_del - ));
+DATA(insert OID = 1648 (  RI_FKey_restrict_del	PGUID 11 f t f 0 f 0 "" 100 0 0 100  RI_FKey_restrict_del - ));
 DESCR("referential integrity ON DELETE RESTRICT");
 DATA(insert OID = 1649 (  RI_FKey_restrict_upd	PGUID 11 f t f 0 f 0 "" 100 0 0 100  RI_FKey_restrict_upd - ));
 DESCR("referential integrity ON UPDATE RESTRICT");
@@ -2180,9 +2180,9 @@ DATA(insert OID = 1652 (  RI_FKey_setdefault_del PGUID 11 f t f 0 f 0 "" 100 0 0
 DESCR("referential integrity ON DELETE SET DEFAULT");
 DATA(insert OID = 1653 (  RI_FKey_setdefault_upd PGUID 11 f t f 0 f 0 "" 100 0 0 100  RI_FKey_setdefault_upd - ));
 DESCR("referential integrity ON UPDATE SET DEFAULT");
-DATA(insert OID = 1654 (  RI_FKey_noaction_del PGUID 11 f t f 0 f 0 "" 100 0 0 100  RI_FKey_noaction_del - ));
+DATA(insert OID = 1654 (  RI_FKey_noaction_del PGUID 11 f t f 0 f 0 "" 100 0 0 100	RI_FKey_noaction_del - ));
 DESCR("referential integrity ON DELETE NO ACTION");
-DATA(insert OID = 1655 (  RI_FKey_noaction_upd PGUID 11 f t f 0 f 0 "" 100 0 0 100  RI_FKey_noaction_upd - ));
+DATA(insert OID = 1655 (  RI_FKey_noaction_upd PGUID 11 f t f 0 f 0 "" 100 0 0 100	RI_FKey_noaction_upd - ));
 DESCR("referential integrity ON UPDATE NO ACTION");
 
 DATA(insert OID = 1666 (  varbiteq			PGUID 11 f t t 2 f 16 "1562 1562" 100 0 1 0  varbiteq - ));
@@ -2383,7 +2383,7 @@ DATA(insert OID = 1739 ( numeric_power			PGUID 11 f t t 2 f 1700 "1700 1700" 100
 DESCR("m raised to the power of n");
 DATA(insert OID = 1740 ( numeric				PGUID 11 f t t 1 f 1700 "23" 100 0 0 100  int4_numeric - ));
 DESCR("(internal)");
-DATA(insert OID = 1741 ( log					PGUID 14 f t t 1 f 1700 "1700" 100 0 0 100  "select log(10, $1)" - ));
+DATA(insert OID = 1741 ( log					PGUID 14 f t t 1 f 1700 "1700" 100 0 0 100	"select log(10, $1)" - ));
 DESCR("logarithm base 10 of n");
 DATA(insert OID = 1742 ( numeric				PGUID 11 f t t 1 f 1700 "700" 100 0 0 100  float4_numeric - ));
 DESCR("(internal)");
@@ -2417,23 +2417,23 @@ DATA(insert OID = 1783 ( int2					PGUID 11 f t t 1 f 21 "1700" 100 0 0 100  nume
 DESCR("(internal)");
 
 /* formatting */
-DATA(insert OID = 1770 ( to_char			PGUID 11 f t f 2 f  25 "1184 25" 100 0 0 100  timestamp_to_char - ));
+DATA(insert OID = 1770 ( to_char			PGUID 11 f t f 2 f	25 "1184 25" 100 0 0 100  timestamp_to_char - ));
 DESCR("format timestamp to text");
-DATA(insert OID = 1772 ( to_char			PGUID 11 f t f 2 f  25 "1700 25" 100 0 0 100  numeric_to_char - ));
+DATA(insert OID = 1772 ( to_char			PGUID 11 f t f 2 f	25 "1700 25" 100 0 0 100  numeric_to_char - ));
 DESCR("format numeric to text");
-DATA(insert OID = 1773 ( to_char			PGUID 11 f t f 2 f  25 "23 25" 100 0 0 100  int4_to_char - ));
+DATA(insert OID = 1773 ( to_char			PGUID 11 f t f 2 f	25 "23 25" 100 0 0 100	int4_to_char - ));
 DESCR("format int4 to text");
-DATA(insert OID = 1774 ( to_char			PGUID 11 f t f 2 f  25 "20 25" 100 0 0 100  int8_to_char - ));
+DATA(insert OID = 1774 ( to_char			PGUID 11 f t f 2 f	25 "20 25" 100 0 0 100	int8_to_char - ));
 DESCR("format int8 to text");
-DATA(insert OID = 1775 ( to_char			PGUID 11 f t f 2 f  25 "700 25" 100 0 0 100  float4_to_char - ));
+DATA(insert OID = 1775 ( to_char			PGUID 11 f t f 2 f	25 "700 25" 100 0 0 100  float4_to_char - ));
 DESCR("format float4 to text");
-DATA(insert OID = 1776 ( to_char			PGUID 11 f t f 2 f  25 "701 25" 100 0 0 100  float8_to_char - ));
+DATA(insert OID = 1776 ( to_char			PGUID 11 f t f 2 f	25 "701 25" 100 0 0 100  float8_to_char - ));
 DESCR("format float8 to text");
-DATA(insert OID = 1777 ( to_number			PGUID 11 f t f 2 f  1700 "25 25" 100 0 0 100  numeric_to_number - ));
+DATA(insert OID = 1777 ( to_number			PGUID 11 f t f 2 f	1700 "25 25" 100 0 0 100  numeric_to_number - ));
 DESCR("convert text to numeric");
-DATA(insert OID = 1778 ( to_timestamp		PGUID 11 f t f 2 f  1184 "25 25" 100 0 0 100  to_timestamp - ));
+DATA(insert OID = 1778 ( to_timestamp		PGUID 11 f t f 2 f	1184 "25 25" 100 0 0 100  to_timestamp - ));
 DESCR("convert text to timestamp");
-DATA(insert OID = 1780 ( to_date			PGUID 11 f t f 2 f  1082 "25 25" 100 0 0 100  to_date - ));
+DATA(insert OID = 1780 ( to_date			PGUID 11 f t f 2 f	1082 "25 25" 100 0 0 100  to_date - ));
 DESCR("convert text to date");
 
 
@@ -2457,4 +2457,3 @@ extern Oid ProcedureCreate(char *procedureName,
 
 
 #endif	 /* PG_PROC_H */
-
diff --git a/src/include/catalog/pg_statistic.h b/src/include/catalog/pg_statistic.h
index e863acc095734cf5470220146612ad065b9e559b..77c89e6b144ccce3033f977db974dac8767b5040 100644
--- a/src/include/catalog/pg_statistic.h
+++ b/src/include/catalog/pg_statistic.h
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_statistic.h,v 1.8 2000/01/26 05:57:58 momjian Exp $
+ * $Id: pg_statistic.h,v 1.9 2000/04/12 17:16:29 momjian Exp $
  *
  * NOTES
  *	  the genbki.sh script reads this file and generates .bki
@@ -37,20 +37,29 @@ CATALOG(pg_statistic)
 	Oid			starelid;		/* relation containing attribute */
 	int2		staattnum;		/* attribute (column) stats are for */
 	Oid			staop;			/* '<' comparison op used for lo/hi vals */
-	/* Note: the current VACUUM code will never produce more than one entry
-	 * per column, but in theory there could be multiple entries if a datatype
-	 * has more than one useful ordering operator.  Also, the current code
-	 * will not write an entry unless it found at least one non-NULL value
-	 * in the column; so the remaining fields will never be NULL.
+
+	/*
+	 * Note: the current VACUUM code will never produce more than one
+	 * entry per column, but in theory there could be multiple entries if
+	 * a datatype has more than one useful ordering operator.  Also, the
+	 * current code will not write an entry unless it found at least one
+	 * non-NULL value in the column; so the remaining fields will never be
+	 * NULL.
 	 */
 
-	/* These fields contain the stats about the column indicated by the key */
-	float4		stanullfrac;	/* the fraction of the entries that are NULL */
-	float4		stacommonfrac;	/* the fraction that are the most common val */
+	/*
+	 * These fields contain the stats about the column indicated by the
+	 * key
+	 */
+	float4		stanullfrac;	/* the fraction of the entries that are
+								 * NULL */
+	float4		stacommonfrac;	/* the fraction that are the most common
+								 * val */
 
-	/* THE REST OF THESE ARE VARIABLE LENGTH FIELDS.
-	 * They cannot be accessed as C struct entries; you have to use the
-	 * full field access machinery (heap_getattr) for them.
+	/*
+	 * THE REST OF THESE ARE VARIABLE LENGTH FIELDS. They cannot be
+	 * accessed as C struct entries; you have to use the full field access
+	 * machinery (heap_getattr) for them.
 	 *
 	 * All three of these are text representations of data values of the
 	 * column's data type.  To re-create the actual Datum, do
@@ -77,7 +86,7 @@ typedef FormData_pg_statistic *Form_pg_statistic;
 #define Anum_pg_statistic_staattnum		2
 #define Anum_pg_statistic_staop			3
 #define Anum_pg_statistic_stanullfrac	4
-#define Anum_pg_statistic_stacommonfrac	5
+#define Anum_pg_statistic_stacommonfrac 5
 #define Anum_pg_statistic_stacommonval	6
 #define Anum_pg_statistic_staloval		7
 #define Anum_pg_statistic_stahival		8
diff --git a/src/include/catalog/pg_trigger.h b/src/include/catalog/pg_trigger.h
index 76e28d2df10e2107b3c4328c8f93a467725fd449..cb1af718bed1cb941abdc96ca87c2ceaab8345a2 100644
--- a/src/include/catalog/pg_trigger.h
+++ b/src/include/catalog/pg_trigger.h
@@ -35,12 +35,13 @@ CATALOG(pg_trigger) BOOTSTRAP
 	int2		tgtype;			/* BEFORE/AFTER UPDATE/DELETE/INSERT
 								 * ROW/STATEMENT */
 	bool		tgenabled;		/* trigger is enabled/disabled */
-	bool		tgisconstraint;	/* trigger is a RI constraint */
+	bool		tgisconstraint; /* trigger is a RI constraint */
 	NameData	tgconstrname;	/* RI constraint name */
 	Oid			tgconstrrelid;	/* RI table of foreign key definition */
-								/* in the case of ON DELETE or ON UPDATE */
+
+	/* in the case of ON DELETE or ON UPDATE */
 	bool		tgdeferrable;	/* RI trigger is deferrable */
-	bool		tginitdeferred;	/* RI trigger is deferred initially */
+	bool		tginitdeferred; /* RI trigger is deferred initially */
 	int2		tgnargs;		/* # of extra arguments in tgargs */
 	int2vector	tgattr;			/* UPDATE of attr1, attr2 ... (NI) */
 	bytea		tgargs;			/* first\000second\000tgnargs\000 */
diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h
index 61bbfeab8582b5e113eb991ccaddd6a0fa9996eb..3f8665ebe1e742afbef824d37846397c3173a488 100644
--- a/src/include/catalog/pg_type.h
+++ b/src/include/catalog/pg_type.h
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_type.h,v 1.87 2000/04/08 02:13:01 thomas Exp $
+ * $Id: pg_type.h,v 1.88 2000/04/12 17:16:29 momjian Exp $
  *
  * NOTES
  *	  the genbki.sh script reads this file and generates .bki
@@ -314,7 +314,7 @@ DATA(insert OID = 1001 (  _bytea	 PGUID -1  -1 f b t \054 0	17 array_in array_ou
 DATA(insert OID = 1002 (  _char		 PGUID -1  -1 f b t \054 0	18 array_in array_out array_in array_out i _null_ ));
 DATA(insert OID = 1003 (  _name		 PGUID -1  -1 f b t \054 0	19 array_in array_out array_in array_out i _null_ ));
 DATA(insert OID = 1005 (  _int2		 PGUID -1  -1 f b t \054 0	21 array_in array_out array_in array_out i _null_ ));
-DATA(insert OID = 1006 (  _int2vector PGUID -1  -1 f b t \054 0	22 array_in array_out array_in array_out i _null_ ));
+DATA(insert OID = 1006 (  _int2vector PGUID -1	-1 f b t \054 0 22 array_in array_out array_in array_out i _null_ ));
 DATA(insert OID = 1007 (  _int4		 PGUID -1  -1 f b t \054 0	23 array_in array_out array_in array_out i _null_ ));
 DATA(insert OID = 1008 (  _regproc	 PGUID -1  -1 f b t \054 0	24 array_in array_out array_in array_out i _null_ ));
 DATA(insert OID = 1009 (  _text		 PGUID -1  -1 f b t \054 0	25 array_in array_out array_in array_out i _null_ ));
@@ -325,7 +325,7 @@ DATA(insert OID = 1012 (  _cid		 PGUID -1  -1 f b t \054 0	29 array_in array_out
 DATA(insert OID = 1013 (  _oidvector PGUID -1  -1 f b t \054 0	30 array_in array_out array_in array_out i _null_ ));
 DATA(insert OID = 1014 (  _bpchar	 PGUID -1  -1 f b t \054 0 1042 array_in array_out array_in array_out i _null_ ));
 DATA(insert OID = 1015 (  _varchar	 PGUID -1  -1 f b t \054 0 1043 array_in array_out array_in array_out i _null_ ));
-DATA(insert OID = 1016 (  _int8		 PGUID -1  -1 f b t \054 0  20 array_in array_out array_in array_out d _null_ ));
+DATA(insert OID = 1016 (  _int8		 PGUID -1  -1 f b t \054 0	20 array_in array_out array_in array_out d _null_ ));
 DATA(insert OID = 1017 (  _point	 PGUID -1  -1 f b t \054 0 600 array_in array_out array_in array_out d _null_ ));
 DATA(insert OID = 1018 (  _lseg		 PGUID -1  -1 f b t \054 0 601 array_in array_out array_in array_out d _null_ ));
 DATA(insert OID = 1019 (  _path		 PGUID -1  -1 f b t \054 0 602 array_in array_out array_in array_out d _null_ ));
@@ -342,7 +342,7 @@ DATA(insert OID = 1027 (  _polygon	 PGUID -1  -1 f b t \054 0 604 array_in array
  *	Thanks to some padding, this will be 8 on all platforms.
  *	We also have an Assert to make sure.
  */
-#define ACLITEMSIZE	8
+#define ACLITEMSIZE 8
 DATA(insert OID = 1033 (  aclitem	 PGUID 8   -1 f b t \054 0 0 aclitemin aclitemout aclitemin aclitemout i _null_ ));
 DESCR("access control list");
 DATA(insert OID = 1034 (  _aclitem	 PGUID -1 -1 f b t \054 0 1033 array_in array_out array_in array_out i _null_ ));
@@ -369,33 +369,33 @@ DATA(insert OID = 1183 ( _time		 PGUID	-1 -1 f b t \054 0	1083 array_in array_ou
 DATA(insert OID = 1184 ( timestamp	 PGUID	8  47 f b t \054 0	0 timestamp_in timestamp_out timestamp_in timestamp_out d _null_ ));
 DESCR("date and time");
 #define TIMESTAMPOID	1184
-DATA(insert OID = 1185 ( _timestamp	 PGUID	-1 -1 f b t \054 0	1184 array_in array_out array_in array_out d _null_ ));
+DATA(insert OID = 1185 ( _timestamp  PGUID	-1 -1 f b t \054 0	1184 array_in array_out array_in array_out d _null_ ));
 DATA(insert OID = 1186 ( interval	 PGUID 12  47 f b t \054 0	0 interval_in interval_out interval_in interval_out d _null_ ));
 DESCR("@ <number> <units>, time interval");
 #define INTERVALOID		1186
 DATA(insert OID = 1187 ( _interval	 PGUID	-1 -1 f b t \054 0	1186 array_in array_out array_in array_out d _null_ ));
 
 /* OIDS 1200 - 1299 */
-DATA(insert OID = 1231 (  _numeric   PGUID -1  -1 f b t \054 0  1700 array_in array_out array_in array_out i _null_ ));
+DATA(insert OID = 1231 (  _numeric	 PGUID -1  -1 f b t \054 0	1700 array_in array_out array_in array_out i _null_ ));
 DATA(insert OID = 1266 ( timetz		 PGUID 12  22 f b t \054 0	0 timetz_in timetz_out timetz_in timetz_out d _null_ ));
 DESCR("hh:mm:ss, ANSI SQL time");
 #define TIMETZOID		1266
 DATA(insert OID = 1270 ( _timetz	 PGUID	-1 -1 f b t \054 0	1266 array_in array_out array_in array_out d _null_ ));
 
 /* OIDS 1500 - 1599 */
-DATA(insert OID = 1560 ( bit         PGUID -1  -1 f b t \054 0  0 zpbit_in zpbit_out zpbit_in zpbit_out i _null_ ));
+DATA(insert OID = 1560 ( bit		 PGUID -1  -1 f b t \054 0	0 zpbit_in zpbit_out zpbit_in zpbit_out i _null_ ));
 DESCR("fixed-length bit string");
-#define ZPBITOID     1560
-DATA(insert OID = 1561 ( _bit        PGUID	-1 -1 f b t \054 0	1560 array_in array_out array_in array_out i _null_ ));
-DATA(insert OID = 1562 ( varbit      PGUID -1  -1 f b t \054 0  0 varbit_in varbit_out varbit_in varbit_out i _null_ ));
+#define ZPBITOID	 1560
+DATA(insert OID = 1561 ( _bit		 PGUID	-1 -1 f b t \054 0	1560 array_in array_out array_in array_out i _null_ ));
+DATA(insert OID = 1562 ( varbit		 PGUID -1  -1 f b t \054 0	0 varbit_in varbit_out varbit_in varbit_out i _null_ ));
 DESCR("fixed-length bit string");
-#define VARBITOID     1562
-DATA(insert OID = 1563 ( _varbit     PGUID	-1 -1 f b t \054 0	1562 array_in array_out array_in array_out i _null_ ));
+#define VARBITOID	  1562
+DATA(insert OID = 1563 ( _varbit	 PGUID	-1 -1 f b t \054 0	1562 array_in array_out array_in array_out i _null_ ));
 
 /* OIDS 1600 - 1699 */
-DATA(insert OID = 1625 ( lztext      PGUID -1  -1 f b t \054 0  0 lztextin lztextout lztextin lztextout i _null_ ));
+DATA(insert OID = 1625 ( lztext		 PGUID -1  -1 f b t \054 0	0 lztextin lztextout lztextin lztextout i _null_ ));
 DESCR("variable-length string, stored compressed");
-#define LZTEXTOID     1625
+#define LZTEXTOID	  1625
 
 /* OIDS 1700 - 1799 */
 DATA(insert OID = 1700 ( numeric	   PGUID -1  -1 f b t \054 0  0 numeric_in numeric_out numeric_in numeric_out i _null_ ));
diff --git a/src/include/catalog/pg_version.h b/src/include/catalog/pg_version.h
index 76f00e5a3116e2d31dbc5f835fd67ff5905abf2e..85b5d0f4ac9af01d23664a4418849768ce3b8f96 100644
--- a/src/include/catalog/pg_version.h
+++ b/src/include/catalog/pg_version.h
@@ -8,14 +8,14 @@
  * version or anything like that.  It is for defining individual relations
  * that have multiple concurrently-existing versions.  Yes, there used to
  * be such a feature in Postgres, but it's been broken for a long time
- * (see src/backend/commands/_deadcode/version.c).  The pg_version table
+ * (see src/backend/commands/_deadcode/version.c).	The pg_version table
  * isn't even created at present.
  *
  *
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_version.h,v 1.10 2000/01/26 05:57:59 momjian Exp $
+ * $Id: pg_version.h,v 1.11 2000/04/12 17:16:30 momjian Exp $
  *
  * NOTES
  *	  the genbki.sh script reads this file and generates .bki
diff --git a/src/include/commands/command.h b/src/include/commands/command.h
index a10adffea9dc1abbedb22b5d2aaddc85aebfe53c..b68ec2de5da6616341319f53828da6736ade6c25 100644
--- a/src/include/commands/command.h
+++ b/src/include/commands/command.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: command.h,v 1.17 2000/01/26 05:58:00 momjian Exp $
+ * $Id: command.h,v 1.18 2000/04/12 17:16:31 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -42,22 +42,22 @@ extern void PortalCleanup(Portal portal);
  * ALTER TABLE variants
  */
 extern void AlterTableAddColumn(const char *relationName,
-                                bool inh, ColumnDef *colDef);
+					bool inh, ColumnDef *colDef);
 
 extern void AlterTableAlterColumn(const char *relationName,
-                                  bool inh, const char *colName,
-                                  Node *newDefault);
+					  bool inh, const char *colName,
+					  Node *newDefault);
 
 extern void AlterTableDropColumn(const char *relationName,
-                                 bool inh, const char *colName,
-                                 int behavior);
+					 bool inh, const char *colName,
+					 int behavior);
 
 extern void AlterTableAddConstraint(const char *relationName,
-                                    bool inh, Node *newConstraint);
+						bool inh, Node *newConstraint);
 
 extern void AlterTableDropConstraint(const char *relationName,
-                                     bool inh, const char *constrName,
-                                     int behavior);
+						 bool inh, const char *constrName,
+						 int behavior);
 
 /*
  * LOCK
diff --git a/src/include/commands/comment.h b/src/include/commands/comment.h
index 93ed200a74a887540cb526e47bac32bde81f1900..7f400411b4e6af439724f23b8a6eb99ecf345bc5 100644
--- a/src/include/commands/comment.h
+++ b/src/include/commands/comment.h
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
  * comment.h
- *	  
+ *
  * Prototypes for functions in commands/comment.c
  *
  * Copyright (c) 1999, PostgreSQL Global Development Group
@@ -14,18 +14,18 @@
 
 /*------------------------------------------------------------------
  * Function Prototypes --
- * 
+ *
  * The following protoypes define the public functions of the comment
  * related routines. CreateComments() is used to create/drop a comment
- * for any object with a valid oid. DeleteComments() deletes, if any, 
- * the comments associated with the object. CommentObject() is used to 
+ * for any object with a valid oid. DeleteComments() deletes, if any,
+ * the comments associated with the object. CommentObject() is used to
  * create comments to be identified by the specific type.
  *------------------------------------------------------------------
  */
 
-void CreateComments(Oid oid, char *comment);
-void DeleteComments(Oid oid);
-void CommentObject(int objtype, char *objname, char *objproperty, 
-		   List *objlist, char *comment);
+void		CreateComments(Oid oid, char *comment);
+void		DeleteComments(Oid oid);
+void CommentObject(int objtype, char *objname, char *objproperty,
+			  List *objlist, char *comment);
 
 #endif	 /* COMMENT_H */
diff --git a/src/include/commands/copy.h b/src/include/commands/copy.h
index ecdb9bbb4e8578b0be1f4137f855054b70fe22eb..bbd465586c9716be1bed5d841ab24aff4c5ad868 100644
--- a/src/include/commands/copy.h
+++ b/src/include/commands/copy.h
@@ -7,16 +7,16 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: copy.h,v 1.10 2000/02/13 18:59:52 momjian Exp $
+ * $Id: copy.h,v 1.11 2000/04/12 17:16:32 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 #ifndef COPY_H
 #define COPY_H
 
-extern int lineno;
+extern int	lineno;
 
 void DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
-			char *filename, char *delim, char *null_print);
+	   char *filename, char *delim, char *null_print);
 
 #endif	 /* COPY_H */
diff --git a/src/include/commands/trigger.h b/src/include/commands/trigger.h
index b2c258c2f8322d44aa2250a52d15c4a8ca9fab46..3b735546ea560974c73af8148c92f12779af9ec3 100644
--- a/src/include/commands/trigger.h
+++ b/src/include/commands/trigger.h
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: trigger.h,v 1.18 2000/01/31 04:35:54 tgl Exp $
+ * $Id: trigger.h,v 1.19 2000/04/12 17:16:32 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -93,31 +93,34 @@ extern void ExecARUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple
  * Deferred trigger stuff
  * ----------
  */
-typedef struct DeferredTriggerStatusData {
-	Oid				dts_tgoid;
-	bool			dts_tgisdeferred;
+typedef struct DeferredTriggerStatusData
+{
+	Oid			dts_tgoid;
+	bool		dts_tgisdeferred;
 } DeferredTriggerStatusData;
 typedef struct DeferredTriggerStatusData *DeferredTriggerStatus;
 
 
-typedef struct DeferredTriggerEventItem {
-	Oid				dti_tgoid;
-	int32			dti_state;
+typedef struct DeferredTriggerEventItem
+{
+	Oid			dti_tgoid;
+	int32		dti_state;
 } DeferredTriggerEventItem;
 
 
-typedef struct DeferredTriggerEventData {
-	int32			dte_event;
-	Oid				dte_relid;
-	ItemPointerData	dte_oldctid;
-	ItemPointerData	dte_newctid;
-	int32			dte_n_items;
-	DeferredTriggerEventItem	dte_item[1];
+typedef struct DeferredTriggerEventData
+{
+	int32		dte_event;
+	Oid			dte_relid;
+	ItemPointerData dte_oldctid;
+	ItemPointerData dte_newctid;
+	int32		dte_n_items;
+	DeferredTriggerEventItem dte_item[1];
 } DeferredTriggerEventData;
 typedef struct DeferredTriggerEventData *DeferredTriggerEvent;
 
 
-extern int  DeferredTriggerInit(void);
+extern int	DeferredTriggerInit(void);
 extern void DeferredTriggerBeginXact(void);
 extern void DeferredTriggerEndQuery(void);
 extern void DeferredTriggerEndXact(void);
@@ -126,7 +129,7 @@ extern void DeferredTriggerAbortXact(void);
 extern void DeferredTriggerSetState(ConstraintsSetStmt *stmt);
 
 extern void DeferredTriggerSaveEvent(Relation rel, int event,
-					HeapTuple oldtup, HeapTuple newtup);
+						 HeapTuple oldtup, HeapTuple newtup);
 
 
 /*
diff --git a/src/include/commands/user.h b/src/include/commands/user.h
index 6a52fe613d981e69aa5d8fa32f616098bb52277b..f250a1c3da8691aed185d7722f167f08cd231369 100644
--- a/src/include/commands/user.h
+++ b/src/include/commands/user.h
@@ -18,7 +18,7 @@ extern void AlterUser(AlterUserStmt *stmt);
 extern void DropUser(DropUserStmt *stmt);
 
 extern void CreateGroup(CreateGroupStmt *stmt);
-extern void AlterGroup(AlterGroupStmt *stmt, const char * tag);
+extern void AlterGroup(AlterGroupStmt *stmt, const char *tag);
 extern void DropGroup(DropGroupStmt *stmt);
 
 extern HeapTuple update_pg_pwd(void);
diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h
index 07bc4ea1f995ac47fe6d712f83f7f303969d4bef..136721c4e17d9657e82b69a34093ed0e2883683b 100644
--- a/src/include/commands/vacuum.h
+++ b/src/include/commands/vacuum.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: vacuum.h,v 1.26 2000/01/26 05:58:00 momjian Exp $
+ * $Id: vacuum.h,v 1.27 2000/04/12 17:16:32 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -47,7 +47,8 @@ typedef struct VPageListData
 {
 	int			vpl_empty_end_pages;	/* Number of "empty" end-pages */
 	int			vpl_num_pages;	/* Number of pages in vpl_pagedesc */
-	int			vpl_num_allocated_pages;	/* Number of allocated pages in vpl_pagedesc */
+	int			vpl_num_allocated_pages;		/* Number of allocated
+												 * pages in vpl_pagedesc */
 	VPageDescr *vpl_pagedesc;	/* Descriptions of pages */
 } VPageListData;
 
diff --git a/src/include/executor/nodeGroup.h b/src/include/executor/nodeGroup.h
index dd104b0af943a1f35b1b7c210760f8c8ada131f6..303516b167e94776f331457b52580db36a4f0b8a 100644
--- a/src/include/executor/nodeGroup.h
+++ b/src/include/executor/nodeGroup.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: nodeGroup.h,v 1.15 2000/01/27 18:11:41 tgl Exp $
+ * $Id: nodeGroup.h,v 1.16 2000/04/12 17:16:33 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -23,13 +23,13 @@ extern void ExecEndGroup(Group *node);
 extern void ExecReScanGroup(Group *node, ExprContext *exprCtxt, Plan *parent);
 
 extern bool execTuplesMatch(HeapTuple tuple1,
-							HeapTuple tuple2,
-							TupleDesc tupdesc,
-							int numCols,
-							AttrNumber *matchColIdx,
-							FmgrInfo *eqfunctions);
+				HeapTuple tuple2,
+				TupleDesc tupdesc,
+				int numCols,
+				AttrNumber *matchColIdx,
+				FmgrInfo *eqfunctions);
 extern FmgrInfo *execTuplesMatchPrepare(TupleDesc tupdesc,
-										int numCols,
-										AttrNumber *matchColIdx);
+					   int numCols,
+					   AttrNumber *matchColIdx);
 
 #endif	 /* NODEGROUP_H */
diff --git a/src/include/executor/nodeSubplan.h b/src/include/executor/nodeSubplan.h
index b25e4dee37945df8c110ceb4eeb207e8a6f42b18..a56ae216f5edeb6384835509f80323cf26acdad3 100644
--- a/src/include/executor/nodeSubplan.h
+++ b/src/include/executor/nodeSubplan.h
@@ -10,7 +10,7 @@
 #include "nodes/plannodes.h"
 
 extern Datum ExecSubPlan(SubPlan *node, List *pvar, ExprContext *econtext,
-						 bool *isNull);
+			bool *isNull);
 extern bool ExecInitSubPlan(SubPlan *node, EState *estate, Plan *parent);
 extern void ExecReScanSetParamPlan(SubPlan *node, Plan *parent);
 extern void ExecSetParamPlan(SubPlan *node);
diff --git a/src/include/executor/nodeTidscan.h b/src/include/executor/nodeTidscan.h
index ffee4677eb79532b717c03dbe86dce0ed1e8ae44..58f18e4b8f4977071f9d80ce7e8c443a3fea0958 100644
--- a/src/include/executor/nodeTidscan.h
+++ b/src/include/executor/nodeTidscan.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: nodeTidscan.h,v 1.2 2000/01/26 05:58:05 momjian Exp $
+ * $Id: nodeTidscan.h,v 1.3 2000/04/12 17:16:33 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -22,7 +22,7 @@ extern void ExecEndTidScan(TidScan *node);
 extern void ExecTidMarkPos(TidScan *node);
 extern void ExecTidRestrPos(TidScan *node);
 extern bool ExecInitTidScan(TidScan *node, EState *estate, Plan *parent);
-extern int  ExecCountSlotsTidScan(TidScan *node);
+extern int	ExecCountSlotsTidScan(TidScan *node);
 extern void ExecTidReScan(TidScan *node, ExprContext *exprCtxt, Plan *parent);
 
 #endif	 /* NODETIDSCAN_H */
diff --git a/src/include/lib/dllist.h b/src/include/lib/dllist.h
index d56f773a9db49b89d706b7534f670b2cf26ffbae..46192e13332fd5596ffb388df8776fdc8635dc2f 100644
--- a/src/include/lib/dllist.h
+++ b/src/include/lib/dllist.h
@@ -27,7 +27,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: dllist.h,v 1.11 2000/01/26 05:58:09 momjian Exp $
+ * $Id: dllist.h,v 1.12 2000/04/12 17:16:34 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -67,7 +67,7 @@ extern void DLRemove(Dlelem *); /* removes node from list */
 extern void DLAddHead(Dllist *list, Dlelem *node);
 extern void DLAddTail(Dllist *list, Dlelem *node);
 extern Dlelem *DLRemHead(Dllist *list); /* remove and return the head */
-extern void DLMoveToFront(Dlelem *); /* move node to front of its list */
+extern void DLMoveToFront(Dlelem *);	/* move node to front of its list */
 
 #define DLE_VAL(x)	(x->dle_val)
 
diff --git a/src/include/lib/stringinfo.h b/src/include/lib/stringinfo.h
index 05ba4b58a1747c64d7d90d7af887b68a7337c2ff..de8ac4a07e3c0ceab969cb3975e04495687f9fa9 100644
--- a/src/include/lib/stringinfo.h
+++ b/src/include/lib/stringinfo.h
@@ -10,7 +10,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: stringinfo.h,v 1.17 2000/02/13 13:21:11 momjian Exp $
+ * $Id: stringinfo.h,v 1.18 2000/04/12 17:16:34 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -106,6 +106,6 @@ extern void appendStringInfoChar(StringInfo str, char ch);
  * if necessary.
  */
 extern void appendBinaryStringInfo(StringInfo str,
-								   const char *data, int datalen);
+					   const char *data, int datalen);
 
 #endif	 /* STRINGINFO_H */
diff --git a/src/include/libpq/hba.h b/src/include/libpq/hba.h
index 5dcf49100d530bf0d8ebe44fa0eb331d841a86e0..1a5021ad2688284ddb649bb20eb9887d3a07f429 100644
--- a/src/include/libpq/hba.h
+++ b/src/include/libpq/hba.h
@@ -4,7 +4,7 @@
  *	  Interface to hba.c
  *
  *
- * $Id: hba.h,v 1.16 1999/10/23 03:13:29 tgl Exp $
+ * $Id: hba.h,v 1.17 2000/04/12 17:16:35 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -42,7 +42,7 @@ typedef enum UserAuth
 
 typedef struct Port hbaPort;
 
-int hba_getauthmethod(hbaPort *port);
+int			hba_getauthmethod(hbaPort *port);
 int authident(struct sockaddr_in * raddr, struct sockaddr_in * laddr,
 		  const char *postgres_username, const char *auth_arg);
 
diff --git a/src/include/libpq/libpq-be.h b/src/include/libpq/libpq-be.h
index 56e0e996d02cf2b57d0c7af99ec2c1e8c7e8d380..76403d495e0a4a413d0e653afea7343961cc00be 100644
--- a/src/include/libpq/libpq-be.h
+++ b/src/include/libpq/libpq-be.h
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: libpq-be.h,v 1.18 2000/01/26 05:58:12 momjian Exp $
+ * $Id: libpq-be.h,v 1.19 2000/04/12 17:16:36 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -133,11 +133,11 @@ typedef struct Port
 	char		auth_arg[MAX_AUTH_ARG];
 	UserAuth	auth_method;
 
-        /*
-	 * SSL structures 
+	/*
+	 * SSL structures
 	 */
 #ifdef USE_SSL
-        SSL             *ssl;
+	SSL		   *ssl;
 #endif
 } Port;
 
diff --git a/src/include/libpq/libpq.h b/src/include/libpq/libpq.h
index d60d4a0a1177485568ea7392de5e56d8e87946d5..bb935d42514b9caabfb7d7deed0ef002a14acff7 100644
--- a/src/include/libpq/libpq.h
+++ b/src/include/libpq/libpq.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: libpq.h,v 1.35 2000/01/26 05:58:12 momjian Exp $
+ * $Id: libpq.h,v 1.36 2000/04/12 17:16:36 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -139,7 +139,7 @@ extern Exception MemoryError,
  * PQerrormsg[] is used only for error messages generated within backend
  * libpq, none of which are remarkably long.  Note that this length should
  * NOT be taken as any indication of the maximum error message length that
- * the backend can create!  elog() can in fact produce extremely long messages.
+ * the backend can create!	elog() can in fact produce extremely long messages.
  */
 
 #define PQERRORMSG_LENGTH 1024
diff --git a/src/include/libpq/pqsignal.h b/src/include/libpq/pqsignal.h
index 7b7350442c0813428839e25b92a49c9fdbe3e1f8..8013848ef65aa3039b6f5449dacb6568820d06f7 100644
--- a/src/include/libpq/pqsignal.h
+++ b/src/include/libpq/pqsignal.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pqsignal.h,v 1.11 2000/01/26 05:58:12 momjian Exp $
+ * $Id: pqsignal.h,v 1.12 2000/04/12 17:16:36 momjian Exp $
  *
  * NOTES
  *	  This shouldn't be in libpq, but the monitor and some other
@@ -19,16 +19,18 @@
 #define PQSIGNAL_H
 
 #ifdef HAVE_SIGPROCMASK
-extern sigset_t		UnBlockSig,
-					BlockSig;
-#define	PG_INITMASK()	( \
+extern sigset_t UnBlockSig,
+			BlockSig;
+
+#define PG_INITMASK()	( \
 							sigemptyset(&UnBlockSig), \
 							sigfillset(&BlockSig) \
 						)
-#define	PG_SETMASK(mask)	sigprocmask(SIG_SETMASK, mask, NULL)
+#define PG_SETMASK(mask)	sigprocmask(SIG_SETMASK, mask, NULL)
 #else
-extern int			UnBlockSig,
-					BlockSig;
+extern int	UnBlockSig,
+			BlockSig;
+
 #define PG_INITMASK()	( \
 							UnBlockSig = 0, \
 							BlockSig = sigmask(SIGHUP) | sigmask(SIGQUIT) | \
@@ -37,7 +39,7 @@ extern int			UnBlockSig,
 										sigmask(SIGUSR2) | sigmask(SIGCHLD) | \
 										sigmask(SIGWINCH) | sigmask(SIGFPE) \
 						)
-#define	PG_SETMASK(mask)	sigsetmask(*((int*)(mask)))
+#define PG_SETMASK(mask)	sigsetmask(*((int*)(mask)))
 #endif
 
 typedef void (*pqsigfunc) (int);
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 3d5dbae01fbb4b175e567c9f39dbf3473f1aa7b3..5070f5bc4d1cb409f0af55c33fef7b9d460ea4ff 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -12,7 +12,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: miscadmin.h,v 1.54 2000/02/23 15:46:14 momjian Exp $
+ * $Id: miscadmin.h,v 1.55 2000/04/12 17:16:24 momjian Exp $
  *
  * NOTES
  *	  some of the information in this file will be moved to
@@ -23,7 +23,7 @@
 #ifndef MISCADMIN_H
 #define MISCADMIN_H
 
-#include <sys/types.h>				/* For pid_t */
+#include <sys/types.h>			/* For pid_t */
 
 #include "postgres.h"
 
@@ -66,7 +66,7 @@ extern bool TransactionInitWasProcessed;
 
 extern bool IsUnderPostmaster;
 
-extern int DebugLvl;
+extern int	DebugLvl;
 
 /* Date/Time Configuration
  *
@@ -148,7 +148,7 @@ extern int	CheckPathAccess(char *path, char *name, int open_mode);
  *****************************************************************************/
 /*
  * Description:
- *		There are three processing modes in POSTGRES.  They are 
+ *		There are three processing modes in POSTGRES.  They are
  * "BootstrapProcessing or "bootstrap," InitProcessing or
  * "initialization," and NormalProcessing or "normal."
  *
@@ -157,12 +157,12 @@ extern int	CheckPathAccess(char *path, char *name, int open_mode);
  * transaction id "one" and are consequently guarenteed to commit. This mode
  * is used during the initial generation of template databases.
  *
- * Initialization mode until all normal initialization is complete.	
- * Some code behaves differently when executed in this mode to enable 
+ * Initialization mode until all normal initialization is complete.
+ * Some code behaves differently when executed in this mode to enable
  * system bootstrapping.
  *
  * If a POSTGRES binary is in normal mode, then all code may be executed
- * normally. 
+ * normally.
  */
 
 typedef enum ProcessingMode
@@ -205,11 +205,11 @@ extern ProcessingMode Mode;
 #define IsNormalProcessingMode() ((bool)(Mode == NormalProcessing))
 
 #define SetProcessingMode(mode) \
-    do { \
-        AssertArg(mode == BootstrapProcessing || mode == InitProcessing || \
-		 		  mode == NormalProcessing); \
-        Mode = mode; \
-    } while(0)
+	do { \
+		AssertArg(mode == BootstrapProcessing || mode == InitProcessing || \
+				  mode == NormalProcessing); \
+		Mode = mode; \
+	} while(0)
 
 #define GetProcessingMode() Mode
 
@@ -218,7 +218,7 @@ extern bool IsIgnoringSystemIndexes(void);
 extern bool IsCacheInitialized(void);
 extern void SetWaitingForLock(bool);
 
-/* 
+/*
  * "postmaster.pid" is a file containing postmaster's pid, being
  * created uder $PGDATA upon postmaster's starting up. When postmaster
  * shuts down, it will be unlinked.
@@ -228,6 +228,6 @@ extern void SetWaitingForLock(bool);
 extern void SetPidFname(char *datadir);
 extern char *GetPidFname(void);
 extern void UnlinkPidFile(void);
-extern int SetPidFile(pid_t pid);
+extern int	SetPidFile(pid_t pid);
 
 #endif	 /* MISCADMIN_H */
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 827bb75a9c84b7a5d9aa1e42bfee8eb5ebfd67b6..044cee23eab9859bc4d0fa96124c4fda3d6b0718 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: execnodes.h,v 1.40 2000/01/27 18:11:44 tgl Exp $
+ * $Id: execnodes.h,v 1.41 2000/04/12 17:16:39 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -89,7 +89,7 @@ typedef struct ExprContext
 	ParamListInfo ecxt_param_list_info;
 	ParamExecData *ecxt_param_exec_vals;		/* this is for subselects */
 	List	   *ecxt_range_table;
-	Datum	   *ecxt_aggvalues;	/* precomputed values for Aggref nodes */
+	Datum	   *ecxt_aggvalues; /* precomputed values for Aggref nodes */
 	bool	   *ecxt_aggnulls;	/* null flags for Aggref nodes */
 } ExprContext;
 
@@ -443,8 +443,8 @@ typedef struct TidScanState
 	int			tss_NumTids;
 	int			tss_TidPtr;
 	int			tss_MarkTidPtr;
-	ItemPointer		*tss_TidList;
-	HeapTupleData		tss_htup;
+	ItemPointer *tss_TidList;
+	HeapTupleData tss_htup;
 } TidScanState;
 
 /* ----------------------------------------------------------------
@@ -602,7 +602,7 @@ typedef struct MaterialState
  *	during evaluation of an Agg node's output tuple(s).
  * -------------------------
  */
-typedef struct AggStatePerAggData *AggStatePerAgg; /* private in nodeAgg.c */
+typedef struct AggStatePerAggData *AggStatePerAgg;		/* private in nodeAgg.c */
 
 typedef struct AggState
 {
diff --git a/src/include/nodes/makefuncs.h b/src/include/nodes/makefuncs.h
index f934eb5e63a0c02a09730f0ae861c2377a40dcee..3b470b150a29fae8721200a08a19865ea5778498 100644
--- a/src/include/nodes/makefuncs.h
+++ b/src/include/nodes/makefuncs.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: makefuncs.h,v 1.23 2000/02/15 03:38:13 thomas Exp $
+ * $Id: makefuncs.h,v 1.24 2000/04/12 17:16:40 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -47,6 +47,6 @@ extern Const *makeConst(Oid consttype,
 		  bool constiscast);
 
 extern Attr *
-makeAttr(char *relname, char *attname);
+			makeAttr(char *relname, char *attname);
 
 #endif	 /* MAKEFUNC_H */
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index f42f615c7a6603e499bd2ba42dc9d5c2c4f0ae66..a8fe032ba51e95f84601e48769f86c20fd9ee1ff 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: nodes.h,v 1.66 2000/02/20 21:32:16 tgl Exp $
+ * $Id: nodes.h,v 1.67 2000/04/12 17:16:40 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -301,7 +301,8 @@ extern bool equal(void *a, void *b);
  * These could have gone into plannodes.h or some such, but many files
  * depend on them...
  */
-typedef double Selectivity;		/* fraction of tuples a qualifier will pass */
+typedef double Selectivity;		/* fraction of tuples a qualifier will
+								 * pass */
 typedef double Cost;			/* execution cost (in page-access units) */
 
 
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index cbbe77c333ae1ae5f4c0a311d449cb3a61c8f547..15c370a64a65fe686bf3310d865c97a40b51dbb8 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: parsenodes.h,v 1.103 2000/03/24 23:26:45 tgl Exp $
+ * $Id: parsenodes.h,v 1.104 2000/04/12 17:16:40 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -54,7 +54,7 @@ typedef struct Query
 	Node	   *qual;			/* qualifications applied to tuples */
 	List	   *rowMark;		/* list of RowMark entries */
 
-	List	   *distinctClause;	/* a list of SortClause's */
+	List	   *distinctClause; /* a list of SortClause's */
 
 	List	   *sortClause;		/* a list of SortClause's */
 
@@ -72,7 +72,8 @@ typedef struct Query
 	/* internal to planner */
 	List	   *base_rel_list;	/* list of base-relation RelOptInfos */
 	List	   *join_rel_list;	/* list of join-relation RelOptInfos */
-	List	   *equi_key_list;	/* list of lists of equijoined PathKeyItems */
+	List	   *equi_key_list;	/* list of lists of equijoined
+								 * PathKeyItems */
 	List	   *query_pathkeys; /* pathkeys for query_planner()'s result */
 } Query;
 
@@ -94,12 +95,13 @@ typedef struct Query
 typedef struct AlterTableStmt
 {
 	NodeTag		type;
-    char        subtype;        /* A = add, T = alter, D = drop, C = add constr, X = drop constr */
-	char	   *relname;        /* table to work on */
+	char		subtype;		/* A = add, T = alter, D = drop, C = add
+								 * constr, X = drop constr */
+	char	   *relname;		/* table to work on */
 	bool		inh;			/* recursively on children? */
-    char       *name;           /* column or constraint name to act on */
-    Node       *def;            /* definition of new column or constraint */
-    int         behavior;       /* CASCADE or RESTRICT drop behavior */
+	char	   *name;			/* column or constraint name to act on */
+	Node	   *def;			/* definition of new column or constraint */
+	int			behavior;		/* CASCADE or RESTRICT drop behavior */
 } AlterTableStmt;
 
 /* ----------------------
@@ -137,7 +139,7 @@ typedef struct CopyStmt
 	int			direction;		/* TO or FROM */
 	char	   *filename;		/* if NULL, use stdin/stdout */
 	char	   *delimiter;		/* delimiter character, \t by default */
-    char       *null_print;     /* how to print NULLs, `\N' by default */
+	char	   *null_print;		/* how to print NULLs, `\N' by default */
 } CopyStmt;
 
 /* ----------------------
@@ -177,7 +179,8 @@ typedef struct CreateStmt
 
 typedef enum ConstrType			/* types of constraints */
 {
-	CONSTR_NULL,				/* not SQL92, but a lot of people expect it */
+	CONSTR_NULL,				/* not SQL92, but a lot of people expect
+								 * it */
 	CONSTR_NOTNULL,
 	CONSTR_DEFAULT,
 	CONSTR_CHECK,
@@ -219,14 +222,14 @@ typedef struct Constraint
 typedef struct FkConstraint
 {
 	NodeTag		type;
-	char	   *constr_name;		/* Constraint name */
-	char	   *pktable_name;		/* Primary key table name */
-	List	   *fk_attrs;			/* Attributes of foreign key */
-	List	   *pk_attrs;			/* Corresponding attrs in PK table */
-	char	   *match_type;			/* FULL or PARTIAL */
-	int32		actions;			/* ON DELETE/UPDATE actions */
-	bool		deferrable;			/* DEFERRABLE */
-	bool		initdeferred;		/* INITIALLY DEFERRED */
+	char	   *constr_name;	/* Constraint name */
+	char	   *pktable_name;	/* Primary key table name */
+	List	   *fk_attrs;		/* Attributes of foreign key */
+	List	   *pk_attrs;		/* Corresponding attrs in PK table */
+	char	   *match_type;		/* FULL or PARTIAL */
+	int32		actions;		/* ON DELETE/UPDATE actions */
+	bool		deferrable;		/* DEFERRABLE */
+	bool		initdeferred;	/* INITIALLY DEFERRED */
 } FkConstraint;
 
 
@@ -250,8 +253,8 @@ typedef struct CreateTrigStmt
 	List	   *attr;			/* UPDATE OF a, b,... (NI) or NULL */
 	char	   *when;			/* WHEN 'a > 10 ...' (NI) or NULL */
 
-								/* The following are used for referential */
-								/* integrity constraint triggers */
+	/* The following are used for referential */
+	/* integrity constraint triggers */
 	bool		isconstraint;	/* This is an RI trigger */
 	bool		deferrable;		/* [NOT] DEFERRABLE */
 	bool		initdeferred;	/* INITIALLY {DEFERRED|IMMEDIATE} */
@@ -295,9 +298,9 @@ typedef struct CreateUserStmt
 	NodeTag		type;
 	char	   *user;			/* PostgreSQL user login			  */
 	char	   *password;		/* PostgreSQL user password			  */
-    int         sysid;          /* PgSQL system id (-1 if don't care) */
-	bool        createdb;		/* Can the user create databases?	  */
-	bool 	    createuser;		/* Can this user create users?		  */
+	int			sysid;			/* PgSQL system id (-1 if don't care) */
+	bool		createdb;		/* Can the user create databases?	  */
+	bool		createuser;		/* Can this user create users?		  */
 	List	   *groupElts;		/* The groups the user is a member of */
 	char	   *validUntil;		/* The time the login is valid until  */
 } CreateUserStmt;
@@ -307,43 +310,43 @@ typedef struct AlterUserStmt
 	NodeTag		type;
 	char	   *user;			/* PostgreSQL user login			  */
 	char	   *password;		/* PostgreSQL user password			  */
-	int 	    createdb;		/* Can the user create databases?	  */
-	int 	    createuser;		/* Can this user create users?		  */
+	int			createdb;		/* Can the user create databases?	  */
+	int			createuser;		/* Can this user create users?		  */
 	char	   *validUntil;		/* The time the login is valid until  */
 } AlterUserStmt;
 
 typedef struct DropUserStmt
 {
 	NodeTag		type;
-    List       *users;          /* List of users to remove */
+	List	   *users;			/* List of users to remove */
 } DropUserStmt;
 
 
 /* ----------------------
- *      Create/Alter/Drop Group Statements
+ *		Create/Alter/Drop Group Statements
  * ----------------------
  */
 typedef struct CreateGroupStmt
 {
-    NodeTag     type;
-    char       *name;           /* name of the new group */
-    int         sysid;          /* group id (-1 if pick default) */
-    List       *initUsers;      /* list of initial users */
+	NodeTag		type;
+	char	   *name;			/* name of the new group */
+	int			sysid;			/* group id (-1 if pick default) */
+	List	   *initUsers;		/* list of initial users */
 } CreateGroupStmt;
 
 typedef struct AlterGroupStmt
 {
-    NodeTag     type;
-    char       *name;           /* name of group to alter */
-    int         action;         /* +1 = add, -1 = drop user */
-    int         sysid;          /* sysid change */
-    List       *listUsers;      /* list of users to add/drop */
+	NodeTag		type;
+	char	   *name;			/* name of group to alter */
+	int			action;			/* +1 = add, -1 = drop user */
+	int			sysid;			/* sysid change */
+	List	   *listUsers;		/* list of users to add/drop */
 } AlterGroupStmt;
 
 typedef struct DropGroupStmt
 {
-    NodeTag     type;
-    char       *name;
+	NodeTag		type;
+	char	   *name;
 } DropGroupStmt;
 
 
@@ -396,29 +399,29 @@ typedef struct DropStmt
 } DropStmt;
 
 /* ----------------------
- *              Truncate Table Statement
+ *				Truncate Table Statement
  * ----------------------
  */
 typedef struct TruncateStmt
 {
-        NodeTag         type;
-        char	   *relName;            /* relation to be truncated */
+	NodeTag		type;
+	char	   *relName;		/* relation to be truncated */
 } TruncateStmt;
 
 /* ----------------------
- *              Comment On Statement
+ *				Comment On Statement
  * ----------------------
  */
 typedef struct CommentStmt
 {
-  NodeTag type;
-  int objtype;                         /* Object's type */
-  char *objname;                       /* Name of the object */
-  char *objproperty;                   /* Property Id (such as column) */
-  List *objlist;                       /* Arguments for VAL objects */
-  char *comment;                       /* The comment to insert */
+	NodeTag		type;
+	int			objtype;		/* Object's type */
+	char	   *objname;		/* Name of the object */
+	char	   *objproperty;	/* Property Id (such as column) */
+	List	   *objlist;		/* Arguments for VAL objects */
+	char	   *comment;		/* The comment to insert */
 } CommentStmt;
-      
+
 /* ----------------------
  *		Extend Index Statement
  * ----------------------
@@ -738,7 +741,7 @@ typedef struct LockStmt
 typedef struct ConstraintsSetStmt
 {
 	NodeTag		type;
-	List		*constraints;
+	List	   *constraints;
 	bool		deferred;
 } ConstraintsSetStmt;
 
@@ -749,8 +752,8 @@ typedef struct ConstraintsSetStmt
 typedef struct ReindexStmt
 {
 	NodeTag		type;
-	int		reindexType;		/* INDEX|TABLE|DATABASE */
-	const	char   *name;			/* name to reindex */
+	int			reindexType;	/* INDEX|TABLE|DATABASE */
+	const char *name;			/* name to reindex */
 	bool		force;
 	bool		all;
 } ReindexStmt;
@@ -768,8 +771,9 @@ typedef struct InsertStmt
 {
 	NodeTag		type;
 	char	   *relname;		/* relation to insert into */
-	List	   *distinctClause;	/* NULL, list of DISTINCT ON exprs, or
-								 * lcons(NIL,NIL) for all (SELECT DISTINCT) */
+	List	   *distinctClause; /* NULL, list of DISTINCT ON exprs, or
+								 * lcons(NIL,NIL) for all (SELECT
+								 * DISTINCT) */
 	List	   *cols;			/* names of the columns */
 	List	   *targetList;		/* the target list (of ResTarget) */
 	List	   *fromClause;		/* the from clause */
@@ -813,8 +817,9 @@ typedef struct UpdateStmt
 typedef struct SelectStmt
 {
 	NodeTag		type;
-	List	   *distinctClause;	/* NULL, list of DISTINCT ON exprs, or
-								 * lcons(NIL,NIL) for all (SELECT DISTINCT) */
+	List	   *distinctClause; /* NULL, list of DISTINCT ON exprs, or
+								 * lcons(NIL,NIL) for all (SELECT
+								 * DISTINCT) */
 	char	   *into;			/* name of table (for select into table) */
 	List	   *targetList;		/* the target list (of ResTarget) */
 	List	   *fromClause;		/* the from clause */
@@ -839,7 +844,7 @@ typedef struct SelectStmt
  *	Supporting data structures for Parse Trees
  *
  *	Most of these node types appear in raw parsetrees output by the grammar,
- *	and get transformed to something else by the analyzer.  A few of them
+ *	and get transformed to something else by the analyzer.	A few of them
  *	are used as-is in transformed querytrees.
  ****************************************************************************/
 
@@ -951,7 +956,7 @@ typedef struct CaseWhen
  * in either "raw" form (an untransformed parse tree) or "cooked" form
  * (the nodeToString representation of an executable expression tree),
  * depending on how this ColumnDef node was created (by parsing, or by
- * inheritance from an existing relation).  We should never have both
+ * inheritance from an existing relation).	We should never have both
  * in the same node!
  *
  * The constraints list may contain a CONSTR_DEFAULT item in a raw
@@ -966,8 +971,9 @@ typedef struct ColumnDef
 	TypeName   *typename;		/* type of column */
 	bool		is_not_null;	/* flag to NOT NULL constraint */
 	bool		is_sequence;	/* is a sequence? */
-	Node	   *raw_default;	/* default value (untransformed parse tree) */
-	char	   *cooked_default;	/* nodeToString representation */
+	Node	   *raw_default;	/* default value (untransformed parse
+								 * tree) */
+	char	   *cooked_default; /* nodeToString representation */
 	List	   *constraints;	/* other constraints on column */
 } ColumnDef;
 
@@ -1141,7 +1147,7 @@ typedef struct TargetEntry
  *	  inFromCl marks those range variables that are listed in the FROM clause.
  *	  In SQL, the query can only refer to range variables listed in the
  *	  FROM clause, but POSTQUEL allows you to refer to tables not listed,
- *	  in which case a range table entry will be generated.  We still support
+ *	  in which case a range table entry will be generated.	We still support
  *	  this POSTQUEL feature, although there is some doubt whether it's
  *	  convenient or merely confusing.  The flag is needed since an
  *	  implicitly-added RTE shouldn't change the namespace for unqualified
@@ -1156,7 +1162,7 @@ typedef struct TargetEntry
  *	  Here we should get the product of the sizes of tx and ty.  However,
  *	  the query optimizer can simplify the WHERE clause to "TRUE", so
  *	  ty will no longer be referred to explicitly; without a flag forcing
- *	  it to be included in the join, we will get the wrong answer.  So,
+ *	  it to be included in the join, we will get the wrong answer.	So,
  *	  a POSTQUEL implicit RTE must be marked inJoinSet but not inFromCl.
  *--------------------
  */
diff --git a/src/include/nodes/pg_list.h b/src/include/nodes/pg_list.h
index 9f05bc7985ffd665a66f7e09ecaf6018d7e21027..c68f0659fa195c68394c08732f78f7d1916d6de3 100644
--- a/src/include/nodes/pg_list.h
+++ b/src/include/nodes/pg_list.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_list.h,v 1.16 2000/02/21 18:47:12 tgl Exp $
+ * $Id: pg_list.h,v 1.17 2000/04/12 17:16:40 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -27,12 +27,12 @@
  * The same Value struct is used for three node types: T_Integer,
  * T_Float, and T_String.  Integral values are actually represented
  * by a machine integer, but both floats and strings are represented
- * as strings.  Using T_Float as the node type simply indicates that
+ * as strings.	Using T_Float as the node type simply indicates that
  * the contents of the string look like a valid numeric literal.
  *
  * (Before Postgres 7.0, we used a double to represent T_Float,
  * but that creates loss-of-precision problems when the value is
- * ultimately destined to be converted to NUMERIC.  Since Value nodes
+ * ultimately destined to be converted to NUMERIC.	Since Value nodes
  * are only used in the parsing process, not for runtime data, it's
  * better to use the more general representation.)
  *
@@ -105,7 +105,7 @@ extern bool intMember(int datum, List *list);
 extern Value *makeInteger(long i);
 extern Value *makeFloat(char *numericStr);
 extern Value *makeString(char *str);
-extern List *makeList(void *elem, ...);
+extern List *makeList(void *elem,...);
 extern List *lappend(List *list, void *datum);
 extern List *lappendi(List *list, int datum);
 extern List *lremove(void *elem, List *list);
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
index 2731c57948cc13db433cd55f81a9b417ffc7cba2..1cab6e03fc0fecb2ef599bd6fe238519b60b3a11 100644
--- a/src/include/nodes/plannodes.h
+++ b/src/include/nodes/plannodes.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: plannodes.h,v 1.38 2000/02/15 20:49:25 tgl Exp $
+ * $Id: plannodes.h,v 1.39 2000/04/12 17:16:40 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -66,10 +66,13 @@ typedef struct Plan
 	NodeTag		type;
 
 	/* estimated execution costs for plan (see costsize.c for more info) */
-	Cost		startup_cost;	/* cost expended before fetching any tuples */
-	Cost		total_cost;		/* total cost (assuming all tuples fetched) */
+	Cost		startup_cost;	/* cost expended before fetching any
+								 * tuples */
+	Cost		total_cost;		/* total cost (assuming all tuples
+								 * fetched) */
 
-	/* planner's estimate of result size (note: LIMIT, if any, is not
+	/*
+	 * planner's estimate of result size (note: LIMIT, if any, is not
 	 * considered in setting plan_rows)
 	 */
 	double		plan_rows;		/* number of rows plan is expected to emit */
@@ -183,12 +186,12 @@ typedef struct IndexScan
 	List	   *indxid;
 	List	   *indxqual;
 	List	   *indxqualorig;
-	ScanDirection	indxorderdir;
+	ScanDirection indxorderdir;
 	IndexScanState *indxstate;
 } IndexScan;
 
 /* ----------------
- *              tid scan node
+ *				tid scan node
  * ----------------
  */
 typedef struct TidScan
@@ -199,7 +202,7 @@ typedef struct TidScan
 	TidScanState *tidstate;
 } TidScan;
 
-/* 
+/*
  * ==========
  * Join nodes
  * ==========
@@ -319,7 +322,8 @@ typedef struct Unique
 	Plan		plan;			/* noname node flattened out */
 	Oid			nonameid;
 	int			keycount;
-	int			numCols;		/* number of columns to check for uniqueness */
+	int			numCols;		/* number of columns to check for
+								 * uniqueness */
 	AttrNumber *uniqColIdx;		/* indexes into the target list */
 	UniqueState *uniquestate;
 } Unique;
@@ -375,10 +379,13 @@ typedef struct SubPlan
 	List	   *setParam;		/* non-correlated EXPR & EXISTS subqueries
 								 * have to set some Params for paren Plan */
 	List	   *parParam;		/* indices of corr. Vars from parent plan */
-	SubLink    *sublink;		/* SubLink node from parser; holds info about
-								 * what to do with subselect's results */
+	SubLink    *sublink;		/* SubLink node from parser; holds info
+								 * about what to do with subselect's
+								 * results */
+
 	/*
-	 * Remaining fields are working state for executor; not used in planning
+	 * Remaining fields are working state for executor; not used in
+	 * planning
 	 */
 	bool		shutdown;		/* TRUE = need to shutdown plan */
 	HeapTuple	curTuple;		/* copy of most recent tuple from subplan */
diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h
index 7c3e0c6c4b843ba5585a21599f852ce2fb9b8e00..926513e0af2357181603fac0957823b8693ab669 100644
--- a/src/include/nodes/primnodes.h
+++ b/src/include/nodes/primnodes.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: primnodes.h,v 1.40 2000/02/20 21:32:16 tgl Exp $
+ * $Id: primnodes.h,v 1.41 2000/04/12 17:16:40 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -29,7 +29,7 @@
  *		restype			- type of the value
  *		restypmod		- type-specific modifier of the value
  *		resname			- name of the resdom (could be NULL)
- *		ressortgroupref	- nonzero if referenced by a sort/group clause
+ *		ressortgroupref - nonzero if referenced by a sort/group clause
  *		reskey			- order of key in a sort (for those > 0)
  *		reskeyop		- sort operator's regproc Oid
  *		resjunk			- set to true to eliminate the attribute
@@ -37,12 +37,12 @@
  *
  * Notes:
  * ressortgroupref is the parse/plan-time representation of ORDER BY and
- * GROUP BY items.  Targetlist entries with ressortgroupref=0 are not
+ * GROUP BY items.	Targetlist entries with ressortgroupref=0 are not
  * sort/group items.  If ressortgroupref>0, then this item is an ORDER BY or
- * GROUP BY value.  No two entries in a targetlist may have the same nonzero
+ * GROUP BY value.	No two entries in a targetlist may have the same nonzero
  * ressortgroupref --- but there is no particular meaning to the nonzero
- * values, except as tags.  (For example, one must not assume that lower
- * ressortgroupref means a more significant sort key.)  The order of the
+ * values, except as tags.	(For example, one must not assume that lower
+ * ressortgroupref means a more significant sort key.)	The order of the
  * associated SortClause or GroupClause lists determine the semantics.
  *
  * reskey and reskeyop are the execution-time representation of sorting.
@@ -329,7 +329,7 @@ typedef struct Aggref
  *		subselect		- subselect as Query* or parsetree
  *
  * A SubLink represents a subselect appearing in an expression, and in some
- * cases also the combining operator(s) just above it.  The subLinkType
+ * cases also the combining operator(s) just above it.	The subLinkType
  * indicates the form of the expression represented:
  *	EXISTS_SUBLINK		EXISTS(SELECT ...)
  *	ALL_SUBLINK			(lefthand) op ALL (SELECT ...)
@@ -350,21 +350,21 @@ typedef struct Aggref
  * NOTE: lefthand and oper have varying meanings depending on where you look
  * in the parse/plan pipeline:
  * 1. gram.y delivers a list of the (untransformed) lefthand expressions in
- *    lefthand, and sets oper to a one-element list containing the string
- *    name of the operator.
+ *	  lefthand, and sets oper to a one-element list containing the string
+ *	  name of the operator.
  * 2. The parser's expression transformation transforms lefthand normally,
- *    and replaces oper with a list of Oper nodes, one per lefthand
- *    expression.  These nodes represent the parser's resolution of exactly
- *    which operator to apply to each pair of lefthand and targetlist
- *    expressions.  However, we have not constructed actual Expr trees for
- *    these operators yet.  This is the representation seen in saved rules
- *    and in the rewriter.
+ *	  and replaces oper with a list of Oper nodes, one per lefthand
+ *	  expression.  These nodes represent the parser's resolution of exactly
+ *	  which operator to apply to each pair of lefthand and targetlist
+ *	  expressions.	However, we have not constructed actual Expr trees for
+ *	  these operators yet.	This is the representation seen in saved rules
+ *	  and in the rewriter.
  * 3. Finally, the planner converts the oper list to a list of normal Expr
- *    nodes representing the application of the operator(s) to the lefthand
- *    expressions and values from the inner targetlist.  The inner
- *    targetlist items are represented by placeholder Param or Const nodes.
- *    The lefthand field is set to NIL, since its expressions are now in
- *    the Expr list.  This representation is passed to the executor.
+ *	  nodes representing the application of the operator(s) to the lefthand
+ *	  expressions and values from the inner targetlist.  The inner
+ *	  targetlist items are represented by placeholder Param or Const nodes.
+ *	  The lefthand field is set to NIL, since its expressions are now in
+ *	  the Expr list.  This representation is passed to the executor.
  *
  * Planner routines that might see either representation 2 or 3 can tell
  * the difference by checking whether lefthand is NIL or not.  Also,
@@ -372,7 +372,7 @@ typedef struct Aggref
  * found in SubLinks that are children of SubPlan nodes.
  *
  * In EXISTS and EXPR SubLinks, both lefthand and oper are unused and are
- * always NIL.  useor is not significant either for these sublink types.
+ * always NIL.	useor is not significant either for these sublink types.
  * ----------------
  */
 typedef enum SubLinkType
@@ -432,12 +432,12 @@ typedef struct Array
  *		refelemlength	- length of the array element type
  *		refelembyval	- is the element type pass-by-value?
  *		refupperindexpr - expressions that evaluate to upper array indexes
- *		reflowerindexpr	- expressions that evaluate to lower array indexes
+ *		reflowerindexpr - expressions that evaluate to lower array indexes
  *		refexpr			- the expression that evaluates to an array value
  *		refassgnexpr	- expression for the source value, or NULL if fetch
  *
  * If reflowerindexpr = NIL, then we are fetching or storing a single array
- * element at the subscripts given by refupperindexpr.  Otherwise we are
+ * element at the subscripts given by refupperindexpr.	Otherwise we are
  * fetching or storing an array slice, that is a rectangular subarray
  * with lower and upper bounds given by the index expressions.
  * reflowerindexpr must be the same length as refupperindexpr when it
@@ -445,7 +445,7 @@ typedef struct Array
  *
  * Note: array types can be fixed-length (refattrlength > 0), but only
  * when the element type is itself fixed-length.  Otherwise they are
- * varlena structures and have refattrlength = -1.  In any case,
+ * varlena structures and have refattrlength = -1.	In any case,
  * an array type is never pass-by-value.
  *
  * Note: currently, refelemtype is NOT the element type, but the array type,
diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h
index f01877a9e892eaae2418a19bc29e893ddc98ada7..b7d651310669e0e342ad13614ead91eeb737c76e 100644
--- a/src/include/nodes/relation.h
+++ b/src/include/nodes/relation.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: relation.h,v 1.46 2000/03/22 22:08:29 tgl Exp $
+ * $Id: relation.h,v 1.47 2000/04/12 17:16:40 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -30,7 +30,10 @@ typedef List *Relids;
  * When looking for a "cheapest path", this enum specifies whether we want
  * cheapest startup cost or cheapest total cost.
  */
-typedef enum CostSelector { STARTUP_COST, TOTAL_COST } CostSelector;
+typedef enum CostSelector
+{
+	STARTUP_COST, TOTAL_COST
+} CostSelector;
 
 /*
  * RelOptInfo
@@ -82,7 +85,7 @@ typedef enum CostSelector { STARTUP_COST, TOTAL_COST } CostSelector;
  * (For example, in a 3-base-rel join, a clause relating rels 1 and 2 must be
  * treated as a restrictclause if we join {1} and {2 3} to make {1 2 3}; but
  * if we join {1 2} and {3} then that clause will be a restrictclause in {1 2}
- * and should not be processed again at the level of {1 2 3}.)  Therefore,
+ * and should not be processed again at the level of {1 2 3}.)	Therefore,
  * the restrictinfo list in the join case appears in individual JoinPaths
  * (field joinrestrictinfo), not in the parent relation.  But it's OK for
  * the RelOptInfo to store the joininfo lists, because those are the same
@@ -98,7 +101,8 @@ typedef struct RelOptInfo
 	NodeTag		type;
 
 	/* all relations included in this RelOptInfo */
-	Relids		relids;			/* integer list of base relids (RT indexes) */
+	Relids		relids;			/* integer list of base relids (RT
+								 * indexes) */
 
 	/* size estimates generated by planner */
 	double		rows;			/* estimated number of result tuples */
@@ -117,11 +121,14 @@ typedef struct RelOptInfo
 	double		tuples;
 
 	/* used by various scans and joins: */
-	List	   *baserestrictinfo; /* RestrictInfo structures (if base rel) */
-	Cost		baserestrictcost; /* cost of evaluating the above */
+	List	   *baserestrictinfo;		/* RestrictInfo structures (if
+										 * base rel) */
+	Cost		baserestrictcost;		/* cost of evaluating the above */
 	List	   *joininfo;		/* JoinInfo structures */
 	List	   *innerjoin;		/* potential indexscans for nestloop joins */
-	/* innerjoin indexscans are not in the main pathlist because they are
+
+	/*
+	 * innerjoin indexscans are not in the main pathlist because they are
 	 * not usable except in specific join contexts; we have to test before
 	 * seeing whether they can be used.
 	 */
@@ -143,8 +150,8 @@ typedef struct RelOptInfo
  *		ordering - List of PG_OPERATOR OIDs which order the indexscan result
  *		relam	  - the OID of the pg_am of the index
  *		amcostestimate - OID of the relam's cost estimator
- *		indproc	  - OID of the function if a functional index, else 0
- *		indpred	  - index predicate if a partial index, else NULL
+ *		indproc   - OID of the function if a functional index, else 0
+ *		indpred   - index predicate if a partial index, else NULL
  *		lossy	  - true if index is lossy (may return non-matching tuples)
  *
  *		NB. the last element of the arrays classlist, indexkeys and ordering
@@ -167,7 +174,7 @@ typedef struct IndexOptInfo
 	Oid		   *ordering;		/* OIDs of sort operators for each key */
 	Oid			relam;			/* OID of the access method (in pg_am) */
 
-	RegProcedure amcostestimate; /* OID of the access method's cost fcn */
+	RegProcedure amcostestimate;/* OID of the access method's cost fcn */
 
 	Oid			indproc;		/* if a functional index */
 	List	   *indpred;		/* if a partial index */
@@ -178,11 +185,11 @@ typedef struct IndexOptInfo
  * PathKeys
  *
  *	The sort ordering of a path is represented by a list of sublists of
- *	PathKeyItem nodes.  An empty list implies no known ordering.  Otherwise
+ *	PathKeyItem nodes.	An empty list implies no known ordering.  Otherwise
  *	the first sublist represents the primary sort key, the second the
- *	first secondary sort key, etc.  Each sublist contains one or more
+ *	first secondary sort key, etc.	Each sublist contains one or more
  *	PathKeyItem nodes, each of which can be taken as the attribute that
- *	appears at that sort position.  (See the top of optimizer/path/pathkeys.c
+ *	appears at that sort position.	(See the top of optimizer/path/pathkeys.c
  *	for more information.)
  */
 
@@ -192,11 +199,12 @@ typedef struct PathKeyItem
 
 	Node	   *key;			/* the item that is ordered */
 	Oid			sortop;			/* the ordering operator ('<' op) */
+
 	/*
-	 * key typically points to a Var node, ie a relation attribute,
-	 * but it can also point to a Func clause representing the value
-	 * indexed by a functional index.  Someday we might allow arbitrary
-	 * expressions as path keys, so don't assume more than you must.
+	 * key typically points to a Var node, ie a relation attribute, but it
+	 * can also point to a Func clause representing the value indexed by a
+	 * functional index.  Someday we might allow arbitrary expressions as
+	 * path keys, so don't assume more than you must.
 	 */
 } PathKeyItem;
 
@@ -212,8 +220,10 @@ typedef struct Path
 	RelOptInfo *parent;			/* the relation this path can build */
 
 	/* estimated execution costs for path (see costsize.c for more info) */
-	Cost		startup_cost;	/* cost expended before fetching any tuples */
-	Cost		total_cost;		/* total cost (assuming all tuples fetched) */
+	Cost		startup_cost;	/* cost expended before fetching any
+								 * tuples */
+	Cost		total_cost;		/* total cost (assuming all tuples
+								 * fetched) */
 
 	NodeTag		pathtype;		/* tag identifying scan/join method */
 	/* XXX why is pathtype separate from the NodeTag? */
@@ -223,10 +233,10 @@ typedef struct Path
 } Path;
 
 /*----------
- * IndexPath represents an index scan.  Although an indexscan can only read
+ * IndexPath represents an index scan.	Although an indexscan can only read
  * a single relation, it can scan it more than once, potentially using a
  * different index during each scan.  The result is the union (OR) of all the
- * tuples matched during any scan.  (The executor is smart enough not to return
+ * tuples matched during any scan.	(The executor is smart enough not to return
  * the same tuple more than once, even if it is matched in multiple scans.)
  *
  * 'indexid' is a list of index relation OIDs, one per scan to be performed.
@@ -272,10 +282,10 @@ typedef struct IndexPath
 
 typedef struct TidPath
 {
-	Path	path;
-	List	*tideval;
-	Relids	unjoined_relids; /* some rels not yet part of my Path */
-} TidPath;  
+	Path		path;
+	List	   *tideval;
+	Relids		unjoined_relids;/* some rels not yet part of my Path */
+} TidPath;
 
 /*
  * All join-type paths share these fields.
@@ -287,8 +297,10 @@ typedef struct JoinPath
 
 	Path	   *outerjoinpath;	/* path for the outer side of the join */
 	Path	   *innerjoinpath;	/* path for the inner side of the join */
-	List	   *joinrestrictinfo; /* RestrictInfos to apply to join */
-	/* See the notes for RelOptInfo to understand why joinrestrictinfo is
+	List	   *joinrestrictinfo;		/* RestrictInfos to apply to join */
+
+	/*
+	 * See the notes for RelOptInfo to understand why joinrestrictinfo is
 	 * needed in JoinPath, and can't be merged into the parent RelOptInfo.
 	 */
 } JoinPath;
@@ -303,7 +315,7 @@ typedef JoinPath NestPath;
  * A mergejoin path has these fields.
  *
  * path_mergeclauses lists the clauses (in the form of RestrictInfos)
- * that will be used in the merge.  (Before 7.0, this was a list of
+ * that will be used in the merge.	(Before 7.0, this was a list of
  * bare clause expressions, but we can save on list memory by leaving
  * it in the form of a RestrictInfo list.)
  *
@@ -321,7 +333,8 @@ typedef JoinPath NestPath;
 typedef struct MergePath
 {
 	JoinPath	jpath;
-	List	   *path_mergeclauses; /* join clauses to be used for merge */
+	List	   *path_mergeclauses;		/* join clauses to be used for
+										 * merge */
 	List	   *outersortkeys;	/* keys for explicit sort, if any */
 	List	   *innersortkeys;	/* keys for explicit sort, if any */
 } MergePath;
@@ -340,14 +353,14 @@ typedef struct MergePath
 typedef struct HashPath
 {
 	JoinPath	jpath;
-	List	   *path_hashclauses; /* join clauses used for hashing */
+	List	   *path_hashclauses;		/* join clauses used for hashing */
 } HashPath;
 
 /*
  * Restriction clause info.
  *
  * We create one of these for each AND sub-clause of a restriction condition
- * (WHERE clause).  Since the restriction clauses are logically ANDed, we
+ * (WHERE clause).	Since the restriction clauses are logically ANDed, we
  * can use any one of them or any subset of them to filter out tuples,
  * without having to evaluate the rest.  The RestrictInfo node itself stores
  * data used by the optimizer while choosing the best query plan.
@@ -376,7 +389,7 @@ typedef struct HashPath
  * sequence we use.  So, these clauses cannot be associated directly with
  * the join RelOptInfo, but must be kept track of on a per-join-path basis.
  *
- * In general, the referenced clause might be arbitrarily complex.  The
+ * In general, the referenced clause might be arbitrarily complex.	The
  * kinds of clauses we can handle as indexscan quals, mergejoin clauses,
  * or hashjoin clauses are fairly limited --- the code for each kind of
  * path is responsible for identifying the restrict clauses it can use
@@ -395,16 +408,16 @@ typedef struct RestrictInfo
 	Expr	   *clause;			/* the represented clause of WHERE cond */
 
 	/* only used if clause is an OR clause: */
-	List	   *subclauseindices;	/* indexes matching subclauses */
+	List	   *subclauseindices;		/* indexes matching subclauses */
 	/* subclauseindices is a List of Lists of IndexOptInfos */
 
 	/* valid if clause is mergejoinable, else InvalidOid: */
-	Oid			mergejoinoperator;	/* copy of clause operator */
+	Oid			mergejoinoperator;		/* copy of clause operator */
 	Oid			left_sortop;	/* leftside sortop needed for mergejoin */
 	Oid			right_sortop;	/* rightside sortop needed for mergejoin */
 
 	/* valid if clause is hashjoinable, else InvalidOid: */
-	Oid			hashjoinoperator;	/* copy of clause operator */
+	Oid			hashjoinoperator;		/* copy of clause operator */
 } RestrictInfo;
 
 /*
@@ -424,8 +437,8 @@ typedef struct RestrictInfo
 typedef struct JoinInfo
 {
 	NodeTag		type;
-	Relids		unjoined_relids; /* some rels not yet part of my RelOptInfo */
-	List	   *jinfo_restrictinfo;	/* relevant RestrictInfos */
+	Relids		unjoined_relids;/* some rels not yet part of my RelOptInfo */
+	List	   *jinfo_restrictinfo;		/* relevant RestrictInfos */
 } JoinInfo;
 
 /*
@@ -463,7 +476,7 @@ typedef struct Stream
 	StreamPtr	downstream;
 	bool		groupup;
 	Cost		groupcost;
-	Selectivity	groupsel;
+	Selectivity groupsel;
 } Stream;
 
 #endif	 /* RELATION_H */
diff --git a/src/include/optimizer/clauses.h b/src/include/optimizer/clauses.h
index a6f6ea2e5f3d0e0f8bd2183e4c2c44978d4c4b2d..9cccc65454ee5a793c393136b8f31a0d7a4964f8 100644
--- a/src/include/optimizer/clauses.h
+++ b/src/include/optimizer/clauses.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: clauses.h,v 1.35 2000/04/04 01:21:45 tgl Exp $
+ * $Id: clauses.h,v 1.36 2000/04/12 17:16:41 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -50,8 +50,8 @@ extern List *pull_constant_clauses(List *quals, List **constantQual);
 extern void clause_get_relids_vars(Node *clause, Relids *relids, List **vars);
 extern int	NumRelids(Node *clause);
 extern void get_relattval(Node *clause, int targetrelid,
-						  int *relid, AttrNumber *attno,
-						  Datum *constval, int *flag);
+			  int *relid, AttrNumber *attno,
+			  Datum *constval, int *flag);
 extern void get_rels_atts(Node *clause, int *relid1,
 			  AttrNumber *attno1, int *relid2, AttrNumber *attno2);
 extern void CommuteClause(Expr *clause);
@@ -59,9 +59,9 @@ extern void CommuteClause(Expr *clause);
 extern Node *eval_const_expressions(Node *node);
 
 extern bool expression_tree_walker(Node *node, bool (*walker) (),
-								   void *context);
-extern Node *expression_tree_mutator(Node *node, Node * (*mutator) (),
-									 void *context);
+											   void *context);
+extern Node *expression_tree_mutator(Node *node, Node *(*mutator) (),
+												 void *context);
 
 #define is_subplan(clause)	((clause) != NULL && \
 							 IsA(clause, Expr) && \
diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h
index e8673675f8981afaf50b4421e544bd97f70010d3..dabfb6817562fcf48c688a07df0aa89c5b146b4e 100644
--- a/src/include/optimizer/cost.h
+++ b/src/include/optimizer/cost.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: cost.h,v 1.31 2000/03/22 22:08:30 tgl Exp $
+ * $Id: cost.h,v 1.32 2000/04/12 17:16:42 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -20,7 +20,7 @@
 /* NB: cost-estimation code should use the variables, not these constants! */
 #define DEFAULT_EFFECTIVE_CACHE_SIZE  1000.0	/* measured in pages */
 #define DEFAULT_RANDOM_PAGE_COST  4.0
-#define DEFAULT_CPU_TUPLE_COST  0.01
+#define DEFAULT_CPU_TUPLE_COST	0.01
 #define DEFAULT_CPU_INDEX_TUPLE_COST 0.001
 #define DEFAULT_CPU_OPERATOR_COST  0.0025
 
@@ -53,36 +53,36 @@ extern bool enable_hashjoin;
 
 extern void cost_seqscan(Path *path, RelOptInfo *baserel);
 extern void cost_index(Path *path, Query *root,
-					   RelOptInfo *baserel, IndexOptInfo *index,
-					   List *indexQuals, bool is_injoin);
+		   RelOptInfo *baserel, IndexOptInfo *index,
+		   List *indexQuals, bool is_injoin);
 extern void cost_tidscan(Path *path, RelOptInfo *baserel, List *tideval);
 extern void cost_sort(Path *path, List *pathkeys, double tuples, int width);
 extern void cost_nestloop(Path *path, Path *outer_path, Path *inner_path,
-						  List *restrictlist);
+			  List *restrictlist);
 extern void cost_mergejoin(Path *path, Path *outer_path, Path *inner_path,
-						   List *restrictlist,
-						   List *outersortkeys, List *innersortkeys);
+			   List *restrictlist,
+			   List *outersortkeys, List *innersortkeys);
 extern void cost_hashjoin(Path *path, Path *outer_path, Path *inner_path,
-						  List *restrictlist, Selectivity innerdisbursion);
+			  List *restrictlist, Selectivity innerdisbursion);
 extern Cost cost_qual_eval(List *quals);
 extern void set_baserel_size_estimates(Query *root, RelOptInfo *rel);
 extern void set_joinrel_size_estimates(Query *root, RelOptInfo *rel,
-									   RelOptInfo *outer_rel,
-									   RelOptInfo *inner_rel,
-									   List *restrictlist);
+						   RelOptInfo *outer_rel,
+						   RelOptInfo *inner_rel,
+						   List *restrictlist);
 
 /*
  * prototypes for clausesel.c
  *	  routines to compute clause selectivities
  */
 extern Selectivity restrictlist_selectivity(Query *root,
-											List *restrictinfo_list,
-											int varRelid);
+						 List *restrictinfo_list,
+						 int varRelid);
 extern Selectivity clauselist_selectivity(Query *root,
-										  List *clauses,
-										  int varRelid);
+					   List *clauses,
+					   int varRelid);
 extern Selectivity clause_selectivity(Query *root,
-									  Node *clause,
-									  int varRelid);
+				   Node *clause,
+				   int varRelid);
 
 #endif	 /* COST_H */
diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h
index e59848278f4f626c011a0277e984e8451c6bb5b0..b8788851e2b4dd151f613a7e7957f930020691eb 100644
--- a/src/include/optimizer/pathnode.h
+++ b/src/include/optimizer/pathnode.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pathnode.h,v 1.26 2000/02/15 20:49:26 tgl Exp $
+ * $Id: pathnode.h,v 1.27 2000/04/12 17:16:42 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -20,48 +20,48 @@
  * prototypes for pathnode.c
  */
 extern int compare_path_costs(Path *path1, Path *path2,
-							  CostSelector criterion);
+				   CostSelector criterion);
 extern int compare_fractional_path_costs(Path *path1, Path *path2,
-										 double fraction);
+							  double fraction);
 extern void set_cheapest(RelOptInfo *parent_rel);
 extern void add_path(RelOptInfo *parent_rel, Path *new_path);
 
 extern Path *create_seqscan_path(RelOptInfo *rel);
 extern IndexPath *create_index_path(Query *root, RelOptInfo *rel,
-									IndexOptInfo *index,
-									List *restriction_clauses,
-									ScanDirection indexscandir);
+				  IndexOptInfo *index,
+				  List *restriction_clauses,
+				  ScanDirection indexscandir);
 extern TidPath *create_tidscan_path(RelOptInfo *rel, List *tideval);
 
 extern NestPath *create_nestloop_path(RelOptInfo *joinrel,
-									  Path *outer_path,
-									  Path *inner_path,
-									  List *restrict_clauses,
-									  List *pathkeys);
+					 Path *outer_path,
+					 Path *inner_path,
+					 List *restrict_clauses,
+					 List *pathkeys);
 
 extern MergePath *create_mergejoin_path(RelOptInfo *joinrel,
-										Path *outer_path,
-										Path *inner_path,
-										List *restrict_clauses,
-										List *pathkeys,
-										List *mergeclauses,
-										List *outersortkeys,
-										List *innersortkeys);
+					  Path *outer_path,
+					  Path *inner_path,
+					  List *restrict_clauses,
+					  List *pathkeys,
+					  List *mergeclauses,
+					  List *outersortkeys,
+					  List *innersortkeys);
 
 extern HashPath *create_hashjoin_path(RelOptInfo *joinrel,
-									  Path *outer_path,
-									  Path *inner_path,
-									  List *restrict_clauses,
-									  List *hashclauses,
-									  Selectivity innerdisbursion);
+					 Path *outer_path,
+					 Path *inner_path,
+					 List *restrict_clauses,
+					 List *hashclauses,
+					 Selectivity innerdisbursion);
 
 /*
  * prototypes for relnode.c
  */
 extern RelOptInfo *get_base_rel(Query *root, int relid);
 extern RelOptInfo *get_join_rel(Query *root, RelOptInfo *outer_rel,
-								RelOptInfo *inner_rel,
-								List **restrictlist_ptr);
+			 RelOptInfo *inner_rel,
+			 List **restrictlist_ptr);
 
 /*
  * prototypes for indexnode.h
diff --git a/src/include/optimizer/paths.h b/src/include/optimizer/paths.h
index d7a0cc2d54602f4c6b21977d2adb13f2314cc3fc..0a2f56db63afd1fe1a7fd22fcaa758f7f786abe1 100644
--- a/src/include/optimizer/paths.h
+++ b/src/include/optimizer/paths.h
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: paths.h,v 1.43 2000/02/15 20:49:26 tgl Exp $
+ * $Id: paths.h,v 1.44 2000/04/12 17:16:42 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -34,13 +34,13 @@ extern RelOptInfo *make_one_rel(Query *root);
  *	  routines to generate index paths
  */
 extern void create_index_paths(Query *root, RelOptInfo *rel, List *indices,
-							   List *restrictinfo_list,
-							   List *joininfo_list);
+				   List *restrictinfo_list,
+				   List *joininfo_list);
 extern Oid indexable_operator(Expr *clause, Oid opclass, Oid relam,
-							  bool indexkey_on_left);
+				   bool indexkey_on_left);
 extern List *extract_or_indexqual_conditions(RelOptInfo *rel,
-											 IndexOptInfo *index,
-											 Expr *orsubclause);
+								IndexOptInfo *index,
+								Expr *orsubclause);
 extern List *expand_indexqual_conditions(List *indexquals);
 
 /*
@@ -48,7 +48,7 @@ extern List *expand_indexqual_conditions(List *indexquals);
  *	  additional routines for indexable OR clauses
  */
 extern void create_or_index_paths(Query *root, RelOptInfo *rel,
-								  List *clauses);
+					  List *clauses);
 
 /*
  * tidpath.h
@@ -61,9 +61,9 @@ extern void create_tidscan_paths(Query *root, RelOptInfo *rel);
  *	   routines to create join paths
  */
 extern void add_paths_to_joinrel(Query *root, RelOptInfo *joinrel,
-								 RelOptInfo *outerrel,
-								 RelOptInfo *innerrel,
-								 List *restrictlist);
+					 RelOptInfo *outerrel,
+					 RelOptInfo *innerrel,
+					 List *restrictlist);
 
 /*
  * joinrels.c
@@ -71,11 +71,11 @@ extern void add_paths_to_joinrel(Query *root, RelOptInfo *joinrel,
  */
 extern void make_rels_by_joins(Query *root, int level);
 extern RelOptInfo *make_rels_by_clause_joins(Query *root,
-											 RelOptInfo *old_rel,
-											 List *other_rels);
+						  RelOptInfo *old_rel,
+						  List *other_rels);
 extern RelOptInfo *make_rels_by_clauseless_joins(Query *root,
-												 RelOptInfo *old_rel,
-												 List *other_rels);
+							  RelOptInfo *old_rel,
+							  List *other_rels);
 
 /*
  * pathkeys.c
@@ -94,22 +94,22 @@ extern List *canonicalize_pathkeys(Query *root, List *pathkeys);
 extern PathKeysComparison compare_pathkeys(List *keys1, List *keys2);
 extern bool pathkeys_contained_in(List *keys1, List *keys2);
 extern Path *get_cheapest_path_for_pathkeys(List *paths, List *pathkeys,
-											CostSelector cost_criterion);
+							   CostSelector cost_criterion);
 extern Path *get_cheapest_fractional_path_for_pathkeys(List *paths,
-													   List *pathkeys,
-													   double fraction);
+										  List *pathkeys,
+										  double fraction);
 extern List *build_index_pathkeys(Query *root, RelOptInfo *rel,
-								  IndexOptInfo *index,
-								  ScanDirection scandir);
+					 IndexOptInfo *index,
+					 ScanDirection scandir);
 extern List *build_join_pathkeys(List *outer_pathkeys,
-								 List *join_rel_tlist,
-								 List *equi_key_list);
+					List *join_rel_tlist,
+					List *equi_key_list);
 extern List *make_pathkeys_for_sortclauses(List *sortclauses,
-										   List *tlist);
+							  List *tlist);
 extern List *find_mergeclauses_for_pathkeys(List *pathkeys,
-											List *restrictinfos);
+							   List *restrictinfos);
 extern List *make_pathkeys_for_mergeclauses(Query *root,
-											List *mergeclauses,
-											List *tlist);
+							   List *mergeclauses,
+							   List *tlist);
 
 #endif	 /* PATHS_H */
diff --git a/src/include/optimizer/plancat.h b/src/include/optimizer/plancat.h
index fb44b5c3038491ab16285e91d17b59e235c63086..745d8dc73ef3cd6c15d7efeed87f79a246e135d4 100644
--- a/src/include/optimizer/plancat.h
+++ b/src/include/optimizer/plancat.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: plancat.h,v 1.17 2000/01/26 05:58:20 momjian Exp $
+ * $Id: plancat.h,v 1.18 2000/04/12 17:16:42 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -18,7 +18,7 @@
 
 
 extern void relation_info(Query *root, Index relid,
-						  bool *hasindex, long *pages, double *tuples);
+			  bool *hasindex, long *pages, double *tuples);
 
 extern List *find_secondary_indexes(Query *root, Index relid);
 
diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h
index 2d61a035bf86ea72d77a42f5a17aa6873938dc46..e0a0d84bc8ac24bfac4cd32f81592fe828b19b6c 100644
--- a/src/include/optimizer/planmain.h
+++ b/src/include/optimizer/planmain.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: planmain.h,v 1.38 2000/02/15 20:49:26 tgl Exp $
+ * $Id: planmain.h,v 1.39 2000/04/12 17:16:42 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -21,7 +21,7 @@
  * prototypes for plan/planmain.c
  */
 extern Plan *query_planner(Query *root, List *tlist, List *qual,
-						   double tuple_fraction);
+			  double tuple_fraction);
 
 /*
  * prototypes for plan/createplan.c
@@ -49,7 +49,7 @@ extern void add_missing_rels_to_query(Query *root);
  */
 extern void set_plan_references(Plan *plan);
 extern List *join_references(List *clauses, List *outer_tlist,
-							 List *inner_tlist, Index acceptable_rel);
+				List *inner_tlist, Index acceptable_rel);
 extern void fix_opids(Node *node);
 
 /*
diff --git a/src/include/optimizer/subselect.h b/src/include/optimizer/subselect.h
index f4e511216133648459e8c7ecb5b59ff60d6c1edb..9c56a7592ba380ce8880130ef4ace5488376cd48 100644
--- a/src/include/optimizer/subselect.h
+++ b/src/include/optimizer/subselect.h
@@ -9,7 +9,7 @@
 
 #include "nodes/plannodes.h"
 
-extern Index PlannerQueryLevel;	/* level of current query */
+extern Index PlannerQueryLevel; /* level of current query */
 extern List *PlannerInitPlan;	/* init subplans for current query */
 extern List *PlannerParamVar;	/* to get Var from Param->paramid */
 extern int	PlannerPlanId;		/* to assign unique ID to subquery plans */
diff --git a/src/include/optimizer/tlist.h b/src/include/optimizer/tlist.h
index dba93c0d173f8e5659c1d13fb37e27c1a7948cc2..3f1c17c9952d77bae0af2b63d3322e7af8116671 100644
--- a/src/include/optimizer/tlist.h
+++ b/src/include/optimizer/tlist.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: tlist.h,v 1.24 2000/01/27 18:11:45 tgl Exp $
+ * $Id: tlist.h,v 1.25 2000/04/12 17:16:42 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -30,8 +30,8 @@ extern List *add_to_flat_tlist(List *tlist, List *vars);
 extern Var *get_expr(TargetEntry *tle);
 
 extern TargetEntry *get_sortgroupclause_tle(SortClause *sortClause,
-											List *targetList);
+						List *targetList);
 extern Node *get_sortgroupclause_expr(SortClause *sortClause,
-									  List *targetList);
+						 List *targetList);
 
 #endif	 /* TLIST_H */
diff --git a/src/include/parser/gramparse.h b/src/include/parser/gramparse.h
index 5f4e5a6af76a09a3684ad1851c42c107af8e2fee..02c95745fee356d10881bbdee69f11d4aa971c02 100644
--- a/src/include/parser/gramparse.h
+++ b/src/include/parser/gramparse.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: gramparse.h,v 1.11 2000/01/26 05:58:26 momjian Exp $
+ * $Id: gramparse.h,v 1.12 2000/04/12 17:16:44 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -18,7 +18,7 @@
 /* from scan.l */
 extern void init_io(void);
 extern int	yylex(void);
-extern void yyerror(const char * message);
+extern void yyerror(const char *message);
 
 /* from gram.y */
 extern Oid	param_type(int t);
diff --git a/src/include/parser/parse_agg.h b/src/include/parser/parse_agg.h
index 324931d12d5df88a63904bd063d9525d0bd8f775..2edc2fff7054b8c535a6691b05e0d63af391e6de 100644
--- a/src/include/parser/parse_agg.h
+++ b/src/include/parser/parse_agg.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: parse_agg.h,v 1.14 2000/01/26 05:58:26 momjian Exp $
+ * $Id: parse_agg.h,v 1.15 2000/04/12 17:16:45 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -19,8 +19,8 @@
 extern void AddAggToParseState(ParseState *pstate, Aggref *aggref);
 extern void parseCheckAggregates(ParseState *pstate, Query *qry);
 extern Aggref *ParseAgg(ParseState *pstate, char *aggname, Oid basetype,
-						List *args, bool agg_star, bool agg_distinct,
-						int precedence);
+		 List *args, bool agg_star, bool agg_distinct,
+		 int precedence);
 extern void agg_error(char *caller, char *aggname, Oid basetypeID);
 
 #endif	 /* PARSE_AGG_H */
diff --git a/src/include/parser/parse_clause.h b/src/include/parser/parse_clause.h
index 58b8fc60fa49d6c8b0fcc5fd12f3f529ad70f7c1..dc665530f8c03609f06f69e08e9bc7ba89f03238 100644
--- a/src/include/parser/parse_clause.h
+++ b/src/include/parser/parse_clause.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: parse_clause.h,v 1.16 2000/02/15 03:38:28 thomas Exp $
+ * $Id: parse_clause.h,v 1.17 2000/04/12 17:16:45 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -20,11 +20,11 @@ extern void makeRangeTable(ParseState *pstate, List *frmList);
 extern void setTargetTable(ParseState *pstate, char *relname);
 extern Node *transformWhereClause(ParseState *pstate, Node *where);
 extern List *transformGroupClause(ParseState *pstate, List *grouplist,
-								  List *targetlist);
+					 List *targetlist);
 extern List *transformSortClause(ParseState *pstate, List *orderlist,
-								 List *targetlist);
+					List *targetlist);
 extern List *transformDistinctClause(ParseState *pstate, List *distinctlist,
-									 List *targetlist, List **sortClause);
+						List *targetlist, List **sortClause);
 
 extern List *addAllTargetsToSortList(List *sortlist, List *targetlist);
 extern Index assignSortGroupRef(TargetEntry *tle, List *tlist);
diff --git a/src/include/parser/parse_coerce.h b/src/include/parser/parse_coerce.h
index 19dd42c9773cbad63f9e65741928751dfc68d317..0bb324402fbc13b943186e2c285510123284598d 100644
--- a/src/include/parser/parse_coerce.h
+++ b/src/include/parser/parse_coerce.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: parse_coerce.h,v 1.21 2000/03/20 15:42:47 momjian Exp $
+ * $Id: parse_coerce.h,v 1.22 2000/04/12 17:16:45 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -126,8 +126,8 @@ extern CATEGORY TypeCategory(Oid type);
 
 extern bool can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids);
 extern Node *coerce_type(ParseState *pstate, Node *node, Oid inputTypeId,
-						 Oid targetTypeId, int32 atttypmod);
+			Oid targetTypeId, int32 atttypmod);
 extern Node *coerce_type_typmod(ParseState *pstate, Node *node,
-								Oid targetTypeId, int32 atttypmod);
+				   Oid targetTypeId, int32 atttypmod);
 
 #endif	 /* PARSE_COERCE_H */
diff --git a/src/include/parser/parse_func.h b/src/include/parser/parse_func.h
index b191944ee2f3ac330fc259a37c66e7a4d0c87d04..836626486b75c5608e458db6ea0ce4f22efc51a7 100644
--- a/src/include/parser/parse_func.h
+++ b/src/include/parser/parse_func.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: parse_func.h,v 1.23 2000/03/16 06:35:06 tgl Exp $
+ * $Id: parse_func.h,v 1.24 2000/04/12 17:16:45 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -41,15 +41,15 @@ typedef struct _CandidateList
 extern Node *ParseNestedFuncOrColumn(ParseState *pstate, Attr *attr,
 						int *curr_resno, int precedence);
 extern Node *ParseFuncOrColumn(ParseState *pstate,
-							   char *funcname, List *fargs,
-							   bool agg_star, bool agg_distinct,
-							   int *curr_resno, int precedence);
+				  char *funcname, List *fargs,
+				  bool agg_star, bool agg_distinct,
+				  int *curr_resno, int precedence);
 
 extern List *setup_base_tlist(Oid typeid);
 
 extern bool typeInheritsFrom(Oid subclassTypeId, Oid superclassTypeId);
 
 extern void func_error(char *caller, char *funcname,
-					   int nargs, Oid *argtypes, char *msg);
+		   int nargs, Oid *argtypes, char *msg);
 
 #endif	 /* PARSE_FUNC_H */
diff --git a/src/include/parser/parse_node.h b/src/include/parser/parse_node.h
index 16641b530a2cb975e6ef65c8d2fbd29c3ae70c11..583ce8ce6a45d9ef3c70dc70af215bd54dfcfe48 100644
--- a/src/include/parser/parse_node.h
+++ b/src/include/parser/parse_node.h
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: parse_node.h,v 1.18 2000/02/15 03:38:29 thomas Exp $
+ * $Id: parse_node.h,v 1.19 2000/04/12 17:16:45 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -42,14 +42,14 @@ typedef struct ParseState
 extern ParseState *make_parsestate(ParseState *parentParseState);
 extern Expr *make_op(char *opname, Node *ltree, Node *rtree);
 extern Node *make_operand(char *opname, Node *tree,
-						  Oid orig_typeId, Oid target_typeId);
+			 Oid orig_typeId, Oid target_typeId);
 extern Var *make_var(ParseState *pstate, Oid relid, char *refname,
 		 char *attrname);
 extern ArrayRef *transformArraySubscripts(ParseState *pstate,
-										  Node *arrayBase,
-										  List *indirection,
-										  bool forceSlice,
-										  Node *assignFrom);
+						 Node *arrayBase,
+						 List *indirection,
+						 bool forceSlice,
+						 Node *assignFrom);
 extern Const *make_const(Value *value);
 
 #endif	 /* PARSE_NODE_H */
diff --git a/src/include/parser/parse_relation.h b/src/include/parser/parse_relation.h
index 5ba5db3f9d0af56cf260d9f574d77f3eed1d01c2..340afcc2f39a02a2aa389bdac68e753792c4e591 100644
--- a/src/include/parser/parse_relation.h
+++ b/src/include/parser/parse_relation.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: parse_relation.h,v 1.15 2000/02/15 03:38:29 thomas Exp $
+ * $Id: parse_relation.h,v 1.16 2000/04/12 17:16:45 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -18,18 +18,18 @@
 
 extern RangeTblEntry *refnameRangeTableEntry(ParseState *pstate, char *refname);
 extern int refnameRangeTablePosn(ParseState *pstate,
-								 char *refname,
-								 int *sublevels_up);
+					  char *refname,
+					  int *sublevels_up);
 extern RangeTblEntry *colnameRangeTableEntry(ParseState *pstate, char *colname);
 extern RangeTblEntry *addRangeTableEntry(ParseState *pstate,
-										 char *relname,
-										 Attr *ref,
-										 bool inh,
-										 bool inFromCl,
-										 bool inJoinSet);
+				   char *relname,
+				   Attr *ref,
+				   bool inh,
+				   bool inFromCl,
+				   bool inJoinSet);
 extern Attr *expandTable(ParseState *pstate, char *refname, bool getaliases);
 extern List *expandAll(ParseState *pstate, char *relname, Attr *ref,
-					   int *this_resno);
+		  int *this_resno);
 extern int	attnameAttNum(Relation rd, char *a);
 extern int	specialAttNum(char *a);
 extern bool attnameIsSet(Relation rd, char *name);
diff --git a/src/include/parser/parse_target.h b/src/include/parser/parse_target.h
index 4438073bdaaf6287ecf52ef6c25e8e480d2945f4..55c4d9f88300ad9e1393b5d3d40febfff1605fef 100644
--- a/src/include/parser/parse_target.h
+++ b/src/include/parser/parse_target.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: parse_target.h,v 1.18 2000/01/26 05:58:27 momjian Exp $
+ * $Id: parse_target.h,v 1.19 2000/04/12 17:16:45 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -18,14 +18,14 @@
 
 extern List *transformTargetList(ParseState *pstate, List *targetlist);
 extern TargetEntry *transformTargetEntry(ParseState *pstate,
-										 Node *node, Node *expr,
-										 char *colname, bool resjunk);
+					 Node *node, Node *expr,
+					 char *colname, bool resjunk);
 extern void updateTargetListEntry(ParseState *pstate, TargetEntry *tle,
-								  char *colname, int attrno,
-								  List *indirection);
+					  char *colname, int attrno,
+					  List *indirection);
 extern Node *CoerceTargetExpr(ParseState *pstate, Node *expr,
-							  Oid type_id, Oid attrtype, int32 attrtypmod);
+				 Oid type_id, Oid attrtype, int32 attrtypmod);
 extern List *checkInsertTargets(ParseState *pstate, List *cols,
-								List **attrnos);
+				   List **attrnos);
 
 #endif	 /* PARSE_TARGET_H */
diff --git a/src/include/port/alpha.h b/src/include/port/alpha.h
index 2c1c6e55c9affbd546bc8a8108ed94b76ae647d0..90c5a8af6cf98d59451eb3de05acca42898950c8 100644
--- a/src/include/port/alpha.h
+++ b/src/include/port/alpha.h
@@ -8,4 +8,3 @@ typedef msemaphore slock_t;
 #if defined(__alpha) && !defined(__alpha__)
 #define __alpha__
 #endif
-
diff --git a/src/include/port/bsd.h b/src/include/port/bsd.h
index 8406844d079e7683b8466d0a970846291d62f94e..dc019303250f30140fb3b05cdba689299c8b0fdf 100644
--- a/src/include/port/bsd.h
+++ b/src/include/port/bsd.h
@@ -38,6 +38,8 @@
 
 #if defined(__powerpc__)
 typedef unsigned int slock_t;
+
 #else
 typedef unsigned char slock_t;
+
 #endif
diff --git a/src/include/port/linux.h b/src/include/port/linux.h
index 2de8fc8e7ec16125faa7053aee3784813de898c2..d82103b879b793870d1e4828dddb38c727aaa3c1 100644
--- a/src/include/port/linux.h
+++ b/src/include/port/linux.h
@@ -9,22 +9,27 @@
 
 #if defined(__i386__)
 typedef unsigned char slock_t;
+
 #define HAS_TEST_AND_SET
 
 #elif defined(__sparc__)
 typedef unsigned char slock_t;
+
 #define HAS_TEST_AND_SET
 
 #elif defined(__powerpc__)
 typedef unsigned int slock_t;
+
 #define HAS_TEST_AND_SET
 
 #elif defined(__alpha__)
 typedef long int slock_t;
+
 #define HAS_TEST_AND_SET
 
 #elif defined(__mips__)
 typedef unsigned int slock_t;
+
 #define HAS_TEST_AND_SET
 
 #endif
diff --git a/src/include/port/netbsd.h b/src/include/port/netbsd.h
index 8406844d079e7683b8466d0a970846291d62f94e..dc019303250f30140fb3b05cdba689299c8b0fdf 100644
--- a/src/include/port/netbsd.h
+++ b/src/include/port/netbsd.h
@@ -38,6 +38,8 @@
 
 #if defined(__powerpc__)
 typedef unsigned int slock_t;
+
 #else
 typedef unsigned char slock_t;
+
 #endif
diff --git a/src/include/port/qnx4.h b/src/include/port/qnx4.h
index 820f26180da52c5bb98e708566ca74d980c14f5a..d60555f10471c767361dab38f5cb5253b36d05e1 100644
--- a/src/include/port/qnx4.h
+++ b/src/include/port/qnx4.h
@@ -1,12 +1,12 @@
-#include <sys/types.h> /* for namser.h */
-#include <arpa/nameser.h> /* for BYTE_ORDER */
-#include <process.h> /* for execv */
-#include <ioctl.h> /* for unix.h */
-#include <termios.h> /* for unix.h */
+#include <sys/types.h>			/* for namser.h */
+#include <arpa/nameser.h>		/* for BYTE_ORDER */
+#include <process.h>			/* for execv */
+#include <ioctl.h>				/* for unix.h */
+#include <termios.h>			/* for unix.h */
 #include <unix.h>
-#include <sys/select.h> /* for select */
+#include <sys/select.h>			/* for select */
 #if !defined(__GNUC__)
-#include <semaphore.h> /* for sem_t */
+#include <semaphore.h>			/* for sem_t */
 #endif
 
 #define USE_POSIX_TIME
@@ -17,23 +17,26 @@
 
 #define strncasecmp strnicmp
 
-#ifndef                 NAN
-#ifndef                 __nan_bytes
-#define __nan_bytes                             { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f }
-#endif   /* __nan_bytes */
+#ifndef					NAN
+#ifndef					__nan_bytes
+#define __nan_bytes								{ 0, 0, 0, 0, 0, 0, 0xf8, 0x7f }
+#endif	 /* __nan_bytes */
 extern unsigned char __nan[8];
-#define                            NAN     (*(const double *) __nan)
-#endif   /* NAN */
+
+#define							   NAN	   (*(const double *) __nan)
+#endif	 /* NAN */
 
 typedef u_short ushort;
 
 #if defined(__GNUC__)
 typedef unsigned char slock_t;
+
 #else
 typedef sem_t slock_t;
+
 #endif
 
-extern int isnan(double dsrc);
+extern int	isnan(double dsrc);
 
 extern double rint(double x);
 
diff --git a/src/include/postgres.h b/src/include/postgres.h
index e089db510f6bf3dbf1afecb7b716ec92a48e8ffc..0d16c553527f33533cab3d09c115b7c7de83bfb0 100644
--- a/src/include/postgres.h
+++ b/src/include/postgres.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1995, Regents of the University of California
  *
- * $Id: postgres.h,v 1.37 2000/03/17 02:36:34 tgl Exp $
+ * $Id: postgres.h,v 1.38 2000/04/12 17:16:24 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -74,8 +74,10 @@ typedef Oid RegProcedure;
  * some warnings about int->pointer conversions...
  */
 typedef int32 ((*func_ptr) ());
-#else 
+
+#else
 typedef char *((*func_ptr) ());
+
 #endif
 
 
@@ -116,27 +118,27 @@ typedef Oid oidvector[INDEX_MAX_KEYS];
 #ifdef TUPLE_TOASTER_ACTIVE
 typedef struct varattrib
 {
-	int32				va_header;			/* External/compressed storage */
-											/* flags and item size */
+	int32		va_header;		/* External/compressed storage */
+	/* flags and item size */
 	union
 	{
 		struct
 		{
-			int32		va_rawsize;			/* Plain data size */
-		}				va_compressed;		/* Compressed stored attribute */
+			int32		va_rawsize;		/* Plain data size */
+		}			va_compressed;		/* Compressed stored attribute */
 
 		struct
 		{
-			int32		va_rawsize;			/* Plain data size */
-			Oid			va_valueid;			/* Unique identifier of value */
-			Oid			va_longrelid;		/* RelID where to find chunks */
-			Oid			va_rowid;			/* Main tables row Oid */
-			int16		va_attno;			/* Main tables attno */
-		}				va_external;		/* External stored attribute */
+			int32		va_rawsize;		/* Plain data size */
+			Oid			va_valueid;		/* Unique identifier of value */
+			Oid			va_longrelid;	/* RelID where to find chunks */
+			Oid			va_rowid;		/* Main tables row Oid */
+			int16		va_attno;		/* Main tables attno */
+		}			va_external;/* External stored attribute */
 
-		char			va_data[1];			/* Plain stored attribute */
-	}					va_content;
-} varattrib;
+		char		va_data[1]; /* Plain stored attribute */
+	}			va_content;
+}			varattrib;
 
 #define VARATT_FLAG_EXTERNAL	0x8000
 #define VARATT_FLAG_COMPRESSED	0x4000
@@ -144,7 +146,7 @@ typedef struct varattrib
 #define VARATT_MASK_SIZE		0x3fff
 
 #define VARATT_SIZEP(_PTR)	(((varattrib *)(_PTR))->va_header)
-#define VARATT_SIZE(PTR)	(VARATT_SIZEP(PTR) & VARATT_MASK_SIZE) 
+#define VARATT_SIZE(PTR)	(VARATT_SIZEP(PTR) & VARATT_MASK_SIZE)
 #define VARATT_DATA(PTR)	(((varattrib *)(PTR))->va_content.va_data)
 
 #define VARATT_IS_EXTENDED(PTR)		\
@@ -160,22 +162,22 @@ typedef struct varattrib
  * so we (evil evil evil) declare it here once more.
  * ----------
  */
-extern varattrib *heap_tuple_untoast_attr(varattrib *attr);
+extern varattrib *heap_tuple_untoast_attr(varattrib * attr);
 
 #define VARATT_GETPLAIN(_ARG,_VAR) {								\
 				if (VARATTR_IS_EXTENDED(_ARG))						\
-					(_VAR) = (void *)heap_tuple_untoast_attr(_ARG);	\
+					(_VAR) = (void *)heap_tuple_untoast_attr(_ARG); \
 				else												\
 					(_VAR) = (_ARG);								\
 			}
-#define VARATT_FREE(_ARG,VAR) {										\
+#define VARATT_FREE(_ARG,VAR) do {									\
 				if ((void *)(_VAR) != (void *)(_ARG))				\
 					pfree((void *)(_VAR));							\
-			}
-#else /* TUPLE_TOASTER_ACTIVE */
+			} while (0)
+#else							/* TUPLE_TOASTER_ACTIVE */
 #define VARATT_SIZE(__PTR) VARSIZE(__PTR)
 #define VARATT_SIZEP(__PTR) VARSIZE(__PTR)
-#endif /* TUPLE_TOASTER_ACTIVE */
+#endif	 /* TUPLE_TOASTER_ACTIVE */
 
 
 /* We want NameData to have length NAMEDATALEN and int alignment,
@@ -251,7 +253,8 @@ typedef uint32 CommandId;
  * ---------------
  */
 #ifdef CYR_RECODE
-extern void		SetCharSet();
+extern void SetCharSet();
+
 #endif	 /* CYR_RECODE */
 
 #endif	 /* POSTGRES_H */
diff --git a/src/include/rewrite/rewriteManip.h b/src/include/rewrite/rewriteManip.h
index 33ea824cf2febe111a0e481f0b0311cae5e37830..af052a65510849b42cd891e634c420623604fb26 100644
--- a/src/include/rewrite/rewriteManip.h
+++ b/src/include/rewrite/rewriteManip.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: rewriteManip.h,v 1.20 2000/03/16 03:23:17 tgl Exp $
+ * $Id: rewriteManip.h,v 1.21 2000/04/12 17:16:50 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -19,9 +19,9 @@
 /* RewriteManip.c */
 extern void OffsetVarNodes(Node *node, int offset, int sublevels_up);
 extern void ChangeVarNodes(Node *node, int old_varno, int new_varno,
-						   int sublevels_up);
+			   int sublevels_up);
 extern void IncrementVarSublevelsUp(Node *node, int delta_sublevels_up,
-									int min_sublevels_up);
+						int min_sublevels_up);
 extern void AddQual(Query *parsetree, Node *qual);
 extern void AddHavingQual(Query *parsetree, Node *havingQual);
 extern void AddNotQual(Query *parsetree, Node *qual);
@@ -33,7 +33,7 @@ extern bool checkExprHasSubLink(Node *node);
 extern void FixNew(RewriteInfo *info, Query *parsetree);
 
 extern void HandleRIRAttributeRule(Query *parsetree, List *rtable,
-								   List *targetlist, int rt_index,
-								   int attr_num, int *modified, int *badsql);
+					   List *targetlist, int rt_index,
+					   int attr_num, int *modified, int *badsql);
 
 #endif	 /* REWRITEMANIP_H */
diff --git a/src/include/storage/buf_internals.h b/src/include/storage/buf_internals.h
index 0c5b6d64c0c68da248609090ab8e65bee21d3b96..2347db17bd04bfaee0f08db7ca2c6590040886b2 100644
--- a/src/include/storage/buf_internals.h
+++ b/src/include/storage/buf_internals.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: buf_internals.h,v 1.36 2000/04/09 04:43:18 tgl Exp $
+ * $Id: buf_internals.h,v 1.37 2000/04/12 17:16:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -67,9 +67,9 @@ typedef struct buftag
  */
 typedef struct bufblindid
 {
-	char		dbname[NAMEDATALEN]; /* name of db in which buf belongs */
-	char		relname[NAMEDATALEN]; /* name of reln */
-} BufferBlindId;
+	char		dbname[NAMEDATALEN];	/* name of db in which buf belongs */
+	char		relname[NAMEDATALEN];	/* name of reln */
+}			BufferBlindId;
 
 #define BAD_BUFFER_ID(bid) ((bid) < 1 || (bid) > NBuffers)
 #define INVALID_DESCRIPTOR (-3)
@@ -184,7 +184,7 @@ extern BufferDesc *LocalBufferDescriptors;
 extern int	NLocBuffer;
 
 extern BufferDesc *LocalBufferAlloc(Relation reln, BlockNumber blockNum,
-									bool *foundPtr);
+				 bool *foundPtr);
 extern int	WriteLocalBuffer(Buffer buffer, bool release);
 extern int	FlushLocalBuffer(Buffer buffer, bool release);
 extern void InitLocalBuffer(void);
diff --git a/src/include/storage/buffile.h b/src/include/storage/buffile.h
index 30ccb6e0933e21f30e8a3a97e373da99f36cff13..3f79e5bfab4e50d918a95539cac54dd400b2b2e1 100644
--- a/src/include/storage/buffile.h
+++ b/src/include/storage/buffile.h
@@ -18,7 +18,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: buffile.h,v 1.3 2000/01/26 05:58:32 momjian Exp $
+ * $Id: buffile.h,v 1.4 2000/04/12 17:16:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -41,9 +41,9 @@ extern BufFile *BufFileCreate(File file);
 extern void BufFileClose(BufFile *file);
 extern size_t BufFileRead(BufFile *file, void *ptr, size_t size);
 extern size_t BufFileWrite(BufFile *file, void *ptr, size_t size);
-extern int BufFileSeek(BufFile *file, int fileno, long offset, int whence);
+extern int	BufFileSeek(BufFile *file, int fileno, long offset, int whence);
 extern void BufFileTell(BufFile *file, int *fileno, long *offset);
-extern int BufFileSeekBlock(BufFile *file, long blknum);
+extern int	BufFileSeekBlock(BufFile *file, long blknum);
 extern long BufFileTellBlock(BufFile *file);
 
 #endif	 /* BUFFILE_H */
diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h
index e852dfd0520f3b866744b0ded27c36e942e2dfc5..da078ffbf3c69b00f3376d8baeb47dd4129a4ee6 100644
--- a/src/include/storage/bufmgr.h
+++ b/src/include/storage/bufmgr.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: bufmgr.h,v 1.36 2000/04/09 04:43:18 tgl Exp $
+ * $Id: bufmgr.h,v 1.37 2000/04/12 17:16:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -169,8 +169,8 @@ extern int	BufferPoolCheckLeak(void);
 extern void FlushBufferPool(void);
 extern BlockNumber BufferGetBlockNumber(Buffer buffer);
 extern BlockNumber RelationGetNumberOfBlocks(Relation relation);
-extern int	FlushRelationBuffers(Relation rel, BlockNumber block,
-								 bool doFlush);
+extern int FlushRelationBuffers(Relation rel, BlockNumber block,
+					 bool doFlush);
 extern void ReleaseRelationBuffers(Relation rel);
 extern void DropBuffers(Oid dbid);
 extern void PrintPinnedBufs(void);
diff --git a/src/include/storage/fd.h b/src/include/storage/fd.h
index f82fc14cae91072bbf3a1825fce269585c6e73a9..fb45e204564aaff58f9212a99a712e5c71df30af 100644
--- a/src/include/storage/fd.h
+++ b/src/include/storage/fd.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: fd.h,v 1.20 2000/04/09 04:43:18 tgl Exp $
+ * $Id: fd.h,v 1.21 2000/04/12 17:16:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -65,7 +65,7 @@ extern FILE *AllocateFile(char *name, char *mode);
 extern void FreeFile(FILE *);
 
 /* Miscellaneous support routines */
-extern bool	ReleaseDataFile(void);
+extern bool ReleaseDataFile(void);
 extern void closeAllVfds(void);
 extern void AtEOXact_Files(void);
 extern int	pg_fsync(int fd);
diff --git a/src/include/storage/itempos.h b/src/include/storage/itempos.h
index d1306068765deb280c264f27a27276ad78a9b181..83ff7a63626e28f0b1de30f43e156e5b71a451ca 100644
--- a/src/include/storage/itempos.h
+++ b/src/include/storage/itempos.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: itempos.h,v 1.10 2000/01/26 05:58:33 momjian Exp $
+ * $Id: itempos.h,v 1.11 2000/04/12 17:16:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -40,6 +40,6 @@ typedef ItemSubpositionData *ItemSubposition;
  *		unsigned		LEN;
  */
 #define PSKIP(OBJP, LEN)\
-		{ (OBJP)->op_cp += (LEN); (OBJP)->op_len -= (LEN); }
+		do { (OBJP)->op_cp += (LEN); (OBJP)->op_len -= (LEN); } while (0)
 
 #endif	 /* ITEMPOS_H */
diff --git a/src/include/storage/lock.h b/src/include/storage/lock.h
index 1c0204132ce3ad1491b0a4f40b24a68e73b3a87c..5e9fb8b42f2c5949f284f1ce486de1aec291c9e8 100644
--- a/src/include/storage/lock.h
+++ b/src/include/storage/lock.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: lock.h,v 1.36 2000/01/26 05:58:33 momjian Exp $
+ * $Id: lock.h,v 1.37 2000/04/12 17:16:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -32,7 +32,7 @@ typedef int LOCKMASK;
  * See LockShmemSize() in lock.c.
  *
  * NLOCKS_PER_XACT - The number of unique locks acquired in a transaction
- *                   (should be configurable!)
+ *					 (should be configurable!)
  * NLOCKENTS - The maximum number of lock entries in the lock table.
  * ----------------------
  */
@@ -62,19 +62,21 @@ typedef int LOCKMETHOD;
 
 typedef struct LTAG
 {
-	Oid				relId;
-	Oid				dbId;
+	Oid			relId;
+	Oid			dbId;
 	union
 	{
-		BlockNumber		blkno;
-		TransactionId	xid;
-	}				objId;
-	/* 
-	 * offnum should be part of objId.tupleId above, but would increase 
-	 * sizeof(LOCKTAG) and so moved here; currently used by userlocks only.
+		BlockNumber blkno;
+		TransactionId xid;
+	}			objId;
+
+	/*
+	 * offnum should be part of objId.tupleId above, but would increase
+	 * sizeof(LOCKTAG) and so moved here; currently used by userlocks
+	 * only.
 	 */
-	OffsetNumber	offnum;
-	uint16			lockmethod;		/* needed by userlocks */
+	OffsetNumber offnum;
+	uint16		lockmethod;		/* needed by userlocks */
 } LOCKTAG;
 
 #define TAGSIZE (sizeof(LOCKTAG))
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index 23e657c7918f56c436edbfce219d32f7fb212f19..a0f8660fbeaca0ff50cfeaca98a1656b3573df67 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: proc.h,v 1.29 2000/02/22 09:55:26 inoue Exp $
+ * $Id: proc.h,v 1.30 2000/04/12 17:16:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -82,9 +82,9 @@ typedef struct procglobal
 	int32		freeSemMap[MAX_PROC_SEMS / PROC_NSEMS_PER_SET];
 
 	/*
-	 * In each freeSemMap entry, the PROC_NSEMS_PER_SET least-significant bits
-	 * flag whether individual semaphores are in use, and the next higher bit
-	 * is set to show that the entire set is allocated.
+	 * In each freeSemMap entry, the PROC_NSEMS_PER_SET least-significant
+	 * bits flag whether individual semaphores are in use, and the next
+	 * higher bit is set to show that the entire set is allocated.
 	 */
 } PROC_HDR;
 
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index 9ea2d4b5b67151c2eac5e6057c12b8d79180c86a..fadd87edb7501c9dddd77c972bfc28922aa39dd0 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.69 2000/01/26 05:58:33 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.70 2000/04/12 17:16:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -260,7 +260,7 @@ tas(slock_t *s_lock)
 #else /* i.e. not __osf__ */
 
 #define TAS(lock) tas(lock)
-#define S_UNLOCK(lock) { __asm__("mb"); *(lock) = 0; }
+#define S_UNLOCK(lock) do { __asm__("mb"); *(lock) = 0; } while (0)
 
 static __inline__ int
 tas(volatile slock_t *lock)
@@ -300,10 +300,10 @@ __asm__("	 ldq   $0, %0			   \n\
  */
 
 #define S_UNLOCK(lock) \
-{ \
+do { \
 	volatile slock_t *lock_ = (volatile slock_t *) (lock); \
 	lock_->sema[0] = lock_->sema[1] = lock_->sema[2] = lock_->sema[3] = -1; \
-}
+} while (0)
 
 #define S_LOCK_FREE(lock)	( *(int *) (((long) (lock) + 15) & ~15) != 0)
 
diff --git a/src/include/storage/sinvaladt.h b/src/include/storage/sinvaladt.h
index 18a14895d7781ec08724c0beeebd10550796b29f..1d49eb8c620bbb92369e9c2ef332179ef29672ce 100644
--- a/src/include/storage/sinvaladt.h
+++ b/src/include/storage/sinvaladt.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: sinvaladt.h,v 1.20 2000/01/26 05:58:33 momjian Exp $
+ * $Id: sinvaladt.h,v 1.21 2000/04/12 17:16:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -20,7 +20,7 @@
 
 /*
  * The shared cache invalidation manager is responsible for transmitting
- * invalidation messages between backends.  Any message sent by any backend
+ * invalidation messages between backends.	Any message sent by any backend
  * must be delivered to all already-running backends before it can be
  * forgotten.
  *
@@ -35,7 +35,7 @@
  * In reality, the messages are stored in a circular buffer of MAXNUMMESSAGES
  * entries.  We translate MsgNum values into circular-buffer indexes by
  * computing MsgNum % MAXNUMMESSAGES (this should be fast as long as
- * MAXNUMMESSAGES is a constant and a power of 2).  As long as maxMsgNum
+ * MAXNUMMESSAGES is a constant and a power of 2).	As long as maxMsgNum
  * doesn't exceed minMsgNum by more than MAXNUMMESSAGES, we have enough space
  * in the buffer.  If the buffer does overflow, we reset it to empty and
  * force each backend to "reset", ie, discard all its invalidatable state.
@@ -85,16 +85,19 @@ typedef struct ProcState
 /* Shared cache invalidation memory segment */
 typedef struct SISeg
 {
+
 	/*
 	 * General state information
 	 */
 	int			minMsgNum;		/* oldest message still needed */
 	int			maxMsgNum;		/* next message number to be assigned */
 	int			maxBackends;	/* size of procState array */
+
 	/*
 	 * Circular buffer holding shared-inval messages
 	 */
-	SharedInvalidData	buffer[MAXNUMMESSAGES];
+	SharedInvalidData buffer[MAXNUMMESSAGES];
+
 	/*
 	 * Per-backend state info.
 	 *
@@ -106,20 +109,19 @@ typedef struct SISeg
 
 
 extern SISeg *shmInvalBuffer;	/* pointer to the shared buffer segment,
-								 * set by SISegmentAttach()
-								 */
+								 * set by SISegmentAttach() */
 
 
 /*
  * prototypes for functions in sinvaladt.c
  */
-extern int	SISegmentInit(bool createNewSegment, IPCKey key,
-						  int maxBackends);
+extern int SISegmentInit(bool createNewSegment, IPCKey key,
+			  int maxBackends);
 extern int	SIBackendInit(SISeg *segP);
 
 extern bool SIInsertDataEntry(SISeg *segP, SharedInvalidData *data);
-extern int	SIGetDataEntry(SISeg *segP, int backendId,
-						   SharedInvalidData *data);
+extern int SIGetDataEntry(SISeg *segP, int backendId,
+			   SharedInvalidData *data);
 extern void SIDelExpiredDataEntries(SISeg *segP);
 
 #endif	 /* SINVALADT_H */
diff --git a/src/include/storage/smgr.h b/src/include/storage/smgr.h
index bc0ec04bb2b5bb7fd92f934749440d9987f8b965..64702ffe702559be02ae324960f0877b3ca7236e 100644
--- a/src/include/storage/smgr.h
+++ b/src/include/storage/smgr.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: smgr.h,v 1.19 2000/04/10 23:41:45 tgl Exp $
+ * $Id: smgr.h,v 1.20 2000/04/12 17:16:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -29,20 +29,20 @@ extern int	smgrunlink(int16 which, Relation reln);
 extern int	smgrextend(int16 which, Relation reln, char *buffer);
 extern int	smgropen(int16 which, Relation reln);
 extern int	smgrclose(int16 which, Relation reln);
-extern int	smgrread(int16 which, Relation reln, BlockNumber blocknum,
-					 char *buffer);
-extern int	smgrwrite(int16 which, Relation reln, BlockNumber blocknum,
-					  char *buffer);
-extern int	smgrflush(int16 which, Relation reln, BlockNumber blocknum,
-					  char *buffer);
-extern int	smgrblindwrt(int16 which, char *dbname, char *relname,
-						 Oid dbid, Oid relid,
-						 BlockNumber blkno, char *buffer,
-						 bool dofsync);
+extern int smgrread(int16 which, Relation reln, BlockNumber blocknum,
+		 char *buffer);
+extern int smgrwrite(int16 which, Relation reln, BlockNumber blocknum,
+		  char *buffer);
+extern int smgrflush(int16 which, Relation reln, BlockNumber blocknum,
+		  char *buffer);
+extern int smgrblindwrt(int16 which, char *dbname, char *relname,
+			 Oid dbid, Oid relid,
+			 BlockNumber blkno, char *buffer,
+			 bool dofsync);
 extern int	smgrmarkdirty(int16 which, Relation reln, BlockNumber blkno);
-extern int	smgrblindmarkdirty(int16 which, char *dbname, char *relname,
-							   Oid dbid, Oid relid,
-							   BlockNumber blkno);
+extern int smgrblindmarkdirty(int16 which, char *dbname, char *relname,
+				   Oid dbid, Oid relid,
+				   BlockNumber blkno);
 extern int	smgrnblocks(int16 which, Relation reln);
 extern int	smgrtruncate(int16 which, Relation reln, int nblocks);
 extern int	smgrcommit(void);
@@ -62,12 +62,12 @@ extern int	mdclose(Relation reln);
 extern int	mdread(Relation reln, BlockNumber blocknum, char *buffer);
 extern int	mdwrite(Relation reln, BlockNumber blocknum, char *buffer);
 extern int	mdflush(Relation reln, BlockNumber blocknum, char *buffer);
-extern int	mdblindwrt(char *dbname, char *relname, Oid dbid, Oid relid,
-					   BlockNumber blkno, char *buffer,
-					   bool dofsync);
+extern int mdblindwrt(char *dbname, char *relname, Oid dbid, Oid relid,
+		   BlockNumber blkno, char *buffer,
+		   bool dofsync);
 extern int	mdmarkdirty(Relation reln, BlockNumber blkno);
-extern int	mdblindmarkdirty(char *dbname, char *relname, Oid dbid, Oid relid,
-							 BlockNumber blkno);
+extern int mdblindmarkdirty(char *dbname, char *relname, Oid dbid, Oid relid,
+				 BlockNumber blkno);
 extern int	mdnblocks(Relation reln);
 extern int	mdtruncate(Relation reln, int nblocks);
 extern int	mdcommit(void);
@@ -85,12 +85,12 @@ extern int	mmclose(Relation reln);
 extern int	mmread(Relation reln, BlockNumber blocknum, char *buffer);
 extern int	mmwrite(Relation reln, BlockNumber blocknum, char *buffer);
 extern int	mmflush(Relation reln, BlockNumber blocknum, char *buffer);
-extern int	mmblindwrt(char *dbname, char *relname, Oid dbid, Oid relid,
-					   BlockNumber blkno, char *buffer,
-					   bool dofsync);
+extern int mmblindwrt(char *dbname, char *relname, Oid dbid, Oid relid,
+		   BlockNumber blkno, char *buffer,
+		   bool dofsync);
 extern int	mmmarkdirty(Relation reln, BlockNumber blkno);
-extern int	mmblindmarkdirty(char *dbname, char *relname, Oid dbid, Oid relid,
-							 BlockNumber blkno);
+extern int mmblindmarkdirty(char *dbname, char *relname, Oid dbid, Oid relid,
+				 BlockNumber blkno);
 extern int	mmnblocks(Relation reln);
 extern int	mmtruncate(Relation reln, int nblocks);
 extern int	mmcommit(void);
diff --git a/src/include/tcop/tcopprot.h b/src/include/tcop/tcopprot.h
index 8255770068fe80e73c0ff6b78b758b2ff354fdc4..4e1de469334d5de5d4f248d9671dce0cb88b697f 100644
--- a/src/include/tcop/tcopprot.h
+++ b/src/include/tcop/tcopprot.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: tcopprot.h,v 1.26 2000/04/04 21:44:37 tgl Exp $
+ * $Id: tcopprot.h,v 1.27 2000/04/12 17:16:53 momjian Exp $
  *
  * OLD COMMENTS
  *	  This file was created so that other c files could get the two
@@ -26,18 +26,18 @@
 extern DLLIMPORT sigjmp_buf Warn_restart;
 extern bool Warn_restart_ready;
 extern bool InError;
-extern bool	ExitAfterAbort;
+extern bool ExitAfterAbort;
 
 #ifndef BOOTSTRAP_INCLUDE
 
 extern List *pg_parse_and_rewrite(char *query_string,
-								  Oid *typev, int nargs,
-								  bool aclOverride);
+					 Oid *typev, int nargs,
+					 bool aclOverride);
 extern Plan *pg_plan_query(Query *querytree);
 extern void pg_exec_query_acl_override(char *query_string);
 extern void pg_exec_query_dest(char *query_string,
-							   CommandDest dest,
-							   bool aclOverride);
+				   CommandDest dest,
+				   bool aclOverride);
 
 #endif	 /* BOOTSTRAP_INCLUDE */
 
diff --git a/src/include/utils/acl.h b/src/include/utils/acl.h
index c8b79da859c61ecff63efb9d81595fa94d8b25f3..f1f60fca4cd154add5e6f899a0a4e5206e9a5a5d 100644
--- a/src/include/utils/acl.h
+++ b/src/include/utils/acl.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: acl.h,v 1.24 2000/01/26 05:58:37 momjian Exp $
+ * $Id: acl.h,v 1.25 2000/04/12 17:16:54 momjian Exp $
  *
  * NOTES
  *	  For backward-compatability purposes we have to allow there
@@ -76,11 +76,13 @@ typedef struct AclItem
 	AclId		ai_id;
 	AclIdType	ai_idtype;
 	AclMode		ai_mode;
+
 	/*
-	 *	This is actually type 'aclitem', and we want a fixed size for
-	 *	for all platforms, so we pad this with dummies.
+	 * This is actually type 'aclitem', and we want a fixed size for for
+	 * all platforms, so we pad this with dummies.
 	 */
-	char		dummy1, dummy2;
+	char		dummy1,
+				dummy2;
 } AclItem;
 
 /* Note: if the size of AclItem changes,
diff --git a/src/include/utils/array.h b/src/include/utils/array.h
index 2c42ebb9998d7740633ccddb8de89028f5cec39d..61317d47051ec7ad22fe1c078900166c812f379c 100644
--- a/src/include/utils/array.h
+++ b/src/include/utils/array.h
@@ -11,7 +11,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: array.h,v 1.22 2000/01/26 05:58:37 momjian Exp $
+ * $Id: array.h,v 1.23 2000/04/12 17:16:54 momjian Exp $
  *
  * NOTES
  *	  XXX the data array should be LONGALIGN'd -- notice that the array
@@ -98,7 +98,7 @@ typedef struct
  *------------------------------------------------------------------------
  */
 
-#define RETURN_NULL {*isNull = true; return(0); }
+#define RETURN_NULL do {*isNull = true; return(0); } while (0)
 #define NAME_LEN	30
 #define MAX_BUFF_SIZE BLCKSZ
 
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 270187e9173f21ccc7599efb47ba48b06569b8e8..80d91aba75a20bcc7d0ad4b6a5f0b4c4a87fc3aa 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: builtins.h,v 1.109 2000/04/08 02:13:10 thomas Exp $
+ * $Id: builtins.h,v 1.110 2000/04/12 17:16:54 momjian Exp $
  *
  * NOTES
  *	  This should normally only be included by fmgr.h.
@@ -164,11 +164,12 @@ extern int	namestrcmp(Name name, const char *str);
 #define ltoa pg_ltoa
 #endif	 /* hpux */
 extern int32 pg_atoi(char *s, int size, int c);
+
 /* XXX hack.  QNX has itoa and ltoa (with different arguments) already. */
 #ifdef __QNX__
 #define itoa pg_itoa
 #define ltoa pg_ltoa
-#endif   /* QNX */
+#endif	 /* QNX */
 extern void itoa(int i, char *a);
 extern void ltoa(int32 l, char *a);
 
@@ -363,11 +364,11 @@ extern Oid	regproctooid(RegProcedure rp);
 
 /* ruleutils.c */
 extern text *pg_get_ruledef(NameData *rname);
-extern text	*pg_get_viewdef(NameData *rname);
-extern text	*pg_get_indexdef(Oid indexrelid);
+extern text *pg_get_viewdef(NameData *rname);
+extern text *pg_get_indexdef(Oid indexrelid);
 extern NameData *pg_get_userbyid(int32 uid);
 extern char *deparse_expression(Node *expr, List *rangetables,
-								bool forceprefix);
+				   bool forceprefix);
 
 /* selfuncs.c */
 extern float64 eqsel(Oid opid, Oid relid, AttrNumber attno, Datum value, int32 flag);
@@ -381,35 +382,35 @@ extern float64 scalargtjoinsel(Oid opid, Oid relid1, AttrNumber attno1, Oid reli
 extern bool convert_to_scalar(Datum value, Oid typid, double *scaleval);
 
 extern void btcostestimate(Query *root, RelOptInfo *rel,
-						   IndexOptInfo *index, List *indexQuals,
-						   Cost *indexStartupCost,
-						   Cost *indexTotalCost,
-						   Selectivity *indexSelectivity);
+			   IndexOptInfo *index, List *indexQuals,
+			   Cost *indexStartupCost,
+			   Cost *indexTotalCost,
+			   Selectivity *indexSelectivity);
 extern void rtcostestimate(Query *root, RelOptInfo *rel,
-						   IndexOptInfo *index, List *indexQuals,
-						   Cost *indexStartupCost,
-						   Cost *indexTotalCost,
-						   Selectivity *indexSelectivity);
+			   IndexOptInfo *index, List *indexQuals,
+			   Cost *indexStartupCost,
+			   Cost *indexTotalCost,
+			   Selectivity *indexSelectivity);
 extern void hashcostestimate(Query *root, RelOptInfo *rel,
-							 IndexOptInfo *index, List *indexQuals,
-							 Cost *indexStartupCost,
-							 Cost *indexTotalCost,
-							 Selectivity *indexSelectivity);
+				 IndexOptInfo *index, List *indexQuals,
+				 Cost *indexStartupCost,
+				 Cost *indexTotalCost,
+				 Selectivity *indexSelectivity);
 extern void gistcostestimate(Query *root, RelOptInfo *rel,
-							 IndexOptInfo *index, List *indexQuals,
-							 Cost *indexStartupCost,
-							 Cost *indexTotalCost,
-							 Selectivity *indexSelectivity);
+				 IndexOptInfo *index, List *indexQuals,
+				 Cost *indexStartupCost,
+				 Cost *indexTotalCost,
+				 Selectivity *indexSelectivity);
 
 /* tid.c */
 extern ItemPointer tidin(const char *str);
 extern char *tidout(ItemPointer itemPtr);
-extern bool tideq(ItemPointer,ItemPointer);
-extern bool tidne(ItemPointer,ItemPointer);
+extern bool tideq(ItemPointer, ItemPointer);
+extern bool tidne(ItemPointer, ItemPointer);
 extern text *tid_text(ItemPointer);
-extern ItemPointer text_tid(const text *); 
-extern ItemPointer currtid_byreloid(Oid relOid, ItemPointer); 
-extern ItemPointer currtid_byrelname(const text* relName, ItemPointer); 
+extern ItemPointer text_tid(const text *);
+extern ItemPointer currtid_byreloid(Oid relOid, ItemPointer);
+extern ItemPointer currtid_byrelname(const text *relName, ItemPointer);
 
 /* varchar.c */
 extern char *bpcharin(char *s, int dummy, int32 atttypmod);
@@ -490,7 +491,7 @@ extern text *rpad(text *string1, int4 len, text *string2);
 extern text *btrim(text *string, text *set);
 extern text *ltrim(text *string, text *set);
 extern text *rtrim(text *string, text *set);
-extern text	*substr(text *string, int4 m, int4 n);
+extern text *substr(text *string, int4 m, int4 n);
 extern text *translate(text *string, text *from, text *to);
 extern text *ichar(int4 arg1);
 extern text *repeat(text *string, int4 count);
@@ -503,113 +504,113 @@ extern char *inet_net_ntop(int af, const void *src, int bits, char *dst, size_t
 extern char *inet_cidr_ntop(int af, const void *src, int bits, char *dst, size_t size);
 
 /* inet_net_pton.c */
-extern int inet_net_pton(int af, const char *src, void *dst, size_t size);
+extern int	inet_net_pton(int af, const char *src, void *dst, size_t size);
 
 /* network.c */
-extern inet	   *inet_in(char *str);
-extern char	   *inet_out(inet *addr);
-extern inet	   *cidr_in(char *str);
-extern char	   *cidr_out(inet *addr);
-extern bool		network_lt(inet *a1, inet *a2);
-extern bool		network_le(inet *a1, inet *a2);
-extern bool		network_eq(inet *a1, inet *a2);
-extern bool		network_ge(inet *a1, inet *a2);
-extern bool		network_gt(inet *a1, inet *a2);
-extern bool		network_ne(inet *a1, inet *a2);
-extern bool		network_sub(inet *a1, inet *a2);
-extern bool		network_subeq(inet *a1, inet *a2);
-extern bool		network_sup(inet *a1, inet *a2);
-extern bool		network_supeq(inet *a1, inet *a2);
-extern int4		network_cmp(inet *a1, inet *a2);
-
-extern text	   *network_network(inet *addr);
-extern text	   *network_netmask(inet *addr);
-extern int4		network_masklen(inet *addr);
-extern text	   *network_broadcast(inet *addr);
-extern text	   *network_host(inet *addr);
+extern inet *inet_in(char *str);
+extern char *inet_out(inet *addr);
+extern inet *cidr_in(char *str);
+extern char *cidr_out(inet *addr);
+extern bool network_lt(inet *a1, inet *a2);
+extern bool network_le(inet *a1, inet *a2);
+extern bool network_eq(inet *a1, inet *a2);
+extern bool network_ge(inet *a1, inet *a2);
+extern bool network_gt(inet *a1, inet *a2);
+extern bool network_ne(inet *a1, inet *a2);
+extern bool network_sub(inet *a1, inet *a2);
+extern bool network_subeq(inet *a1, inet *a2);
+extern bool network_sup(inet *a1, inet *a2);
+extern bool network_supeq(inet *a1, inet *a2);
+extern int4 network_cmp(inet *a1, inet *a2);
+
+extern text *network_network(inet *addr);
+extern text *network_netmask(inet *addr);
+extern int4 network_masklen(inet *addr);
+extern text *network_broadcast(inet *addr);
+extern text *network_host(inet *addr);
 
 /* mac.c */
 extern macaddr *macaddr_in(char *str);
-extern char	   *macaddr_out(macaddr *addr);
-extern bool		macaddr_lt(macaddr *a1, macaddr *a2);
-extern bool		macaddr_le(macaddr *a1, macaddr *a2);
-extern bool		macaddr_eq(macaddr *a1, macaddr *a2);
-extern bool		macaddr_ge(macaddr *a1, macaddr *a2);
-extern bool		macaddr_gt(macaddr *a1, macaddr *a2);
-extern bool		macaddr_ne(macaddr *a1, macaddr *a2);
-extern int4		macaddr_cmp(macaddr *a1, macaddr *a2);
-extern text	   *macaddr_manuf(macaddr *addr);
+extern char *macaddr_out(macaddr *addr);
+extern bool macaddr_lt(macaddr *a1, macaddr *a2);
+extern bool macaddr_le(macaddr *a1, macaddr *a2);
+extern bool macaddr_eq(macaddr *a1, macaddr *a2);
+extern bool macaddr_ge(macaddr *a1, macaddr *a2);
+extern bool macaddr_gt(macaddr *a1, macaddr *a2);
+extern bool macaddr_ne(macaddr *a1, macaddr *a2);
+extern int4 macaddr_cmp(macaddr *a1, macaddr *a2);
+extern text *macaddr_manuf(macaddr *addr);
 
 /* numeric.c */
-extern Numeric	numeric_in(char *str, int dummy, int32 typmod);
-extern char	   *numeric_out(Numeric num);
-extern Numeric	numeric(Numeric num, int32 typmod);
-extern Numeric	numeric_abs(Numeric num);
-extern Numeric	numeric_uminus(Numeric num);
-extern Numeric	numeric_sign(Numeric num);
-extern Numeric	numeric_round(Numeric num, int32 scale);
-extern Numeric	numeric_trunc(Numeric num, int32 scale);
-extern Numeric	numeric_ceil(Numeric num);
-extern Numeric	numeric_floor(Numeric num);
-extern int32	numeric_cmp(Numeric num1, Numeric num2);
-extern bool		numeric_eq(Numeric num1, Numeric num2);
-extern bool		numeric_ne(Numeric num1, Numeric num2);
-extern bool		numeric_gt(Numeric num1, Numeric num2);
-extern bool		numeric_ge(Numeric num1, Numeric num2);
-extern bool		numeric_lt(Numeric num1, Numeric num2);
-extern bool		numeric_le(Numeric num1, Numeric num2);
-extern Numeric	numeric_add(Numeric num1, Numeric num2);
-extern Numeric	numeric_sub(Numeric num1, Numeric num2);
-extern Numeric	numeric_mul(Numeric num1, Numeric num2);
-extern Numeric	numeric_div(Numeric num1, Numeric num2);
-extern Numeric	numeric_mod(Numeric num1, Numeric num2);
-extern Numeric	numeric_inc(Numeric num);
-extern Numeric	numeric_dec(Numeric num);
-extern Numeric	numeric_smaller(Numeric num1, Numeric num2);
-extern Numeric	numeric_larger(Numeric num1, Numeric num2);
-extern Numeric	numeric_sqrt(Numeric num);
-extern Numeric	numeric_exp(Numeric num);
-extern Numeric	numeric_ln(Numeric num);
-extern Numeric	numeric_log(Numeric num1, Numeric num2);
-extern Numeric	numeric_power(Numeric num1, Numeric num2);
-extern Numeric	int4_numeric(int32 val);
-extern int32	numeric_int4(Numeric num);
-extern Numeric	int8_numeric(int64 *val);
-extern int64   *numeric_int8(Numeric num);
-extern Numeric	int2_numeric(int16 val);
-extern int16	numeric_int2(Numeric num);
-extern Numeric	float4_numeric(float32 val);
-extern float32	numeric_float4(Numeric num);
-extern Numeric	float8_numeric(float64 val);
-extern float64	numeric_float8(Numeric num);
+extern Numeric numeric_in(char *str, int dummy, int32 typmod);
+extern char *numeric_out(Numeric num);
+extern Numeric numeric(Numeric num, int32 typmod);
+extern Numeric numeric_abs(Numeric num);
+extern Numeric numeric_uminus(Numeric num);
+extern Numeric numeric_sign(Numeric num);
+extern Numeric numeric_round(Numeric num, int32 scale);
+extern Numeric numeric_trunc(Numeric num, int32 scale);
+extern Numeric numeric_ceil(Numeric num);
+extern Numeric numeric_floor(Numeric num);
+extern int32 numeric_cmp(Numeric num1, Numeric num2);
+extern bool numeric_eq(Numeric num1, Numeric num2);
+extern bool numeric_ne(Numeric num1, Numeric num2);
+extern bool numeric_gt(Numeric num1, Numeric num2);
+extern bool numeric_ge(Numeric num1, Numeric num2);
+extern bool numeric_lt(Numeric num1, Numeric num2);
+extern bool numeric_le(Numeric num1, Numeric num2);
+extern Numeric numeric_add(Numeric num1, Numeric num2);
+extern Numeric numeric_sub(Numeric num1, Numeric num2);
+extern Numeric numeric_mul(Numeric num1, Numeric num2);
+extern Numeric numeric_div(Numeric num1, Numeric num2);
+extern Numeric numeric_mod(Numeric num1, Numeric num2);
+extern Numeric numeric_inc(Numeric num);
+extern Numeric numeric_dec(Numeric num);
+extern Numeric numeric_smaller(Numeric num1, Numeric num2);
+extern Numeric numeric_larger(Numeric num1, Numeric num2);
+extern Numeric numeric_sqrt(Numeric num);
+extern Numeric numeric_exp(Numeric num);
+extern Numeric numeric_ln(Numeric num);
+extern Numeric numeric_log(Numeric num1, Numeric num2);
+extern Numeric numeric_power(Numeric num1, Numeric num2);
+extern Numeric int4_numeric(int32 val);
+extern int32 numeric_int4(Numeric num);
+extern Numeric int8_numeric(int64 *val);
+extern int64 *numeric_int8(Numeric num);
+extern Numeric int2_numeric(int16 val);
+extern int16 numeric_int2(Numeric num);
+extern Numeric float4_numeric(float32 val);
+extern float32 numeric_float4(Numeric num);
+extern Numeric float8_numeric(float64 val);
+extern float64 numeric_float8(Numeric num);
 
 /* lztext.c */
-lztext       *lztextin(char *str);
-char     *lztextout(lztext *lz);
-text     *lztext_text(lztext *lz);
-lztext       *text_lztext(text *txt);
-int32     lztextlen(lztext *lz);
-int32     lztextoctetlen(lztext *lz);
-int32     lztext_cmp(lztext *lz1, lztext *lz2);
-bool      lztext_eq(lztext *lz1, lztext *lz2);
-bool      lztext_ne(lztext *lz1, lztext *lz2);
-bool      lztext_gt(lztext *lz1, lztext *lz2);
-bool      lztext_ge(lztext *lz1, lztext *lz2);
-bool      lztext_lt(lztext *lz1, lztext *lz2);
-bool      lztext_le(lztext *lz1, lztext *lz2);
+lztext	   *lztextin(char *str);
+char	   *lztextout(lztext *lz);
+text	   *lztext_text(lztext *lz);
+lztext	   *text_lztext(text *txt);
+int32		lztextlen(lztext *lz);
+int32		lztextoctetlen(lztext *lz);
+int32		lztext_cmp(lztext *lz1, lztext *lz2);
+bool		lztext_eq(lztext *lz1, lztext *lz2);
+bool		lztext_ne(lztext *lz1, lztext *lz2);
+bool		lztext_gt(lztext *lz1, lztext *lz2);
+bool		lztext_ge(lztext *lz1, lztext *lz2);
+bool		lztext_lt(lztext *lz1, lztext *lz2);
+bool		lztext_le(lztext *lz1, lztext *lz2);
 
 /* ri_triggers.c */
-extern HeapTuple	RI_FKey_check_ins(FmgrInfo *proinfo);
-extern HeapTuple	RI_FKey_check_upd(FmgrInfo *proinfo);
-extern HeapTuple	RI_FKey_noaction_del(FmgrInfo *proinfo);
-extern HeapTuple	RI_FKey_noaction_upd(FmgrInfo *proinfo);
-extern HeapTuple	RI_FKey_cascade_del(FmgrInfo *proinfo);
-extern HeapTuple	RI_FKey_cascade_upd(FmgrInfo *proinfo);
-extern HeapTuple	RI_FKey_restrict_del(FmgrInfo *proinfo);
-extern HeapTuple	RI_FKey_restrict_upd(FmgrInfo *proinfo);
-extern HeapTuple	RI_FKey_setnull_del(FmgrInfo *proinfo);
-extern HeapTuple	RI_FKey_setnull_upd(FmgrInfo *proinfo);
-extern HeapTuple	RI_FKey_setdefault_del(FmgrInfo *proinfo);
-extern HeapTuple	RI_FKey_setdefault_upd(FmgrInfo *proinfo);
+extern HeapTuple RI_FKey_check_ins(FmgrInfo *proinfo);
+extern HeapTuple RI_FKey_check_upd(FmgrInfo *proinfo);
+extern HeapTuple RI_FKey_noaction_del(FmgrInfo *proinfo);
+extern HeapTuple RI_FKey_noaction_upd(FmgrInfo *proinfo);
+extern HeapTuple RI_FKey_cascade_del(FmgrInfo *proinfo);
+extern HeapTuple RI_FKey_cascade_upd(FmgrInfo *proinfo);
+extern HeapTuple RI_FKey_restrict_del(FmgrInfo *proinfo);
+extern HeapTuple RI_FKey_restrict_upd(FmgrInfo *proinfo);
+extern HeapTuple RI_FKey_setnull_del(FmgrInfo *proinfo);
+extern HeapTuple RI_FKey_setnull_upd(FmgrInfo *proinfo);
+extern HeapTuple RI_FKey_setdefault_del(FmgrInfo *proinfo);
+extern HeapTuple RI_FKey_setdefault_upd(FmgrInfo *proinfo);
 
 #endif	 /* BUILTINS_H */
diff --git a/src/include/utils/catcache.h b/src/include/utils/catcache.h
index 7b4b679e9dd86e711d48024ace5dee74552abb4d..cf9b1efc6f3f72b4d2ef976d074b9d390ad3f276 100644
--- a/src/include/utils/catcache.h
+++ b/src/include/utils/catcache.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: catcache.h,v 1.20 2000/02/21 03:36:59 tgl Exp $
+ * $Id: catcache.h,v 1.21 2000/04/12 17:16:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -27,7 +27,9 @@
 typedef struct catctup
 {
 	HeapTuple	ct_tup;			/* A pointer to a tuple			*/
-	/* Each tuple in the cache has two catctup items, one in the LRU list
+
+	/*
+	 * Each tuple in the cache has two catctup items, one in the LRU list
 	 * and one in the hashbucket list for its hash value.  ct_node in each
 	 * one points to the other one.
 	 */
@@ -38,7 +40,7 @@ typedef struct catctup
 #define NCCBUCK 500				/* CatCache buckets */
 #define MAXTUP 300				/* Maximum # of tuples cached per cache */
 
-typedef uint32 (* CCHashFunc) (Datum);
+typedef uint32 (*CCHashFunc) (Datum);
 
 typedef struct catcache
 {
@@ -55,11 +57,11 @@ typedef struct catcache
 	short		cc_nkeys;
 	short		cc_size;
 	short		cc_key[4];		/* AttrNumber of each key */
-	CCHashFunc	cc_hashfunc[4];	/* hash function to use for each key */
+	CCHashFunc	cc_hashfunc[4]; /* hash function to use for each key */
 	ScanKeyData cc_skey[4];
 	struct catcache *cc_next;
 	Dllist	   *cc_lrulist;		/* LRU list, most recent first */
-	Dllist	   *cc_cache[NCCBUCK + 1]; /* hash buckets */
+	Dllist	   *cc_cache[NCCBUCK + 1];	/* hash buckets */
 } CatCache;
 
 #define InvalidCatalogCacheId	(-1)
diff --git a/src/include/utils/date.h b/src/include/utils/date.h
index b474634a384041adcc27613a10206d4390bffab1..0d53f3755c1aaf90dc9072366afd30d770f3df0f 100644
--- a/src/include/utils/date.h
+++ b/src/include/utils/date.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: date.h,v 1.2 2000/03/14 23:06:50 thomas Exp $
+ * $Id: date.h,v 1.3 2000/04/12 17:16:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -20,8 +20,9 @@ typedef float8 TimeADT;
 
 typedef struct
 {
-	double		time;	/* all time units other than months and years */
-	int4		zone;	/* numeric time zone, in seconds */
+	double		time;			/* all time units other than months and
+								 * years */
+	int4		zone;			/* numeric time zone, in seconds */
 } TimeTzADT;
 
 /* date.c */
@@ -52,9 +53,9 @@ extern bool time_lt(TimeADT *time1, TimeADT *time2);
 extern bool time_le(TimeADT *time1, TimeADT *time2);
 extern bool time_gt(TimeADT *time1, TimeADT *time2);
 extern bool time_ge(TimeADT *time1, TimeADT *time2);
-extern int time_cmp(TimeADT *time1, TimeADT *time2);
+extern int	time_cmp(TimeADT *time1, TimeADT *time2);
 extern bool overlaps_time(TimeADT *time1, TimeADT *time2,
-						  TimeADT *time3, TimeADT *time4);
+			  TimeADT *time3, TimeADT *time4);
 extern TimeADT *time_larger(TimeADT *time1, TimeADT *time2);
 extern TimeADT *time_smaller(TimeADT *time1, TimeADT *time2);
 extern TimeADT *timestamp_time(Timestamp *timestamp);
@@ -68,15 +69,12 @@ extern bool timetz_lt(TimeTzADT *time1, TimeTzADT *time2);
 extern bool timetz_le(TimeTzADT *time1, TimeTzADT *time2);
 extern bool timetz_gt(TimeTzADT *time1, TimeTzADT *time2);
 extern bool timetz_ge(TimeTzADT *time1, TimeTzADT *time2);
-extern int timetz_cmp(TimeTzADT *time1, TimeTzADT *time2);
+extern int	timetz_cmp(TimeTzADT *time1, TimeTzADT *time2);
 extern bool overlaps_timetz(TimeTzADT *time1, TimeTzADT *time2,
-							TimeTzADT *time3, TimeTzADT *time4);
+				TimeTzADT *time3, TimeTzADT *time4);
 extern TimeTzADT *timetz_larger(TimeTzADT *time1, TimeTzADT *time2);
 extern TimeTzADT *timetz_smaller(TimeTzADT *time1, TimeTzADT *time2);
 extern TimeTzADT *timestamp_timetz(Timestamp *timestamp);
 extern Timestamp *datetimetz_timestamp(DateADT date, TimeTzADT *time);
 
 #endif	 /* DATE_H */
-
-
-
diff --git a/src/include/utils/datetime.h b/src/include/utils/datetime.h
index e6469d46de50dfe6817a2d4bfe7fe21cd5f676ea..0ba0504e85b0b06abee258957731ac0486da12fc 100644
--- a/src/include/utils/datetime.h
+++ b/src/include/utils/datetime.h
@@ -9,7 +9,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: datetime.h,v 1.11 2000/03/14 23:06:50 thomas Exp $
+ * $Id: datetime.h,v 1.12 2000/04/12 17:16:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -236,39 +236,39 @@ extern void j2date(int jd, int *year, int *month, int *day);
 extern int	date2j(int year, int month, int day);
 
 extern int ParseDateTime(char *timestr, char *lowstr,
-						 char **field, int *ftype,
-						 int maxfields, int *numfields);
+			  char **field, int *ftype,
+			  int maxfields, int *numfields);
 extern int DecodeDateTime(char **field, int *ftype,
-						  int nf, int *dtype,
-						  struct tm * tm, double *fsec, int *tzp);
+			   int nf, int *dtype,
+			   struct tm * tm, double *fsec, int *tzp);
 
 extern int DecodeTimeOnly(char **field, int *ftype,
-						  int nf, int *dtype,
-						  struct tm * tm, double *fsec, int *tzp);
+			   int nf, int *dtype,
+			   struct tm * tm, double *fsec, int *tzp);
 
 extern int DecodeDateDelta(char **field, int *ftype,
-						   int nf, int *dtype,
-						   struct tm * tm, double *fsec);
+				int nf, int *dtype,
+				struct tm * tm, double *fsec);
 
-extern int EncodeDateOnly(struct tm * tm, int style, char *str);
-extern int EncodeTimeOnly(struct tm * tm, double fsec, int *tzp, int style, char *str);
-extern int EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, char *str);
-extern int EncodeTimeSpan(struct tm * tm, double fsec, int style, char *str);
+extern int	EncodeDateOnly(struct tm * tm, int style, char *str);
+extern int	EncodeTimeOnly(struct tm * tm, double fsec, int *tzp, int style, char *str);
+extern int	EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, char *str);
+extern int	EncodeTimeSpan(struct tm * tm, double fsec, int style, char *str);
 
-extern int DecodeDate(char *str, int fmask, int *tmask, struct tm * tm);
+extern int	DecodeDate(char *str, int fmask, int *tmask, struct tm * tm);
 extern int DecodeNumber(int flen, char *field,
-						int fmask, int *tmask,
-						struct tm * tm, double *fsec, int *is2digits);
+			 int fmask, int *tmask,
+			 struct tm * tm, double *fsec, int *is2digits);
 extern int DecodeNumberField(int len, char *str,
-							 int fmask, int *tmask,
-							 struct tm * tm, double *fsec, int *is2digits);
-extern int DecodeSpecial(int field, char *lowtoken, int *val);
+				  int fmask, int *tmask,
+				  struct tm * tm, double *fsec, int *is2digits);
+extern int	DecodeSpecial(int field, char *lowtoken, int *val);
 extern int DecodeTime(char *str, int fmask, int *tmask,
-					  struct tm * tm, double *fsec);
-extern int DecodeTimezone(char *str, int *tzp);
-extern int DecodeUnits(int field, char *lowtoken, int *val);
+		   struct tm * tm, double *fsec);
+extern int	DecodeTimezone(char *str, int *tzp);
+extern int	DecodeUnits(int field, char *lowtoken, int *val);
 extern datetkn *datebsearch(char *key, datetkn *base, unsigned int nel);
 
-extern int j2day(int jd);
+extern int	j2day(int jd);
 
 #endif	 /* DATETIME_H */
diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h
index eb9ed14f10e10205fbc7475cc29521592fb9ef6d..190d44cfff22fde36bb952e75217ad49430d8e31 100644
--- a/src/include/utils/elog.h
+++ b/src/include/utils/elog.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: elog.h,v 1.15 2000/01/26 05:58:37 momjian Exp $
+ * $Id: elog.h,v 1.16 2000/04/12 17:16:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -17,22 +17,25 @@
 #define NOTICE	0				/* random info - no special action */
 #define ERROR	(-1)			/* user error - return to known state */
 #define FATAL	1				/* fatal error - abort process */
-#define REALLYFATAL	2			/* take down the other backends with me */
-#define	STOP	REALLYFATAL
+#define REALLYFATAL 2			/* take down the other backends with me */
+#define STOP	REALLYFATAL
 #define DEBUG	(-2)			/* debug message */
-#define	LOG		DEBUG
+#define LOG		DEBUG
 #define NOIND	(-3)			/* debug message, don't indent as far */
 
 #ifndef __GNUC__
-extern void elog(int lev, const char *fmt, ...);
+extern void elog(int lev, const char *fmt,...);
+
 #else
 /* This extension allows gcc to check the format string for consistency with
    the supplied arguments. */
-extern void elog(int lev, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
+extern void elog(int lev, const char *fmt,...) __attribute__((format(printf, 2, 3)));
+
 #endif
 
 #ifndef PG_STANDALONE
 extern int	DebugFileOpen(void);
+
 #endif
 
 #endif	 /* ELOG_H */
diff --git a/src/include/utils/formatting.h b/src/include/utils/formatting.h
index 39259afff248f3eccef3c61a24d5e220e4718d25..36cc381b36d1b4f1f45a134486b8a238e6329ed1 100644
--- a/src/include/utils/formatting.h
+++ b/src/include/utils/formatting.h
@@ -2,15 +2,15 @@
 /* -----------------------------------------------------------------------
  * formatting.h
  *
- * $Id: formatting.h,v 1.3 2000/02/16 17:26:26 thomas Exp $
+ * $Id: formatting.h,v 1.4 2000/04/12 17:16:55 momjian Exp $
  *
  *
- *   Portions Copyright (c) 1999-2000, PostgreSQL, Inc
+ *	 Portions Copyright (c) 1999-2000, PostgreSQL, Inc
  *
- *   The PostgreSQL routines for a DateTime/int/float/numeric formatting, 
- *   inspire with Oracle TO_CHAR() / TO_DATE() / TO_NUMBER() routines.  
+ *	 The PostgreSQL routines for a DateTime/int/float/numeric formatting,
+ *	 inspire with Oracle TO_CHAR() / TO_DATE() / TO_NUMBER() routines.
  *
- *   Karel Zak - Zakkr
+ *	 Karel Zak - Zakkr
  *
  * -----------------------------------------------------------------------
  */
diff --git a/src/include/utils/geo_decls.h b/src/include/utils/geo_decls.h
index 6d8869802c0420ab2b8ad84532e2aac97dce961e..305b482a64e63f1317f5ef5da879f310a6e4ea1c 100644
--- a/src/include/utils/geo_decls.h
+++ b/src/include/utils/geo_decls.h
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: geo_decls.h,v 1.26 2000/03/14 23:06:50 thomas Exp $
+ * $Id: geo_decls.h,v 1.27 2000/04/12 17:16:55 momjian Exp $
  *
  * NOTE
  *	  These routines do *not* use the float types from adt/.
@@ -361,16 +361,16 @@ extern double circle_dt(CIRCLE *circle1, CIRCLE *circle2);
 
 /* geo_selfuncs.c */
 extern float64 areasel(Oid opid, Oid relid, AttrNumber attno,
-					   Datum value, int32 flag);
+		Datum value, int32 flag);
 extern float64 areajoinsel(Oid opid, Oid relid1, AttrNumber attno1,
-						   Oid relid2, AttrNumber attno2);
+			Oid relid2, AttrNumber attno2);
 extern float64 positionsel(Oid opid, Oid relid, AttrNumber attno,
-						   Datum value, int32 flag);
+			Datum value, int32 flag);
 extern float64 positionjoinsel(Oid opid, Oid relid1, AttrNumber attno1,
-							   Oid relid2, AttrNumber attno2);
+				Oid relid2, AttrNumber attno2);
 extern float64 contsel(Oid opid, Oid relid, AttrNumber attno,
-					   Datum value, int32 flag);
+		Datum value, int32 flag);
 extern float64 contjoinsel(Oid opid, Oid relid1, AttrNumber attno1,
-						   Oid relid2, AttrNumber attno2);
+			Oid relid2, AttrNumber attno2);
 
 #endif	 /* GEO_DECLS_H */
diff --git a/src/include/utils/hsearch.h b/src/include/utils/hsearch.h
index aa5f4603012fbbc871ab87a41df3ec60a3c1d52a..ef243da145fc370db8851177aa9446103825c780 100644
--- a/src/include/utils/hsearch.h
+++ b/src/include/utils/hsearch.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: hsearch.h,v 1.14 2000/02/26 05:25:53 tgl Exp $
+ * $Id: hsearch.h,v 1.15 2000/04/12 17:16:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -27,13 +27,13 @@
  * In a hash table allocated in shared memory, the directory cannot be
  * expanded because it must stay at a fixed address.  The directory size
  * should be selected using hash_select_dirsize (and you'd better have
- * a good idea of the maximum number of entries!).  For non-shared hash
+ * a good idea of the maximum number of entries!).	For non-shared hash
  * tables, the initial directory size can be left at the default.
  */
 #define DEF_SEGSIZE			   256
-#define DEF_SEGSIZE_SHIFT	   8		/* must be log2(DEF_SEGSIZE) */
+#define DEF_SEGSIZE_SHIFT	   8/* must be log2(DEF_SEGSIZE) */
 #define DEF_DIRSIZE			   256
-#define DEF_FFACTOR			   1		/* default fill factor */
+#define DEF_FFACTOR			   1/* default fill factor */
 
 #define PRIME1				   37		/* for the hash function */
 #define PRIME2				   1048583
@@ -68,8 +68,9 @@ typedef struct hashhdr
 	long		nsegs;			/* Number of allocated segments */
 	long		keysize;		/* hash key length in bytes */
 	long		datasize;		/* elem data length in bytes */
-	long		max_dsize;		/* 'dsize' limit if directory is fixed size */
-	BUCKET_INDEX freeBucketIndex;	/* index of first free bucket */
+	long		max_dsize;		/* 'dsize' limit if directory is fixed
+								 * size */
+	BUCKET_INDEX freeBucketIndex;		/* index of first free bucket */
 #ifdef HASH_STATISTICS
 	long		accesses;
 	long		collisions;
diff --git a/src/include/utils/int8.h b/src/include/utils/int8.h
index 02053d6c393a6da453dcba0c015d522819f6abed..dab1e0addd1c60cc83c26e5dd613c6c23cfeb868 100644
--- a/src/include/utils/int8.h
+++ b/src/include/utils/int8.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: int8.h,v 1.19 2000/03/14 23:06:50 thomas Exp $
+ * $Id: int8.h,v 1.20 2000/04/12 17:16:55 momjian Exp $
  *
  * NOTES
  * These data types are supported on all 64-bit architectures, and may
@@ -97,6 +97,7 @@ extern int32 int84(int64 *val);
 
 #ifdef NOT_USED
 extern int16 int82(int64 *val);
+
 #endif
 
 extern float64 i8tod(int64 *val);
diff --git a/src/include/utils/logtape.h b/src/include/utils/logtape.h
index 24bf0bca59b485adf5196081181fa4762af91b07..1ce02fc64b4405656e30435881d799d507f2915e 100644
--- a/src/include/utils/logtape.h
+++ b/src/include/utils/logtape.h
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: logtape.h,v 1.2 2000/01/26 05:58:38 momjian Exp $
+ * $Id: logtape.h,v 1.3 2000/04/12 17:16:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -27,16 +27,16 @@ typedef struct LogicalTapeSet LogicalTapeSet;
 extern LogicalTapeSet *LogicalTapeSetCreate(int ntapes);
 extern void LogicalTapeSetClose(LogicalTapeSet *lts);
 extern size_t LogicalTapeRead(LogicalTapeSet *lts, int tapenum,
-							  void *ptr, size_t size);
+				void *ptr, size_t size);
 extern void LogicalTapeWrite(LogicalTapeSet *lts, int tapenum,
-							 void *ptr, size_t size);
+				 void *ptr, size_t size);
 extern void LogicalTapeRewind(LogicalTapeSet *lts, int tapenum, bool forWrite);
 extern void LogicalTapeFreeze(LogicalTapeSet *lts, int tapenum);
 extern bool LogicalTapeBackspace(LogicalTapeSet *lts, int tapenum,
-								 size_t size);
+					 size_t size);
 extern bool LogicalTapeSeek(LogicalTapeSet *lts, int tapenum,
-							long blocknum, int offset);
+				long blocknum, int offset);
 extern void LogicalTapeTell(LogicalTapeSet *lts, int tapenum,
-							long *blocknum, int *offset);
+				long *blocknum, int *offset);
 
 #endif	 /* LOGTAPE_H */
diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h
index df510f60bfbf3bb95c220fb4effaf0d17c8f5a3c..b6c02a11929749f6fbd4fc8abd58a334c6a890b9 100644
--- a/src/include/utils/lsyscache.h
+++ b/src/include/utils/lsyscache.h
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: lsyscache.h,v 1.22 2000/01/26 05:58:38 momjian Exp $
+ * $Id: lsyscache.h,v 1.23 2000/04/12 17:16:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -22,7 +22,7 @@ extern Oid	get_atttype(Oid relid, AttrNumber attnum);
 extern bool get_attisset(Oid relid, char *attname);
 extern int32 get_atttypmod(Oid relid, AttrNumber attnum);
 extern double get_attdisbursion(Oid relid, AttrNumber attnum,
-								double min_estimate);
+				  double min_estimate);
 extern RegProcedure get_opcode(Oid opid);
 extern char *get_opname(Oid opid);
 extern bool op_mergejoinable(Oid opid, Oid ltype, Oid rtype,
diff --git a/src/include/utils/lztext.h b/src/include/utils/lztext.h
index a10ab34cd1e14f6087bc1f48d30e212009daffeb..8936ffb133d04e94432ee95f9e1213ab6444a693 100644
--- a/src/include/utils/lztext.h
+++ b/src/include/utils/lztext.h
@@ -1,7 +1,7 @@
 /* ----------
  * lztext.h
  *
- * $Header: /cvsroot/pgsql/src/include/utils/Attic/lztext.h,v 1.2 1999/12/28 13:40:53 wieck Exp $
+ * $Header: /cvsroot/pgsql/src/include/utils/Attic/lztext.h,v 1.3 2000/04/12 17:16:55 momjian Exp $
  *
  *	Definitions for the lztext compressed data type
  * ----------
@@ -17,6 +17,6 @@
  * The internal storage format of an LZ compressed text field
  * ----------
  */
-typedef PGLZ_Header		lztext;
+typedef PGLZ_Header lztext;
 
-#endif /* _LZTEXT_H_ */
+#endif	 /* _LZTEXT_H_ */
diff --git a/src/include/utils/memutils.h b/src/include/utils/memutils.h
index e86c4be0ae929b93a3fb7ae63a30a8970b2640fb..a42bce402cdfe83e517533550c9b104c390d2edc 100644
--- a/src/include/utils/memutils.h
+++ b/src/include/utils/memutils.h
@@ -13,7 +13,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: memutils.h,v 1.33 2000/01/26 05:58:38 momjian Exp $
+ * $Id: memutils.h,v 1.34 2000/04/12 17:16:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -31,7 +31,7 @@
  * ----------------
  */
 
-#define TYPEALIGN(ALIGNVAL,LEN)	(((long)(LEN) + (ALIGNVAL-1)) & ~(ALIGNVAL-1))
+#define TYPEALIGN(ALIGNVAL,LEN) (((long)(LEN) + (ALIGNVAL-1)) & ~(ALIGNVAL-1))
 
 #define SHORTALIGN(LEN)			TYPEALIGN(ALIGNOF_SHORT, (LEN))
 #define INTALIGN(LEN)			TYPEALIGN(ALIGNOF_INT, (LEN))
@@ -165,14 +165,14 @@ typedef struct AllocSetData
 {
 	AllocBlock	blocks;			/* head of list of blocks in this set */
 #define ALLOCSET_NUM_FREELISTS	8
-	AllocChunk	freelist[ALLOCSET_NUM_FREELISTS]; /* free chunk lists */
+	AllocChunk	freelist[ALLOCSET_NUM_FREELISTS];		/* free chunk lists */
 	/* Note: this will change in the future to support other modes */
 } AllocSetData;
 
 /*
  * AllocBlock
  *		An AllocBlock is the unit of memory that is obtained by aset.c
- *		from malloc().  It contains one or more AllocChunks, which are
+ *		from malloc().	It contains one or more AllocChunks, which are
  *		the units requested by palloc() and freed by pfree().  AllocChunks
  *		cannot be returned to malloc() individually, instead they are put
  *		on freelists by pfree() and re-used by the next palloc() that has
diff --git a/src/include/utils/nabstime.h b/src/include/utils/nabstime.h
index a822e58a66e1ddad7ccd7458188730987b26184a..97f5119fd743e5dcb0395092df7a87a7d81725b3 100644
--- a/src/include/utils/nabstime.h
+++ b/src/include/utils/nabstime.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: nabstime.h,v 1.24 2000/03/27 17:07:48 thomas Exp $
+ * $Id: nabstime.h,v 1.25 2000/04/12 17:16:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -25,7 +25,7 @@
  *
  * ----------------------------------------------------------------
  */
-/* 
+/*
  * Although time_t generally is a long int on 64 bit systems, these two
  * types must be 4 bytes, because that's what the system assumes. They
  * should be yanked (long) before 2038 and be replaced by timestamp and
@@ -52,10 +52,10 @@ typedef TimeIntervalData *TimeInterval;
  *	so redefine them explicitly using these bit patterns. - tgl 97/02/24
  */
 #define EPOCH_ABSTIME	((AbsoluteTime) 0)
-#define INVALID_ABSTIME ((AbsoluteTime) 0x7FFFFFFE)	 /* 2147483647 (2^31 - 1) */
-#define CURRENT_ABSTIME ((AbsoluteTime) 0x7FFFFFFD)	 /* 2147483646 (2^31 - 2) */
-#define NOEND_ABSTIME	((AbsoluteTime) 0x7FFFFFFC)	 /* 2147483645 (2^31 - 3) */
-#define BIG_ABSTIME		((AbsoluteTime) 0x7FFFFFFB)	 /* 2147483644 (2^31 - 4) */
+#define INVALID_ABSTIME ((AbsoluteTime) 0x7FFFFFFE)		/* 2147483647 (2^31 - 1) */
+#define CURRENT_ABSTIME ((AbsoluteTime) 0x7FFFFFFD)		/* 2147483646 (2^31 - 2) */
+#define NOEND_ABSTIME	((AbsoluteTime) 0x7FFFFFFC)		/* 2147483645 (2^31 - 3) */
+#define BIG_ABSTIME		((AbsoluteTime) 0x7FFFFFFB)		/* 2147483644 (2^31 - 4) */
 
 #if defined(_AIX)
 /*
@@ -66,10 +66,10 @@ typedef TimeIntervalData *TimeInterval;
  */
 #define NOSTART_ABSTIME		 ((AbsoluteTime) INT_MIN)
 #else
-#define NOSTART_ABSTIME ((AbsoluteTime) 0x80000001)	 /* -2147483647 (- 2^31) */
+#define NOSTART_ABSTIME ((AbsoluteTime) 0x80000001)		/* -2147483647 (- 2^31) */
 #endif	 /* _AIX */
 
-#define INVALID_RELTIME ((RelativeTime) 0x7FFFFFFE)	 /* 2147483647 (2^31 - 1) */
+#define INVALID_RELTIME ((RelativeTime) 0x7FFFFFFE)		/* 2147483647 (2^31 - 1) */
 
 #define AbsoluteTimeIsValid(time) \
 	((bool) ((time) != INVALID_ABSTIME))
diff --git a/src/include/utils/numeric.h b/src/include/utils/numeric.h
index cd8ff13e2895d0120c2fdeb4140be2c6a623be53..1b3864dc0ddcf70e42096805e0a0641499efd2ed 100644
--- a/src/include/utils/numeric.h
+++ b/src/include/utils/numeric.h
@@ -5,7 +5,7 @@
  *
  *	1998 Jan Wieck
  *
- * $Header: /cvsroot/pgsql/src/include/utils/numeric.h,v 1.8 2000/01/15 23:42:48 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/include/utils/numeric.h,v 1.9 2000/04/12 17:16:55 momjian Exp $
  *
  * ----------
  */
@@ -41,7 +41,7 @@
 #define NUMERIC_POS			0x0000
 #define NUMERIC_NEG			0x4000
 #define NUMERIC_NAN			0xC000
-#define NUMERIC_DSCALE_MASK	0x3FFF
+#define NUMERIC_DSCALE_MASK 0x3FFF
 #define NUMERIC_SIGN(n)		((n)->n_sign_dscale & NUMERIC_SIGN_MASK)
 #define NUMERIC_DSCALE(n)	((n)->n_sign_dscale & NUMERIC_DSCALE_MASK)
 #define NUMERIC_IS_NAN(n)	(NUMERIC_SIGN(n) != NUMERIC_POS &&			\
diff --git a/src/include/utils/pg_locale.h b/src/include/utils/pg_locale.h
index 21e9a6d0f5a23b8e23ad19bbd7bdaeed7d911759..b3a178d6a79d5fc796e3095b2434da56687c99b7 100644
--- a/src/include/utils/pg_locale.h
+++ b/src/include/utils/pg_locale.h
@@ -2,50 +2,51 @@
 /* -----------------------------------------------------------------------
  * pg_locale.h
  *
- * $Header: /cvsroot/pgsql/src/include/utils/pg_locale.h,v 1.3 2000/03/18 18:57:15 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/include/utils/pg_locale.h,v 1.4 2000/04/12 17:16:55 momjian Exp $
  *
  *
- *   Portions Copyright (c) 1999-2000, PostgreSQL, Inc
+ *	 Portions Copyright (c) 1999-2000, PostgreSQL, Inc
  *
- *   The PostgreSQL locale utils.
+ *	 The PostgreSQL locale utils.
  *
  *	Karel Zak - Zakkr
  *
  * -----------------------------------------------------------------------
  */
-  
- #ifndef _PG_LOCALE_
- #define _PG_LOCALE_
- 
- #ifdef USE_LOCALE
- 
+
+#ifndef _PG_LOCALE_
+#define _PG_LOCALE_
+
+#ifdef USE_LOCALE
+
 /*------
  * POSIX locale categories and environment variable LANG
  *------
  */
-typedef struct PG_LocaleCategories {
-	char	*lang,
-		*lc_ctype,
-		*lc_numeric,
-		*lc_time,
-		*lc_collate,
-		*lc_monetary,
-		*lc_messages;
-} PG_LocaleCategories;
+typedef struct PG_LocaleCategories
+{
+	char	   *lang,
+			   *lc_ctype,
+			   *lc_numeric,
+			   *lc_time,
+			   *lc_collate,
+			   *lc_monetary,
+			   *lc_messages;
+}			PG_LocaleCategories;
 
 
-extern PG_LocaleCategories *PGLC_current( PG_LocaleCategories *lc );
-extern PG_LocaleCategories *PGLC_setlocale( PG_LocaleCategories *lc );
+extern PG_LocaleCategories *PGLC_current(PG_LocaleCategories * lc);
+extern PG_LocaleCategories *PGLC_setlocale(PG_LocaleCategories * lc);
 
 /*------
  * Return the POSIX lconv struct (contains number/money formatting information)
- * with locale information for *all* categories. Returned lconv is *independent* 
+ * with locale information for *all* categories. Returned lconv is *independent*
  * on current locale catogories setting - in contrast to standard localeconv().
  *------
  */
 extern struct lconv *PGLC_localeconv(void);
 
- 
-#endif /* USE_LOCALE */
- 
-#endif /* _PG_LOCALE_ */  
+
+#endif	 /* USE_LOCALE */
+
+#endif	 /* _PG_LOCALE_ */
diff --git a/src/include/utils/pg_lzcompress.h b/src/include/utils/pg_lzcompress.h
index db9618fd40e4ed3ae4ecd0639cc9af07bf4d38af..fd1e62a8bed3e3fa48f4e7749cd768966835f1aa 100644
--- a/src/include/utils/pg_lzcompress.h
+++ b/src/include/utils/pg_lzcompress.h
@@ -1,7 +1,7 @@
 /* ----------
  * pg_lzcompress.h -
  *
- * $Header: /cvsroot/pgsql/src/include/utils/pg_lzcompress.h,v 1.4 2000/01/05 18:23:52 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/include/utils/pg_lzcompress.h,v 1.5 2000/04/12 17:16:55 momjian Exp $
  *
  *	Definitions for the builtin LZ compressor
  * ----------
@@ -14,14 +14,15 @@
 /* ----------
  * PGLZ_Header -
  *
- *      The information at the top of the compressed data.
+ *		The information at the top of the compressed data.
  *		The varsize must be kept the same data type as the value
  *		in front of all variable size data types in PostgreSQL.
  * ----------
  */
-typedef struct PGLZ_Header {
-    int32                       varsize;
-    int32                       rawsize;
+typedef struct PGLZ_Header
+{
+	int32		varsize;
+	int32		rawsize;
 } PGLZ_Header;
 
 
@@ -54,9 +55,9 @@ typedef struct PGLZ_Header {
  *		uncompressed data.
  * ----------
  */
-#define PGLZ_IS_COMPRESSED(_lzdata)		(_lzdata->varsize != 				\
-										 _lzdata->rawsize + 				\
-										 				sizeof(PGLZ_Header))
+#define PGLZ_IS_COMPRESSED(_lzdata)		(_lzdata->varsize !=				\
+										 _lzdata->rawsize +					\
+														sizeof(PGLZ_Header))
 
 /* ----------
  * PGLZ_RAW_DATA -
@@ -65,7 +66,7 @@ typedef struct PGLZ_Header {
  *		data. Useful if PGLZ_IS_COMPRESSED returns false.
  * ----------
  */
-#define PGLZ_RAW_DATA(_lzdata)			(((char *)(_lzdata)) + 				\
+#define PGLZ_RAW_DATA(_lzdata)			(((char *)(_lzdata)) +				\
 														sizeof(PGLZ_Header))
 
 /* ----------
@@ -89,7 +90,7 @@ typedef struct PGLZ_Header {
  *							lookup. When looking up the history to find a
  *							match that could be expressed as a tag, the
  *							algorithm does not allways walk back entirely.
- *							A good match fast is usually better than the 
+ *							A good match fast is usually better than the
  *							best possible one very late. For each iteration
  *							in the lookup, this value is lowered so the
  *							longer the lookup takes, the smaller matches
@@ -101,7 +102,8 @@ typedef struct PGLZ_Header {
  *							latest history entry at all).
  * ----------
  */
-typedef struct PGLZ_Strategy {
+typedef struct PGLZ_Strategy
+{
 	int32		min_input_size;
 	int32		force_input_size;
 	int32		min_comp_rate;
@@ -117,16 +119,17 @@ typedef struct PGLZ_Strategy {
  *		using pglz_decomp_getchar() macro.
  * ----------
  */
-typedef struct PGLZ_DecompState {
-	unsigned char	   *temp_buf;
-	unsigned char	   *cp_in;
-	unsigned char	   *cp_end;
-	unsigned char	   *cp_out;
-	unsigned char	   *cp_copy;
-	int					(*next_char)(struct PGLZ_DecompState *dstate);
-	int					tocopy;
-	int					ctrl_count;
-	unsigned char		ctrl;
+typedef struct PGLZ_DecompState
+{
+	unsigned char *temp_buf;
+	unsigned char *cp_in;
+	unsigned char *cp_end;
+	unsigned char *cp_out;
+	unsigned char *cp_copy;
+	int			(*next_char) (struct PGLZ_DecompState *dstate);
+	int			tocopy;
+	int			ctrl_count;
+	unsigned char ctrl;
 } PGLZ_DecompState;
 
 
@@ -154,9 +157,9 @@ typedef struct PGLZ_DecompState {
  *									for generic interfacing.
  * ----------
  */
-extern PGLZ_Strategy	*PGLZ_strategy_default;
-extern PGLZ_Strategy	*PGLZ_strategy_allways;
-extern PGLZ_Strategy	*PGLZ_strategy_never;
+extern PGLZ_Strategy *PGLZ_strategy_default;
+extern PGLZ_Strategy *PGLZ_strategy_allways;
+extern PGLZ_Strategy *PGLZ_strategy_never;
 
 
 /* ----------
@@ -177,10 +180,10 @@ extern PGLZ_Strategy	*PGLZ_strategy_never;
  *		Initialize a decomp state from a compressed input.
  * ----------
  */
-#define pglz_decomp_init(_ds,_lz) {											\
-		(_ds)->cp_in		= ((unsigned char *)(_lz)) 						\
+#define pglz_decomp_init(_ds,_lz) do {											\
+		(_ds)->cp_in		= ((unsigned char *)(_lz))						\
 											+ sizeof(PGLZ_Header);			\
-		(_ds)->cp_end		= (_ds)->cp_in + (_lz)->varsize 				\
+		(_ds)->cp_end		= (_ds)->cp_in + (_lz)->varsize					\
 											- sizeof(PGLZ_Header);			\
 		if (PGLZ_IS_COMPRESSED((_lz))) {									\
 			(_ds)->temp_buf		= (unsigned char *)							\
@@ -193,7 +196,7 @@ extern PGLZ_Strategy	*PGLZ_strategy_never;
 			(_ds)->temp_buf		= NULL;										\
 			(_ds)->next_char	= pglz_get_next_decomp_char_from_plain;		\
 		}																	\
-	}
+	} while (0)
 
 
 /* ----------
@@ -202,19 +205,19 @@ extern PGLZ_Strategy	*PGLZ_strategy_never;
  *		Deallocate resources after decompression.
  * ----------
  */
-#define pglz_decomp_end(_ds) {												\
+#define pglz_decomp_end(_ds) do {											\
 		if ((_ds)->temp_buf != NULL)										\
 			pfree((void *)((_ds)->temp_buf));								\
-	}
+	} while (0)
 
 
 /* ----------
  * Global function declarations
  * ----------
  */
-int	pglz_compress (char *source, int32 slen, PGLZ_Header *dest,
-									 PGLZ_Strategy *strategy);
-int pglz_decompress (PGLZ_Header *source, char *dest);
+int pglz_compress(char *source, int32 slen, PGLZ_Header *dest,
+			  PGLZ_Strategy *strategy);
+int			pglz_decompress(PGLZ_Header *source, char *dest);
 
 
 /* ----------
@@ -222,8 +225,7 @@ int pglz_decompress (PGLZ_Header *source, char *dest);
  * Internal use only.
  * ----------
  */
-extern int pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate);
-extern int pglz_get_next_decomp_char_from_plain(PGLZ_DecompState *dstate);
-
-#endif /* _PG_LZCOMPRESS_H_ */
+extern int	pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate);
+extern int	pglz_get_next_decomp_char_from_plain(PGLZ_DecompState *dstate);
 
+#endif	 /* _PG_LZCOMPRESS_H_ */
diff --git a/src/include/utils/portal.h b/src/include/utils/portal.h
index d24fd16f1a59dfe28b5f5cde7d26686fc52b2315..406fcc6af2353747b40e937d0261b5add799a183 100644
--- a/src/include/utils/portal.h
+++ b/src/include/utils/portal.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: portal.h,v 1.22 2000/02/18 09:30:16 inoue Exp $
+ * $Id: portal.h,v 1.23 2000/04/12 17:16:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -61,7 +61,7 @@ struct PortalD
  * Special portals (well, their names anyway)
  */
 #define VACPNAME		"<vacuum>"
-#define TRUNCPNAME              "<truncate>"
+#define TRUNCPNAME				"<truncate>"
 
 extern bool PortalNameIsSpecial(char *pname);
 extern void AtEOXact_portals(void);
diff --git a/src/include/utils/ps_status.h b/src/include/utils/ps_status.h
index 0058e56ae3f375b1ac8b3f6f2cdb536861355a6b..b74816586b46bc2006d56cab82b198d1e6f5109b 100644
--- a/src/include/utils/ps_status.h
+++ b/src/include/utils/ps_status.h
@@ -21,7 +21,7 @@ extern char *ps_status_buffer;
 char *ps_status_buffer = NULL
 
 #define PS_INIT_STATUS(argc, argv, execname, username, hostname, dbname) \
-	{ \
+	do { \
 		int i; \
 		for (i = 0; i < (argc); i++) { \
 			memset((argv)[i], 0, strlen((argv)[i])); \
@@ -30,10 +30,10 @@ char *ps_status_buffer = NULL
 		sprintf(ps_status_buffer, "%s %s %s %s ", execname, username, hostname, dbname); \
 		ps_status_buffer += strlen(ps_status_buffer); \
 		ps_status_buffer[0] = '\0'; \
-	}
+	} while (0)
 
 #define PS_CLEAR_STATUS() \
-	{ if (ps_status_buffer) memset(ps_status_buffer, 0, strlen(ps_status_buffer)); }
+	do { if (ps_status_buffer) memset(ps_status_buffer, 0, strlen(ps_status_buffer)); }
 
 #define PS_SET_STATUS(status) \
 	{ \
@@ -42,7 +42,7 @@ char *ps_status_buffer = NULL
 			PS_CLEAR_STATUS(); \
 			strcpy(ps_status_buffer, status); \
 		} \
-	}
+	} while (0)
 
 #define PS_STATUS (ps_status_buffer ? ps_status_buffer : "")
 
@@ -53,7 +53,7 @@ extern char Ps_status_buffer[];
 #undef PS_DEFINE_BUFFER
 
 #define PS_INIT_STATUS(argc, argv, execname, username, hostname, dbname) \
-	{ \
+	do { \
 		int i; \
 		Assert(argc >= 5); \
 		argv[0] = execname; \
@@ -63,13 +63,13 @@ extern char Ps_status_buffer[];
 		argv[4] = Ps_status_buffer; \
 		for (i = 5; i < argc; i++) \
 			argv[i] = "";  /* blank them */ \
-	}
+	} while (0)
 
 #define PS_CLEAR_STATUS() \
-	{ Ps_status_buffer[0] = '\0'; }
+	do { Ps_status_buffer[0] = '\0'; } while (0)
 
 #define PS_SET_STATUS(status) \
-	{ strcpy(Ps_status_buffer, (status)); }
+	do { strcpy(Ps_status_buffer, (status)); } while (0)
 
 #define PS_STATUS (Ps_status_buffer)
 #endif
@@ -78,7 +78,7 @@ extern char Ps_status_buffer[];
 #undef PS_DEFINE_BUFFER
 #define PS_INIT_STATUS(argc, argv, execname, username, hostname, dbname)
 #define PS_CLEAR_STATUS()
-#define PS_SET_STATUS(status) { if ((status)); }
+#define PS_SET_STATUS(status) do { if ((status)); } while (0)
 #define PS_STATUS ""
 #endif	 /* !linux */
 
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index dcc9cffcbf475cfa83971eaf797d39696e0ba001..1bd2f10376ea0a9ba53691876bb3747c755a6a38 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: rel.h,v 1.35 2000/02/27 07:31:00 tgl Exp $
+ * $Id: rel.h,v 1.36 2000/04/12 17:16:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -95,7 +95,8 @@ typedef struct RelationData
 	Form_pg_am	rd_am;			/* AM tuple */
 	Form_pg_class rd_rel;		/* RELATION tuple */
 	Oid			rd_id;			/* relation's object id */
-	LockInfoData rd_lockInfo;	/* lock manager's info for locking relation */
+	LockInfoData rd_lockInfo;	/* lock manager's info for locking
+								 * relation */
 	TupleDesc	rd_att;			/* tuple descriptor */
 	RuleLock   *rd_rules;		/* rewrite rules */
 	IndexStrategy rd_istrat;
@@ -225,7 +226,7 @@ typedef Relation *RelationPtr;
 
 
 extern void RelationSetIndexSupport(Relation relation,
-									IndexStrategy strategy,
-									RegProcedure *support);
+						IndexStrategy strategy,
+						RegProcedure *support);
 
 #endif	 /* REL_H */
diff --git a/src/include/utils/syscache.h b/src/include/utils/syscache.h
index 01dea2a9c2cf2d16ea19146d694b4061c044a47b..272b177c7817455d4ee1bd4f1bd922b3d945dd8a 100644
--- a/src/include/utils/syscache.h
+++ b/src/include/utils/syscache.h
@@ -9,7 +9,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: syscache.h,v 1.24 2000/01/26 05:58:38 momjian Exp $
+ * $Id: syscache.h,v 1.25 2000/04/12 17:16:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -83,7 +83,7 @@ extern HeapTuple SearchSysCacheTupleCopy(int cacheId,
 extern HeapTuple SearchSysCacheTuple(int cacheId,
 					Datum key1, Datum key2, Datum key3, Datum key4);
 extern Datum SysCacheGetAttr(int cacheId, HeapTuple tup,
-							 AttrNumber attributeNumber,
-							 bool *isnull);
+				AttrNumber attributeNumber,
+				bool *isnull);
 
 #endif	 /* SYSCACHE_H */
diff --git a/src/include/utils/temprel.h b/src/include/utils/temprel.h
index ddcca0bc0de83d1180a9edf86e5dbb016741ceef..7a1dfa9e1bfb5ab33f0276e7a9569ed1f6433702 100644
--- a/src/include/utils/temprel.h
+++ b/src/include/utils/temprel.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: temprel.h,v 1.8 2000/01/26 05:58:38 momjian Exp $
+ * $Id: temprel.h,v 1.9 2000/04/12 17:16:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -20,7 +20,7 @@ void		create_temp_relation(const char *relname, HeapTuple pg_class_tuple);
 void		remove_all_temp_relations(void);
 void		invalidate_temp_relations(void);
 void		remove_temp_relation(Oid relid);
-char 	   *get_temp_rel_by_username(const char *user_relname);
-char 	   *get_temp_rel_by_physicalname(const char *relname);
+char	   *get_temp_rel_by_username(const char *user_relname);
+char	   *get_temp_rel_by_physicalname(const char *relname);
 
 #endif	 /* TEMPREL_H */
diff --git a/src/include/utils/timestamp.h b/src/include/utils/timestamp.h
index cea772afb775aeb3c458a6e87b5940230085af50..bce73ae0801ed1955e417891d0e3280ac9dcad69 100644
--- a/src/include/utils/timestamp.h
+++ b/src/include/utils/timestamp.h
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: timestamp.h,v 1.3 2000/04/07 13:40:12 thomas Exp $
+ * $Id: timestamp.h,v 1.4 2000/04/12 17:16:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -31,8 +31,10 @@ typedef double Timestamp;
 
 typedef struct
 {
-	double		time;	/* all time units other than months and years */
-	int4		month;	/* months and years, after time for alignment */
+	double		time;			/* all time units other than months and
+								 * years */
+	int4		month;			/* months and years, after time for
+								 * alignment */
 } Interval;
 
 
@@ -51,29 +53,29 @@ typedef struct
 #define DT_CURRENT		(DBL_MIN)
 #define DT_EPOCH		(-DBL_MIN)
 
-#define TIMESTAMP_INVALID(j)		{j = DT_INVALID;}
+#define TIMESTAMP_INVALID(j)		do {j = DT_INVALID;} while (0)
 #ifdef NAN
-#define TIMESTAMP_IS_INVALID(j)	(isnan(j))
+#define TIMESTAMP_IS_INVALID(j) (isnan(j))
 #else
-#define TIMESTAMP_IS_INVALID(j)	(j == DT_INVALID)
+#define TIMESTAMP_IS_INVALID(j) (j == DT_INVALID)
 #endif
 
-#define TIMESTAMP_NOBEGIN(j)		{j = DT_NOBEGIN;}
-#define TIMESTAMP_IS_NOBEGIN(j)	(j == DT_NOBEGIN)
+#define TIMESTAMP_NOBEGIN(j)		do {j = DT_NOBEGIN;} while (0)
+#define TIMESTAMP_IS_NOBEGIN(j) (j == DT_NOBEGIN)
 
-#define TIMESTAMP_NOEND(j)		{j = DT_NOEND;}
+#define TIMESTAMP_NOEND(j)		do {j = DT_NOEND;} while (0)
 #define TIMESTAMP_IS_NOEND(j)	(j == DT_NOEND)
 
-#define TIMESTAMP_CURRENT(j)		{j = DT_CURRENT;}
+#define TIMESTAMP_CURRENT(j)		do {j = DT_CURRENT;} while (0)
 #if defined(linux) && defined(__powerpc__)
 extern int	timestamp_is_current(double j);
 
-#define TIMESTAMP_IS_CURRENT(j)	timestamp_is_current(j)
+#define TIMESTAMP_IS_CURRENT(j) timestamp_is_current(j)
 #else
-#define TIMESTAMP_IS_CURRENT(j)	(j == DT_CURRENT)
+#define TIMESTAMP_IS_CURRENT(j) (j == DT_CURRENT)
 #endif
 
-#define TIMESTAMP_EPOCH(j)		{j = DT_EPOCH;}
+#define TIMESTAMP_EPOCH(j)		do {j = DT_EPOCH;} while (0)
 #if defined(linux) && defined(__powerpc__)
 extern int	timestamp_is_epoch(double j);
 
@@ -83,11 +85,11 @@ extern int	timestamp_is_epoch(double j);
 #endif
 
 #define TIMESTAMP_IS_RELATIVE(j) (TIMESTAMP_IS_CURRENT(j) || TIMESTAMP_IS_EPOCH(j))
-#define TIMESTAMP_NOT_FINITE(j)	(TIMESTAMP_IS_INVALID(j) \
+#define TIMESTAMP_NOT_FINITE(j) (TIMESTAMP_IS_INVALID(j) \
 								|| TIMESTAMP_IS_NOBEGIN(j) || TIMESTAMP_IS_NOEND(j))
 #define TIMESTAMP_IS_RESERVED(j) (TIMESTAMP_IS_RELATIVE(j) || TIMESTAMP_NOT_FINITE(j))
 
-#define INTERVAL_INVALID(j)		{(j).time = DT_INVALID;}
+#define INTERVAL_INVALID(j)		do {(j).time = DT_INVALID;} while (0)
 #ifdef NAN
 #define INTERVAL_IS_INVALID(j)	(isnan((j).time))
 #else
@@ -152,15 +154,15 @@ extern Timestamp *timestamp_mi_span(Timestamp *dt, Interval *span);
 extern Interval *timestamp_age(Timestamp *dt1, Timestamp *dt2);
 extern bool overlaps_timestamp(Timestamp *dt1, Timestamp *dt2, Timestamp *dt3, Timestamp *dt4);
 
-extern int tm2timestamp(struct tm * tm, double fsec, int *tzp, Timestamp *dt);
-extern int timestamp2tm(Timestamp dt, int *tzp, struct tm * tm, double *fsec, char **tzn);
+extern int	tm2timestamp(struct tm * tm, double fsec, int *tzp, Timestamp *dt);
+extern int	timestamp2tm(Timestamp dt, int *tzp, struct tm * tm, double *fsec, char **tzn);
 
 extern Timestamp SetTimestamp(Timestamp timestamp);
 extern Timestamp dt2local(Timestamp dt, int timezone);
 extern void dt2time(Timestamp dt, int *hour, int *min, double *sec);
-extern int EncodeSpecialTimestamp(Timestamp dt, char *str);
-extern int interval2tm(Interval span, struct tm * tm, float8 *fsec);
-extern int tm2interval(struct tm * tm, double fsec, Interval *span);
+extern int	EncodeSpecialTimestamp(Timestamp dt, char *str);
+extern int	interval2tm(Interval span, struct tm * tm, float8 *fsec);
+extern int	tm2interval(struct tm * tm, double fsec, Interval *span);
 extern Timestamp *now(void);
 
 #endif	 /* TIMESTAMP_H */
diff --git a/src/include/utils/tqual.h b/src/include/utils/tqual.h
index 9f361fd6ff47f320af3f6d8eebb6237e74da9c82..01a3b9c80c7b6bbdce0d3a37a390af1334413b1f 100644
--- a/src/include/utils/tqual.h
+++ b/src/include/utils/tqual.h
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: tqual.h,v 1.28 2000/01/26 05:58:38 momjian Exp $
+ * $Id: tqual.h,v 1.29 2000/04/12 17:16:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -21,11 +21,11 @@
 
 typedef struct SnapshotData
 {
-	TransactionId	xmin;		/* XID < xmin are visible to me */
-	TransactionId	xmax;		/* XID >= xmax are invisible to me */
-	uint32			xcnt;		/* # of xact below */
-	TransactionId  *xip;		/* array of xacts in progress */
-	ItemPointerData	tid;		/* required for Dirty snapshot -:( */
+	TransactionId xmin;			/* XID < xmin are visible to me */
+	TransactionId xmax;			/* XID >= xmax are invisible to me */
+	uint32		xcnt;			/* # of xact below */
+	TransactionId *xip;			/* array of xacts in progress */
+	ItemPointerData tid;		/* required for Dirty snapshot -:( */
 } SnapshotData;
 
 typedef SnapshotData *Snapshot;
@@ -89,7 +89,7 @@ extern bool HeapTupleSatisfiesItself(HeapTupleHeader tuple);
 extern bool HeapTupleSatisfiesNow(HeapTupleHeader tuple);
 extern bool HeapTupleSatisfiesDirty(HeapTupleHeader tuple);
 extern bool HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple,
-									   Snapshot snapshot);
+						   Snapshot snapshot);
 extern int	HeapTupleSatisfiesUpdate(HeapTuple tuple);
 
 extern Snapshot GetSnapshotData(bool serializable);
diff --git a/src/include/utils/trace.h b/src/include/utils/trace.h
index 3cb2d9e28f1d7e18ebd7b2db0641da9877eb4ae5..71e402e9edc1ba1347536ff109ca815882a6b52d 100644
--- a/src/include/utils/trace.h
+++ b/src/include/utils/trace.h
@@ -34,8 +34,10 @@ extern void read_pg_options(SIGNAL_ARGS);
  * Trace options, used as index into pg_options.
  * Must match the constants in pg_options[].
  */
-enum pg_option_enum {
-	TRACE_ALL,					/* 0=trace some, 1=trace all, -1=trace none */
+enum pg_option_enum
+{
+	TRACE_ALL,					/* 0=trace some, 1=trace all, -1=trace
+								 * none */
 	TRACE_VERBOSE,
 	TRACE_QUERY,
 	TRACE_PLAN,
diff --git a/src/include/utils/tuplesort.h b/src/include/utils/tuplesort.h
index dc4dffa8e0ab011276cff24f20fa337be1c2559b..6b54eb9f0b9bb9dd870b223cad387b7dc992cc3c 100644
--- a/src/include/utils/tuplesort.h
+++ b/src/include/utils/tuplesort.h
@@ -6,14 +6,14 @@
  * This module handles sorting of heap tuples, index tuples, or single
  * Datums (and could easily support other kinds of sortable objects,
  * if necessary).  It works efficiently for both small and large amounts
- * of data.  Small amounts are sorted in-memory using qsort().  Large
+ * of data.  Small amounts are sorted in-memory using qsort().	Large
  * amounts are sorted using temporary files and a standard external sort
  * algorithm.
  *
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: tuplesort.h,v 1.3 2000/01/26 05:58:38 momjian Exp $
+ * $Id: tuplesort.h,v 1.4 2000/04/12 17:16:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -39,31 +39,32 @@ typedef struct Tuplesortstate Tuplesortstate;
  */
 
 extern Tuplesortstate *tuplesort_begin_heap(TupleDesc tupDesc,
-											int nkeys, ScanKey keys,
-											bool randomAccess);
+					 int nkeys, ScanKey keys,
+					 bool randomAccess);
 extern Tuplesortstate *tuplesort_begin_index(Relation indexRel,
-											 bool enforceUnique,
-											 bool randomAccess);
+					  bool enforceUnique,
+					  bool randomAccess);
 extern Tuplesortstate *tuplesort_begin_datum(Oid datumType,
-											 Oid sortOperator,
-											 bool randomAccess);
+					  Oid sortOperator,
+					  bool randomAccess);
 
 extern void tuplesort_puttuple(Tuplesortstate *state, void *tuple);
 
 extern void tuplesort_putdatum(Tuplesortstate *state, Datum val,
-							   bool isNull);
+				   bool isNull);
 
 extern void tuplesort_performsort(Tuplesortstate *state);
 
 extern void *tuplesort_gettuple(Tuplesortstate *state, bool forward,
-								bool *should_free);
+				   bool *should_free);
+
 #define tuplesort_getheaptuple(state, forward, should_free) \
 	((HeapTuple) tuplesort_gettuple(state, forward, should_free))
 #define tuplesort_getindextuple(state, forward, should_free) \
 	((IndexTuple) tuplesort_gettuple(state, forward, should_free))
 
 extern bool tuplesort_getdatum(Tuplesortstate *state, bool forward,
-							   Datum *val, bool *isNull);
+				   Datum *val, bool *isNull);
 
 extern void tuplesort_end(Tuplesortstate *state);
 
diff --git a/src/include/utils/varbit.h b/src/include/utils/varbit.h
index 9ee0724b01d790da6ef13d0e5254de5e7791a464..e6106331b9aaa6f26dd1ef7f8087e83e2f1cc65e 100644
--- a/src/include/utils/varbit.h
+++ b/src/include/utils/varbit.h
@@ -17,7 +17,7 @@
 #include "utils/builtins.h"
 
 
-#define HEXDIG(z)    (z)<10 ? ((z)+'0') : ((z)-10+'A')
+#define HEXDIG(z)	 (z)<10 ? ((z)+'0') : ((z)-10+'A')
 
 /* Modeled on struct varlena from postgres.h, bu data type is bits8 */
 struct varbita
@@ -47,41 +47,41 @@ struct varbita
 #define BITHIGH 0x80
 
 
-bits8 * zpbit_in(char *s, int dummy,  int32 atttypmod);
-char * zpbit_out(bits8 *s);
-char * zpbits_out(bits8 *s);
-bits8 * varbit_in(char *s, int dummy,  int32 atttypmod);
-char * varbit_out (bits8 *s);
-bool biteq (bits8 *arg1, bits8 *arg2);
-bool bitne (bits8 *arg1, bits8 *arg2);
-bool bitge (bits8 *arg1, bits8 *arg2);
-bool bitgt (bits8 *arg1, bits8 *arg2);
-bool bitle (bits8 *arg1, bits8 *arg2);
-bool bitlt (bits8 *arg1, bits8 *arg2);
-int bitcmp (bits8 *arg1, bits8 *arg2);
-bits8 * bitand (bits8 * arg1, bits8 * arg2);
-bits8 * bitor (bits8 * arg1, bits8 * arg2);
-bits8 * bitxor (bits8 * arg1, bits8 * arg2);
-bits8 * bitnot (bits8 * arg);
-bits8 * bitshiftright (bits8 * arg, int shft);
-bits8 * bitshiftleft (bits8 * arg, int shft);
-bits8 * bitcat (bits8 *arg1, bits8 *arg2);
-bits8 * bitsubstr (bits8 *arg, int32 s, int32 l);
+bits8	   *zpbit_in(char *s, int dummy, int32 atttypmod);
+char	   *zpbit_out(bits8 *s);
+char	   *zpbits_out(bits8 *s);
+bits8	   *varbit_in(char *s, int dummy, int32 atttypmod);
+char	   *varbit_out(bits8 *s);
+bool		biteq(bits8 *arg1, bits8 *arg2);
+bool		bitne(bits8 *arg1, bits8 *arg2);
+bool		bitge(bits8 *arg1, bits8 *arg2);
+bool		bitgt(bits8 *arg1, bits8 *arg2);
+bool		bitle(bits8 *arg1, bits8 *arg2);
+bool		bitlt(bits8 *arg1, bits8 *arg2);
+int			bitcmp(bits8 *arg1, bits8 *arg2);
+bits8	   *bitand(bits8 *arg1, bits8 *arg2);
+bits8	   *bitor(bits8 *arg1, bits8 *arg2);
+bits8	   *bitxor(bits8 *arg1, bits8 *arg2);
+bits8	   *bitnot(bits8 *arg);
+bits8	   *bitshiftright(bits8 *arg, int shft);
+bits8	   *bitshiftleft(bits8 *arg, int shft);
+bits8	   *bitcat(bits8 *arg1, bits8 *arg2);
+bits8	   *bitsubstr(bits8 *arg, int32 s, int32 l);
 
-bool varbiteq (bits8 *arg1, bits8 *arg2);
-bool varbitne (bits8 *arg1, bits8 *arg2);
-bool varbitge (bits8 *arg1, bits8 *arg2);
-bool varbitgt (bits8 *arg1, bits8 *arg2);
-bool varbitle (bits8 *arg1, bits8 *arg2);
-bool varbitlt (bits8 *arg1, bits8 *arg2);
-int varbitcmp (bits8 *arg1, bits8 *arg2);
-bits8 * varbitand (bits8 * arg1, bits8 * arg2);
-bits8 * varbitor (bits8 * arg1, bits8 * arg2);
-bits8 * varbitxor (bits8 * arg1, bits8 * arg2);
-bits8 * varbitnot (bits8 * arg);
-bits8 * varbitshiftright (bits8 * arg, int shft);
-bits8 * varbitshiftleft (bits8 * arg, int shft);
-bits8 * varbitcat (bits8 *arg1, bits8 *arg2);
-bits8 * varbitsubstr (bits8 *arg, int32 s, int32 l);
+bool		varbiteq(bits8 *arg1, bits8 *arg2);
+bool		varbitne(bits8 *arg1, bits8 *arg2);
+bool		varbitge(bits8 *arg1, bits8 *arg2);
+bool		varbitgt(bits8 *arg1, bits8 *arg2);
+bool		varbitle(bits8 *arg1, bits8 *arg2);
+bool		varbitlt(bits8 *arg1, bits8 *arg2);
+int			varbitcmp(bits8 *arg1, bits8 *arg2);
+bits8	   *varbitand(bits8 *arg1, bits8 *arg2);
+bits8	   *varbitor(bits8 *arg1, bits8 *arg2);
+bits8	   *varbitxor(bits8 *arg1, bits8 *arg2);
+bits8	   *varbitnot(bits8 *arg);
+bits8	   *varbitshiftright(bits8 *arg, int shft);
+bits8	   *varbitshiftleft(bits8 *arg, int shft);
+bits8	   *varbitcat(bits8 *arg1, bits8 *arg2);
+bits8	   *varbitsubstr(bits8 *arg, int32 s, int32 l);
 
 #endif
diff --git a/src/interfaces/cli/example1.c b/src/interfaces/cli/example1.c
index 95dbeabd640e54f3a1cc279cf3554b412cb734d2..88d8d7f403f65b2185e74fa239dd50a0114a2639 100644
--- a/src/interfaces/cli/example1.c
+++ b/src/interfaces/cli/example1.c
@@ -13,7 +13,7 @@
  */
 
 /*
- * B.1  Create table, insert, select
+ * B.1	Create table, insert, select
  *
  * This example function creates a table, inserts data into the table,
  * and selects the inserted data.
@@ -37,135 +37,137 @@
 #define NULL   0
 #endif
 
-int print_err(SQLSMALLINT handletype, SQLINTEGER handle);
+int			print_err(SQLSMALLINT handletype, SQLINTEGER handle);
 
-int example1(SQLCHAR *server, SQLCHAR *uid, SQLCHAR *authen)
+int
+example1(SQLCHAR * server, SQLCHAR * uid, SQLCHAR * authen)
 {
-  SQLHENV     henv;
-  SQLHDBC     hdbc;
-  SQLHDESC    hdesc;
-  SQLHDESC    hdesc1;
-  SQLHDESC    hdesc2;
-  SQLHSTMT    hstmt;
-  SQLINTEGER  id;
-  SQLSMALLINT idind;
-  SQLCHAR     name[51];
-  SQLINTEGER  namelen;
-  SQLSMALLINT nameind;
-
-  /* EXEC SQL CONNECT TO :server USER :uid; */
-
-  /* allocate an environment handle */
-  SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
-  /* allocate a connection handle */
-  SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
-
-  /* connect to database */
-  if (SQLConnect(hdbc, server, SQL_NTS, uid, SQL_NTS,
-		 authen, SQL_NTS)
-      != SQL_SUCCESS)
-    return(print_err(SQL_HANDLE_DBC, hdbc));
-
-  /* allocate a statement handle */
-  SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
-
-  /* EXEC SQL CREATE TABLE NAMEID (ID integer, NAME varchar(50));  */
-  {
-    SQLCHAR create[]  ="CREATE TABLE NAMEID (ID integer,"
-      " NAME varchar(50))";
-
-    /* execute the CREATE TABLE statement */
-    if (SQLExecDirect(hstmt, create, SQL_NTS) != SQL_SUCCESS)
-      return(print_err(SQL_HANDLE_STMT, hstmt));
-  }
-
-  /* EXEC SQL COMMIT WORK; */
-  /* commit CREATE TABLE */
-  SQLEndTran(SQL_HANDLE_ENV, henv, SQL_COMMIT);
-  /* EXEC SQL INSERT INTO NAMEID VALUES ( :id, :name ); */
-  {
-    SQLCHAR insert[]=  "INSERT INTO NAMEID VALUES (?, ?)";
-
-    /* show the use of SQLPrepare/SQLExecute method */
-    /* prepare the INSERT */
-    if (SQLPrepare(hstmt, insert, SQL_NTS) != SQL_SUCCESS)
-      return(print_err(SQL_HANDLE_STMT, hstmt));
-    /* application parameter descriptor */
-    SQLGetStmtAttr(hstmt, SQL_ATTR_APP_PARAM_
-		   DESC, &hdesc1, 0L,
-		   (SQLINTEGER *)NULL);
-    SQLSetDescRec(hdesc1, 1, SQL_INTEGER, 0, 0L, 0, 0,
-		  (SQLPOINTER)&id, (SQLINTEGER *)NULL, (SQLSMALLINT *)NULL);
-    SQLSetDescRec(hdesc1, 2, SQL_CHAR, 0, 0L, 0, 0,
-		  (SQLPOINTER)name, (SQLINTEGER *)NULL,
-		  (SQLSMALLINT *)NULL);
-    /* implementation parameter descriptor */
-    SQLGetStmtAttr(hstmt, SQL_ATTR_IMP_PARAM_
-		   DESC, &hdesc2, 0L,
-		   (SQLINTEGER *)NULL);
-    SQLSetDescRec(hdesc2, 1, SQL_INTEGER, 0, 0L, 0, 0,
-		  (SQLPOINTER)NULL, (SQLINTEGER *)NULL,
-		  (SQLSMALLINT *)NULL);
-    SQLSetDescRec(hdesc2, 2, SQL_VARCHAR, 0, 50L, 0, 0,
-		  (SQLPOINTER)NULL, (SQLINTEGER *)NULL,
-		  (SQLSMALLINT *)NULL);
-
-    /* assign parameter values and execute the INSERT */
-    id=500;
-    (void)strcpy(name, "Babbage");
-    if (SQLExecute(hstmt) != SQL_SUCCESS)
-      return(print_err(SQL_HANDLE_STMT, hstmt));
-  }
-  /* EXEC SQL COMMIT WORK; */
-  SQLEndTran(SQL_HANDLE_ENV, henv, SQL_COMMIT);
-  /* commit inserts */
-
-  /* EXEC SQL DECLARE c1 CURSOR FOR SELECT ID, NAME FROM NAMEID; */
-  /* EXEC SQL OPEN c1; */
-  /* The application doesn't specify "declare c1 cursor for" */
-  {
-    SQLCHAR select[]=  "select ID, NAME from NAMEID";
-    if (SQLExecDirect(hstmt, select, SQL_NTS) != SQL_SUCCESS)
-      return(print_err(SQL_HANDLE_STMT, hstmt));
-  }
-
-  /* EXEC SQL FETCH c1 INTO :id, :name; */
-  /* this time, explicitly allocate an application row descriptor */
-  SQLAllocHandle(SQL_HANDLE_DESC, hdbc, &hdesc);
-  SQLSetDescRec(hdesc, 1, SQL_INTEGER, 0, 0L, 0, 0,
-		(SQLPOINTER)&id, (SQLINTEGER *)NULL, (SQLSMALLINT *)&idind);
-
-  SQLSetDescRec(hdesc, 2, SQL_
-		CHAR, 0, (SQLINTEGER)sizeof(name),
-		0, 0, (SQLPOINTER)&name, (SQLINTEGER *)&namelen,
-		(SQLSMALLINT *)&nameind);
-  /* associate descriptor with statement handle */
-  SQLSetStmtAttr(hstmt, SQL_ATTR_APP_ROW_DESC, &hdesc, 0);
-  /* execute the fetch */
-  SQLFetch(hstmt);
-
-  /* EXEC SQL COMMIT WORK; */
-  /* commit the transaction  */
-  SQLEndTran(SQL_HANDLE_ENV, henv, SQL_COMMIT);
-
-  /* EXEC SQL CLOSE c1; */
-  SQLClose(hstmt);
-  /* free the statement handle */
-  SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
-
-  /* EXEC SQL DISCONNECT; */
-  /* disconnect from the database */
-  SQLDisconnect(hdbc);
-  /* free descriptor handle */
-  SQLFreeHandle(SQL_HANDLE_DESC, hdesc);
-  /* free descriptor handle */
-  SQLFreeHandle(SQL_HANDLE_DESC, hdesc1);
-  /* free descriptor handle */
-  SQLFreeHandle(SQL_HANDLE_DESC, hdesc2);
-  /* free connection handle */
-  SQLFreeHandle(SQL_HANDLE_DBC,  hdbc);
-  /* free environment handle */
-  SQLFreeHandle(SQL_HANDLE_ENV,  henv);
-
-  return(0);
+	SQLHENV		henv;
+	SQLHDBC		hdbc;
+	SQLHDESC	hdesc;
+	SQLHDESC	hdesc1;
+	SQLHDESC	hdesc2;
+	SQLHSTMT	hstmt;
+	SQLINTEGER	id;
+	SQLSMALLINT idind;
+	SQLCHAR		name[51];
+	SQLINTEGER	namelen;
+	SQLSMALLINT nameind;
+
+	/* EXEC SQL CONNECT TO :server USER :uid; */
+
+	/* allocate an environment handle */
+	SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
+	/* allocate a connection handle */
+	SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
+
+	/* connect to database */
+	if (SQLConnect(hdbc, server, SQL_NTS, uid, SQL_NTS,
+				   authen, SQL_NTS)
+		!= SQL_SUCCESS)
+		return (print_err(SQL_HANDLE_DBC, hdbc));
+
+	/* allocate a statement handle */
+	SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
+
+	/* EXEC SQL CREATE TABLE NAMEID (ID integer, NAME varchar(50));  */
+	{
+		SQLCHAR		create[] = "CREATE TABLE NAMEID (ID integer,"
+		" NAME varchar(50))";
+
+		/* execute the CREATE TABLE statement */
+		if (SQLExecDirect(hstmt, create, SQL_NTS) != SQL_SUCCESS)
+			return (print_err(SQL_HANDLE_STMT, hstmt));
+	}
+
+	/* EXEC SQL COMMIT WORK; */
+	/* commit CREATE TABLE */
+	SQLEndTran(SQL_HANDLE_ENV, henv, SQL_COMMIT);
+	/* EXEC SQL INSERT INTO NAMEID VALUES ( :id, :name ); */
+	{
+		SQLCHAR		insert[] = "INSERT INTO NAMEID VALUES (?, ?)";
+
+		/* show the use of SQLPrepare/SQLExecute method */
+		/* prepare the INSERT */
+		if (SQLPrepare(hstmt, insert, SQL_NTS) != SQL_SUCCESS)
+			return (print_err(SQL_HANDLE_STMT, hstmt));
+		/* application parameter descriptor */
+		SQLGetStmtAttr(hstmt, SQL_ATTR_APP_PARAM_
+					   DESC, &hdesc1, 0L,
+					   (SQLINTEGER *) NULL);
+		SQLSetDescRec(hdesc1, 1, SQL_INTEGER, 0, 0L, 0, 0,
+		   (SQLPOINTER) & id, (SQLINTEGER *) NULL, (SQLSMALLINT *) NULL);
+		SQLSetDescRec(hdesc1, 2, SQL_CHAR, 0, 0L, 0, 0,
+					  (SQLPOINTER) name, (SQLINTEGER *) NULL,
+					  (SQLSMALLINT *) NULL);
+		/* implementation parameter descriptor */
+		SQLGetStmtAttr(hstmt, SQL_ATTR_IMP_PARAM_
+					   DESC, &hdesc2, 0L,
+					   (SQLINTEGER *) NULL);
+		SQLSetDescRec(hdesc2, 1, SQL_INTEGER, 0, 0L, 0, 0,
+					  (SQLPOINTER) NULL, (SQLINTEGER *) NULL,
+					  (SQLSMALLINT *) NULL);
+		SQLSetDescRec(hdesc2, 2, SQL_VARCHAR, 0, 50L, 0, 0,
+					  (SQLPOINTER) NULL, (SQLINTEGER *) NULL,
+					  (SQLSMALLINT *) NULL);
+
+		/* assign parameter values and execute the INSERT */
+		id = 500;
+		(void) strcpy(name, "Babbage");
+		if (SQLExecute(hstmt) != SQL_SUCCESS)
+			return (print_err(SQL_HANDLE_STMT, hstmt));
+	}
+	/* EXEC SQL COMMIT WORK; */
+	SQLEndTran(SQL_HANDLE_ENV, henv, SQL_COMMIT);
+	/* commit inserts */
+
+	/* EXEC SQL DECLARE c1 CURSOR FOR SELECT ID, NAME FROM NAMEID; */
+	/* EXEC SQL OPEN c1; */
+	/* The application doesn't specify "declare c1 cursor for" */
+	{
+		SQLCHAR		select[] = "select ID, NAME from NAMEID";
+
+		if (SQLExecDirect(hstmt, select, SQL_NTS) != SQL_SUCCESS)
+			return (print_err(SQL_HANDLE_STMT, hstmt));
+	}
+
+	/* EXEC SQL FETCH c1 INTO :id, :name; */
+	/* this time, explicitly allocate an application row descriptor */
+	SQLAllocHandle(SQL_HANDLE_DESC, hdbc, &hdesc);
+	SQLSetDescRec(hdesc, 1, SQL_INTEGER, 0, 0L, 0, 0,
+		(SQLPOINTER) & id, (SQLINTEGER *) NULL, (SQLSMALLINT *) & idind);
+
+	SQLSetDescRec(hdesc, 2, SQL_
+				  CHAR, 0, (SQLINTEGER) sizeof(name),
+				  0, 0, (SQLPOINTER) & name, (SQLINTEGER *) & namelen,
+				  (SQLSMALLINT *) & nameind);
+	/* associate descriptor with statement handle */
+	SQLSetStmtAttr(hstmt, SQL_ATTR_APP_ROW_DESC, &hdesc, 0);
+	/* execute the fetch */
+	SQLFetch(hstmt);
+
+	/* EXEC SQL COMMIT WORK; */
+	/* commit the transaction  */
+	SQLEndTran(SQL_HANDLE_ENV, henv, SQL_COMMIT);
+
+	/* EXEC SQL CLOSE c1; */
+	SQLClose(hstmt);
+	/* free the statement handle */
+	SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
+
+	/* EXEC SQL DISCONNECT; */
+	/* disconnect from the database */
+	SQLDisconnect(hdbc);
+	/* free descriptor handle */
+	SQLFreeHandle(SQL_HANDLE_DESC, hdesc);
+	/* free descriptor handle */
+	SQLFreeHandle(SQL_HANDLE_DESC, hdesc1);
+	/* free descriptor handle */
+	SQLFreeHandle(SQL_HANDLE_DESC, hdesc2);
+	/* free connection handle */
+	SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
+	/* free environment handle */
+	SQLFreeHandle(SQL_HANDLE_ENV, henv);
+
+	return (0);
 }
diff --git a/src/interfaces/cli/example2.c b/src/interfaces/cli/example2.c
index e882274221349c1e94f00d19f36bcbe94c08f99a..d74b1e971a5ee5a7329f68e1a5a0c0e6cad18457 100644
--- a/src/interfaces/cli/example2.c
+++ b/src/interfaces/cli/example2.c
@@ -13,7 +13,7 @@
  */
 
 /*
- * B.2  Interactive Query
+ * B.2	Interactive Query
  *
  * This sample function uses the concise CLI functions to
  * interactively execute a SQL statement supplied as an argument.
@@ -38,158 +38,163 @@
 
 #define  max(a,b) (a>b?a:b)
 
-int print_err(SQLSMALLINT handletype, SQLINTEGER handle);
-int build_indicator_message(SQLCHAR *errmsg,
-			    SQLPOINTER *data,
-			    SQLINTEGER collen,
-			    SQLINTEGER *outlen,
-			    SQLSMALLINT colnum);
+int			print_err(SQLSMALLINT handletype, SQLINTEGER handle);
+int build_indicator_message(SQLCHAR * errmsg,
+						SQLPOINTER * data,
+						SQLINTEGER collen,
+						SQLINTEGER * outlen,
+						SQLSMALLINT colnum);
 
 SQLINTEGER display_length(SQLSMALLINT coltype,
-			  SQLINTEGER collen,
-			  SQLCHAR *colname);
+			   SQLINTEGER collen,
+			   SQLCHAR * colname);
 
-example2(SQLCHAR *server, SQLCHAR *uid, SQLCHAR *authen, SQLCHAR *sqlstr)
+example2(SQLCHAR * server, SQLCHAR * uid, SQLCHAR * authen, SQLCHAR * sqlstr)
 {
-  int         i;
-  SQLHENV     henv;
-  SQLHDBC     hdbc;
-  SQLHSTMT    hstmt;
-  SQLCHAR     errmsg[256];
-  SQLCHAR     colname[32];
-  SQLSMALLINT coltype;
-  SQLSMALLINT colnamelen;
-  SQLSMALLINT nullable;
-  SQLINTEGER  collen[MAXCOLS];
-  SQLSMALLINT scale;
-  SQLINTEGER  outlen[MAXCOLS];
-  SQLCHAR    *data[MAXCOLS];
-  SQLSMALLINT nresultcols;
-  SQLINTEGER  rowcount;
-  SQLINTEGER  stmttype;
-  SQLRETURN   rc;
-
-  /* allocate an environment handle */
-  SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
-
-  /* allocate a connection handle */
-  SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
-
-  /* connect to database */
-  if (SQLConnect(hdbc, server, SQL_NTS, uid, SQL_NTS, authen, SQL_NTS)
-      != SQL_SUCCESS )
-    return(print_err(SQL_HANDLE_DBC, hdbc));
-
-  /* allocate a statement handle */
-  SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
-
-  /* execute the SQL statement */
-  if (SQLExecDirect(hstmt, sqlstr, SQL_NTS) != SQL_SUCCESS)
-    return(print_err(SQL_HANDLE_STMT, hstmt));
-
-  /* see what kind of statement it was */
-  SQLGetDiagField(SQL_HANDLE_STMT, hstmt, 0,
-		  SQL_DIAG_DYNAMIC_FUNCTION_CODE,
-		  (SQLPOINTER)&stmttype, 0, (SQLSMALLINT *)NULL);
-
-  switch (stmttype) {
-    /* SELECT statement */
-  case SQL_SELECT_CURSOR:
-    /* determine number of result columns */
-    SQLNumResultCols(hstmt, &nresultcols);
-    /* display column names */
-    for (i=0; i<nresultcols; i++) {
-      SQLDescribeCol(hstmt, i+1, colname, sizeof(colname),
-		     &colnamelen, &coltype, &collen[i], &scale, &nullable);
-
-      /* assume there is a display_length function which
-	 computes correct length given the data type  */
-      collen[i] = display_length(coltype, collen[i], colname);
-      (void)printf("%*.*s", collen[i], collen[i], colname);
-      /* allocate memory to bind column */
-      data[i] = (SQLCHAR *) malloc(collen[i]);
-
-      /* bind columns to program vars, converting all types to CHAR */
-      SQLBindCol(hstmt, i+1, SQL_CHAR, data[i], collen[i],
-		 &outlen[i]);
-    }
-    /* display result rows */
-    while ((rc=SQLFetch(hstmt))!=SQL_ERROR) {
-      errmsg[0] = '\0';
-      if (rc ==  SQL_SUCCESS_WITH_INFO) {
-	for (i=0; i<nresultcols; i++) {
-	  if (outlen[i] ==  SQL_NULL_DATA || outlen[i] >= collen[i])
-	    build_indicator_message(errmsg,
-                                    (SQLPOINTER *)&data[i], collen[i],
-                                    &outlen[i], i);
-	  (void)printf("%*.*s ", outlen[i], outlen[i],
-		       data[i]);
-	} /* for all columns in this row  */
-	/* print any truncation messages */
-	(void)printf("\n%s", errmsg);
-      }
-    } /* while rows to fetch */
-    SQLClose(hstmt);
-    break;
-
-    /* searched DELETE, INSERT or searched UPDATE statement */
-  case SQL_DELETE_WHERE:
-  case SQL_INSERT:
-  case SQL_UPDATE_WHERE:
-    /* check rowcount */
-    SQLGetDiagField(SQL_HANDLE_STMT, hstmt, 0,
-		    SQL_DIAG_ROW_COUNT, (SQLPOINTER)&rowcount, 0,
-		    (SQLSMALLINT *)NULL);
-    if (SQLEndTran(SQL_HANDLE_ENV, henv, SQL_COMMIT)
-	==  SQL_SUCCESS) {
-      (void) printf("Operation successful\n");
-    }
-    else {
-      (void) printf("Operation failed\n");
-    }
-    (void)printf("%ld rows affected\n", rowcount);
-    break;
-
-    /* other statements */
-  case SQL_ALTER_TABLE:
-  case SQL_CREATE_TABLE:
-  case SQL_CREATE_VIEW:
-  case SQL_DROP_TABLE:
-  case SQL_DROP_VIEW:
-  case SQL_DYNAMIC_DELETE_CURSOR:
-  case SQL_DYNAMIC_UPDATE_CURSOR:
-  case SQL_GRANT:
-  case SQL_REVOKE:
-    if (SQLEndTran(SQL_HANDLE_ENV, henv, SQL_COMMIT)
-	==  SQL_SUCCESS) {
-      (void) printf("Operation successful\n");
-    }
-    else {
-      (void) printf("Operation failed\n");
-    }
-    break;
-
-  /* implementation-defined statement */
-  default:
-    (void)printf("Statement type=%ld\n", stmttype);
-    break;
-  }
-
-  /* free data buffers */
-  for (i=0; i<nresultcols; i++)  {
-    (void)free(data[i]);
-  }
-
-  /* free statement handle */
-  SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
-  /* disconnect from database */
-  SQLDisconnect(hdbc);
-  /* free connection handle */
-  SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
-  /* free environment handle */
-  SQLFreeHandle(SQL_HANDLE_ENV, henv);
-
-  return(0);
+	int			i;
+	SQLHENV		henv;
+	SQLHDBC		hdbc;
+	SQLHSTMT	hstmt;
+	SQLCHAR		errmsg[256];
+	SQLCHAR		colname[32];
+	SQLSMALLINT coltype;
+	SQLSMALLINT colnamelen;
+	SQLSMALLINT nullable;
+	SQLINTEGER	collen[MAXCOLS];
+	SQLSMALLINT scale;
+	SQLINTEGER	outlen[MAXCOLS];
+	SQLCHAR    *data[MAXCOLS];
+	SQLSMALLINT nresultcols;
+	SQLINTEGER	rowcount;
+	SQLINTEGER	stmttype;
+	SQLRETURN	rc;
+
+	/* allocate an environment handle */
+	SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
+
+	/* allocate a connection handle */
+	SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
+
+	/* connect to database */
+	if (SQLConnect(hdbc, server, SQL_NTS, uid, SQL_NTS, authen, SQL_NTS)
+		!= SQL_SUCCESS)
+		return (print_err(SQL_HANDLE_DBC, hdbc));
+
+	/* allocate a statement handle */
+	SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
+
+	/* execute the SQL statement */
+	if (SQLExecDirect(hstmt, sqlstr, SQL_NTS) != SQL_SUCCESS)
+		return (print_err(SQL_HANDLE_STMT, hstmt));
+
+	/* see what kind of statement it was */
+	SQLGetDiagField(SQL_HANDLE_STMT, hstmt, 0,
+					SQL_DIAG_DYNAMIC_FUNCTION_CODE,
+					(SQLPOINTER) & stmttype, 0, (SQLSMALLINT *) NULL);
+
+	switch (stmttype)
+	{
+			/* SELECT statement */
+		case SQL_SELECT_CURSOR:
+			/* determine number of result columns */
+			SQLNumResultCols(hstmt, &nresultcols);
+			/* display column names */
+			for (i = 0; i < nresultcols; i++)
+			{
+				SQLDescribeCol(hstmt, i + 1, colname, sizeof(colname),
+				   &colnamelen, &coltype, &collen[i], &scale, &nullable);
+
+				/*
+				 * assume there is a display_length function which
+				 * computes correct length given the data type
+				 */
+				collen[i] = display_length(coltype, collen[i], colname);
+				(void) printf("%*.*s", collen[i], collen[i], colname);
+				/* allocate memory to bind column */
+				data[i] = (SQLCHAR *) malloc(collen[i]);
+
+				/*
+				 * bind columns to program vars, converting all types to
+				 * CHAR
+				 */
+				SQLBindCol(hstmt, i + 1, SQL_CHAR, data[i], collen[i],
+						   &outlen[i]);
+			}
+			/* display result rows */
+			while ((rc = SQLFetch(hstmt)) != SQL_ERROR)
+			{
+				errmsg[0] = '\0';
+				if (rc == SQL_SUCCESS_WITH_INFO)
+				{
+					for (i = 0; i < nresultcols; i++)
+					{
+						if (outlen[i] == SQL_NULL_DATA || outlen[i] >= collen[i])
+							build_indicator_message(errmsg,
+									 (SQLPOINTER *) & data[i], collen[i],
+													&outlen[i], i);
+						(void) printf("%*.*s ", outlen[i], outlen[i],
+									  data[i]);
+					}			/* for all columns in this row	*/
+					/* print any truncation messages */
+					(void) printf("\n%s", errmsg);
+				}
+			}					/* while rows to fetch */
+			SQLClose(hstmt);
+			break;
+
+			/* searched DELETE, INSERT or searched UPDATE statement */
+		case SQL_DELETE_WHERE:
+		case SQL_INSERT:
+		case SQL_UPDATE_WHERE:
+			/* check rowcount */
+			SQLGetDiagField(SQL_HANDLE_STMT, hstmt, 0,
+						  SQL_DIAG_ROW_COUNT, (SQLPOINTER) & rowcount, 0,
+							(SQLSMALLINT *) NULL);
+			if (SQLEndTran(SQL_HANDLE_ENV, henv, SQL_COMMIT)
+				== SQL_SUCCESS)
+				(void) printf("Operation successful\n");
+			else
+				(void) printf("Operation failed\n");
+			(void) printf("%ld rows affected\n", rowcount);
+			break;
+
+			/* other statements */
+		case SQL_ALTER_TABLE:
+		case SQL_CREATE_TABLE:
+		case SQL_CREATE_VIEW:
+		case SQL_DROP_TABLE:
+		case SQL_DROP_VIEW:
+		case SQL_DYNAMIC_DELETE_CURSOR:
+		case SQL_DYNAMIC_UPDATE_CURSOR:
+		case SQL_GRANT:
+		case SQL_REVOKE:
+			if (SQLEndTran(SQL_HANDLE_ENV, henv, SQL_COMMIT)
+				== SQL_SUCCESS)
+				(void) printf("Operation successful\n");
+			else
+				(void) printf("Operation failed\n");
+			break;
+
+			/* implementation-defined statement */
+		default:
+			(void) printf("Statement type=%ld\n", stmttype);
+			break;
+	}
+
+	/* free data buffers */
+	for (i = 0; i < nresultcols; i++)
+		(void) free(data[i]);
+
+	/* free statement handle */
+	SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
+	/* disconnect from database */
+	SQLDisconnect(hdbc);
+	/* free connection handle */
+	SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
+	/* free environment handle */
+	SQLFreeHandle(SQL_HANDLE_ENV, henv);
+
+	return (0);
 }
 
 /***********************************************************
@@ -202,59 +207,64 @@ example2(SQLCHAR *server, SQLCHAR *uid, SQLCHAR *authen, SQLCHAR *sqlstr)
 /*#define max length of char string representation of no. as:
 
   = max(precision) + leading sign + E + exp sign + max exp length
-  =  15            + 1            + 1 + 1        + 2
+  =  15			   + 1			  + 1 + 1		 + 2
   =  15 + 5
 */
 #define MAX_NUM_STRING_SIZE (MAX_NUM_PRECISION + 5)
 
-SQLINTEGER  display_length(SQLSMALLINT coltype, SQLINTEGER collen,
-			   SQLCHAR *colname)
+SQLINTEGER
+display_length(SQLSMALLINT coltype, SQLINTEGER collen,
+			   SQLCHAR * colname)
 {
-  switch (coltype) {
-
-  case SQL_VARCHAR:
-  case SQL_CHAR:
-    return(max(collen,strlen((char *)colname)));
-    break;
-
-  case SQL_FLOAT:
-  case SQL_DOUBLE:
-  case SQL_NUMERIC:
-  case SQL_REAL:
-  case SQL_DECIMAL:
-    return(max(MAX_NUM_STRING_SIZE,strlen((char *)colname)));
-    break;
-
-  case SQL_DATETIME:
-    return(max(SQL_TIMESTAMP_LEN,strlen((char *)colname)));
-    break;
-
-  case SQL_INTEGER:
-    return(max(10,strlen((char *)colname)));
-    break;
-
-  case SQL_SMALLINT:
-    return(max(5,strlen((char *)colname)));
-    break;
-
-  default:
-    (void)printf("Unknown datatype, %d\n", coltype);
-    return(0);
-    break;
-  }
+	switch (coltype)
+	{
+
+		case SQL_VARCHAR:
+		case SQL_CHAR:
+			return (max(collen, strlen((char *) colname)));
+			break;
+
+		case SQL_FLOAT:
+		case SQL_DOUBLE:
+		case SQL_NUMERIC:
+		case SQL_REAL:
+		case SQL_DECIMAL:
+			return (max(MAX_NUM_STRING_SIZE, strlen((char *) colname)));
+			break;
+
+		case SQL_DATETIME:
+			return (max(SQL_TIMESTAMP_LEN, strlen((char *) colname)));
+			break;
+
+		case SQL_INTEGER:
+			return (max(10, strlen((char *) colname)));
+			break;
+
+		case SQL_SMALLINT:
+			return (max(5, strlen((char *) colname)));
+			break;
+
+		default:
+			(void) printf("Unknown datatype, %d\n", coltype);
+			return (0);
+			break;
+	}
 }
 
-int build_indicator_message(SQLCHAR *errmsg, SQLPOINTER *data,
-			    SQLINTEGER collen, SQLINTEGER *outlen, SQLSMALLINT colnum)
+int
+build_indicator_message(SQLCHAR * errmsg, SQLPOINTER * data,
+			  SQLINTEGER collen, SQLINTEGER * outlen, SQLSMALLINT colnum)
 {
-  if (*outlen ==  SQL_NULL_DATA) {
-    (void)strcpy((char *)data, "NULL");
-    *outlen=4;
-  }
-  else {
-    sprintf((char *)errmsg+strlen((char *)errmsg),
-	    "%d chars truncated, col %d\n", *outlen-collen+1,
-	    colnum);
-    *outlen=255;
-  }
+	if (*outlen == SQL_NULL_DATA)
+	{
+		(void) strcpy((char *) data, "NULL");
+		*outlen = 4;
+	}
+	else
+	{
+		sprintf((char *) errmsg + strlen((char *) errmsg),
+				"%d chars truncated, col %d\n", *outlen - collen + 1,
+				colnum);
+		*outlen = 255;
+	}
 }
diff --git a/src/interfaces/cli/sqlcli.h b/src/interfaces/cli/sqlcli.h
index 243a7cbe2b2569ee93c3481db8bf06e05d792fa1..a9145495fc62612c78cb91d82112d9345805dc34 100644
--- a/src/interfaces/cli/sqlcli.h
+++ b/src/interfaces/cli/sqlcli.h
@@ -13,698 +13,698 @@
  */
 
 /* API declaration data types */
-typedef unsigned char   SQLCHAR;
-typedef long            SQLINTEGER;
-typedef short           SQLSMALLINT;
-typedef double          SQLDOUBLE;
-typedef float           SQLREAL;
-typedef void *          SQLPOINTER;
-typedef unsigned char   SQLDATE;
-typedef unsigned char   SQLTIME;
-typedef unsigned char   SQLTIMESTAMP;
-typedef unsigned char   SQLDECIMAL;
-typedef unsigned char   SQLNUMERIC;
+typedef unsigned char SQLCHAR;
+typedef long SQLINTEGER;
+typedef short SQLSMALLINT;
+typedef double SQLDOUBLE;
+typedef float SQLREAL;
+typedef void *SQLPOINTER;
+typedef unsigned char SQLDATE;
+typedef unsigned char SQLTIME;
+typedef unsigned char SQLTIMESTAMP;
+typedef unsigned char SQLDECIMAL;
+typedef unsigned char SQLNUMERIC;
 
 /* function return type */
-typedef SQLSMALLINT     SQLRETURN;
+typedef SQLSMALLINT SQLRETURN;
 
 /* generic data structures */
-typedef SQLINTEGER      SQLHENV;    /* environment handle */
-typedef SQLINTEGER      SQLHDBC;    /* connection handle */
-typedef SQLINTEGER      SQLHSTMT;   /* statement handle */
-typedef SQLINTEGER      SQLHDESC;   /* descriptor handle */
+typedef SQLINTEGER SQLHENV;		/* environment handle */
+typedef SQLINTEGER SQLHDBC;		/* connection handle */
+typedef SQLINTEGER SQLHSTMT;	/* statement handle */
+typedef SQLINTEGER SQLHDESC;	/* descriptor handle */
 
 /* special length/indicator values */
-#define SQL_NULL_DATA             -1
-#define SQL_DATA_AT_EXEC          -2
+#define SQL_NULL_DATA			  -1
+#define SQL_DATA_AT_EXEC		  -2
 
 /* return values from functions */
-#define SQL_SUCCESS                0
-#define SQL_SUCCESS_WITH_INFO      1
-#define SQL_NEED_DATA             99
-#define SQL_NO_DATA              100
-#define SQL_ERROR                 -1
-#define SQL_INVALID_HANDLE        -2
+#define SQL_SUCCESS				   0
+#define SQL_SUCCESS_WITH_INFO	   1
+#define SQL_NEED_DATA			  99
+#define SQL_NO_DATA				 100
+#define SQL_ERROR				  -1
+#define SQL_INVALID_HANDLE		  -2
 
 /* test for SQL_SUCCESS or SQL_SUCCESS_WITH_INFO */
 #define SQL_SUCCEEDED(rc) (((rc)&(~1))==0)
 
 /* flags for null-terminated string */
-#define SQL_NTS                   -3
-#define SQL_NTSL                  -3L
+#define SQL_NTS					  -3
+#define SQL_NTSL				  -3L
 
 /* maximum message length from Date and Darwen
  * was 255 in the August 1994 draft standard
  * - Thomas Lockhart 1999-06-17
  */
-#define SQL_MAX_MESSAGE_LENGTH   512
+#define SQL_MAX_MESSAGE_LENGTH	 512
 
 /* maximum identifier length */
-#define SQL_MAX_ID_LENGTH         18
+#define SQL_MAX_ID_LENGTH		  18
 
 /* date/time length constants */
 /* add p+1 for time and timestamp if precision is nonzero */
-#define SQL_DATE_LEN              10
-#define SQL_TIME_LEN               8
-#define SQL_TIMESTAMP_LEN         19
+#define SQL_DATE_LEN			  10
+#define SQL_TIME_LEN			   8
+#define SQL_TIMESTAMP_LEN		  19
 
 /* handle type identifiers */
-#define SQL_HANDLE_ENV             1
-#define SQL_HANDLE_DBC             2
-#define SQL_HANDLE_STMT            3
-#define SQL_HANDLE_DESC            4
+#define SQL_HANDLE_ENV			   1
+#define SQL_HANDLE_DBC			   2
+#define SQL_HANDLE_STMT			   3
+#define SQL_HANDLE_DESC			   4
 
 /* environment attribute */
 #define SQL_ATTR_OUTPUT_NTS    10001
 
 /* connection attribute */
-#define SQL_ATTR_AUTO_IPD      10001
+#define SQL_ATTR_AUTO_IPD	   10001
 
 /* statement attributes */
-#define SQL_ATTR_APP_ROW_DESC        10010
-#define SQL_ATTR_APP_PARAM_DESC      10011
-#define SQL_ATTR_IMP_ROW_DESC        10012
-#define SQL_ATTR_IMP_PARAM_DESC      10013
-#define SQL_ATTR_CURSOR_SCROLLABLE      -1
-#define SQL_ATTR_CURSOR_SENSITIVITY     -2
+#define SQL_ATTR_APP_ROW_DESC		 10010
+#define SQL_ATTR_APP_PARAM_DESC		 10011
+#define SQL_ATTR_IMP_ROW_DESC		 10012
+#define SQL_ATTR_IMP_PARAM_DESC		 10013
+#define SQL_ATTR_CURSOR_SCROLLABLE		-1
+#define SQL_ATTR_CURSOR_SENSITIVITY		-2
 
 /* identifiers of fields in the SQL descriptor */
 /* These ran 1-99 in the August 1994 draft standard
  * - Thomas Lockhart 1999-06-17
  */
-#define SQL_DESC_COUNT                        1001
-#define SQL_DESC_TYPE                         1002
-#define SQL_DESC_LENGTH                       1003
-#define SQL_DESC_OCTET_LENGTH_POINTER         1004
-#define SQL_DESC_PRECISION                    1005
-#define SQL_DESC_SCALE                        1006
-#define SQL_DESC_DATETIME_INTERVAL_CODE       1007
-#define SQL_DESC_NULLABLE                     1008
-#define SQL_DESC_INDICATOR_POINTER            1009
-#define SQL_DESC_DATA_POINTER                 1010
-#define SQL_DESC_NAME                         1011
-#define SQL_DESC_UNNAMED                      1012
-#define SQL_DESC_OCTET_LENGTH                 1013
+#define SQL_DESC_COUNT						  1001
+#define SQL_DESC_TYPE						  1002
+#define SQL_DESC_LENGTH						  1003
+#define SQL_DESC_OCTET_LENGTH_POINTER		  1004
+#define SQL_DESC_PRECISION					  1005
+#define SQL_DESC_SCALE						  1006
+#define SQL_DESC_DATETIME_INTERVAL_CODE		  1007
+#define SQL_DESC_NULLABLE					  1008
+#define SQL_DESC_INDICATOR_POINTER			  1009
+#define SQL_DESC_DATA_POINTER				  1010
+#define SQL_DESC_NAME						  1011
+#define SQL_DESC_UNNAMED					  1012
+#define SQL_DESC_OCTET_LENGTH				  1013
 #define SQL_DESC_DATETIME_INTERVAL_PRECISION  1014
-#define SQL_DESC_COLLATION_CATALOG            1015
-#define SQL_DESC_COLLATION_SCHEMA             1016
-#define SQL_DESC_COLLATION_NAME               1017
-#define SQL_DESC_CHARACTER_SET_CATALOG        1018
-#define SQL_DESC_CHARACTER_SET_SCHEMA         1019
-#define SQL_DESC_CHARACTER_SET_NAME           1020
-#define SQL_DESC_PARAMETER_MODE               1021
+#define SQL_DESC_COLLATION_CATALOG			  1015
+#define SQL_DESC_COLLATION_SCHEMA			  1016
+#define SQL_DESC_COLLATION_NAME				  1017
+#define SQL_DESC_CHARACTER_SET_CATALOG		  1018
+#define SQL_DESC_CHARACTER_SET_SCHEMA		  1019
+#define SQL_DESC_CHARACTER_SET_NAME			  1020
+#define SQL_DESC_PARAMETER_MODE				  1021
 #define SQL_DESC_PARAMETER_ORDINAL_POSITION   1022
 #define SQL_DESC_PARAMETER_SPECIFIC_CATALOG   1023
-#define SQL_DESC_PARAMETER_SPECIFIC_SCHEMA    1024
-#define SQL_DESC_PARAMETER_SPECIFIC_NAME      1025
-#define SQL_DESC_ALLOC_TYPE                   1099
+#define SQL_DESC_PARAMETER_SPECIFIC_SCHEMA	  1024
+#define SQL_DESC_PARAMETER_SPECIFIC_NAME	  1025
+#define SQL_DESC_ALLOC_TYPE					  1099
 
 /* identifiers of fields in the diagnostics area */
 /* Many new definitions since August 1994 draft standard
  * - Thomas Lockhart 1999-06-17
  */
-#define SQL_DIAG_RETURNCODE                      1
-#define SQL_DIAG_NUMBER                          2
-#define SQL_DIAG_ROW_COUNT                       3
-#define SQL_DIAG_SQLSTATE                        4
-#define SQL_DIAG_NATIVE                          5
-#define SQL_DIAG_MESSAGE_TEXT                    6
-#define SQL_DIAG_DYNAMIC_FUNCTION                7
-#define SQL_DIAG_CLASS_ORIGIN                    8
-#define SQL_DIAG_SUBCLASS_ORIGIN                 9
-#define SQL_DIAG_CONNECTION_NAME                10
-#define SQL_DIAG_SERVER_NAME                    11
-#define SQL_DIAG_DYNAMIC_FUNCTION_CODE          12
-#define SQL_DIAG_MORE                           13
-#define SQL_DIAG_CONDITION_NUMBER               14
-#define SQL_DIAG_CONSTRAINT_CATALOG             15
-#define SQL_DIAG_CONSTRAINT_SCHEMA              16
-#define SQL_DIAG_CONSTRAINT_NAME                17
-#define SQL_DIAG_CATALOG_NAME                   18
-#define SQL_DIAG_SCHEMA_NAME                    19
-#define SQL_DIAG_TABLE_NAME                     20
-#define SQL_DIAG_COLUMN_NAME                    21
-#define SQL_DIAG_CURSOR_NAME                    22
-#define SQL_DIAG_MESSAGE_LENGTH                 23
-#define SQL_DIAG_MESSAGE_OCTET_LENGTH           24
+#define SQL_DIAG_RETURNCODE						 1
+#define SQL_DIAG_NUMBER							 2
+#define SQL_DIAG_ROW_COUNT						 3
+#define SQL_DIAG_SQLSTATE						 4
+#define SQL_DIAG_NATIVE							 5
+#define SQL_DIAG_MESSAGE_TEXT					 6
+#define SQL_DIAG_DYNAMIC_FUNCTION				 7
+#define SQL_DIAG_CLASS_ORIGIN					 8
+#define SQL_DIAG_SUBCLASS_ORIGIN				 9
+#define SQL_DIAG_CONNECTION_NAME				10
+#define SQL_DIAG_SERVER_NAME					11
+#define SQL_DIAG_DYNAMIC_FUNCTION_CODE			12
+#define SQL_DIAG_MORE							13
+#define SQL_DIAG_CONDITION_NUMBER				14
+#define SQL_DIAG_CONSTRAINT_CATALOG				15
+#define SQL_DIAG_CONSTRAINT_SCHEMA				16
+#define SQL_DIAG_CONSTRAINT_NAME				17
+#define SQL_DIAG_CATALOG_NAME					18
+#define SQL_DIAG_SCHEMA_NAME					19
+#define SQL_DIAG_TABLE_NAME						20
+#define SQL_DIAG_COLUMN_NAME					21
+#define SQL_DIAG_CURSOR_NAME					22
+#define SQL_DIAG_MESSAGE_LENGTH					23
+#define SQL_DIAG_MESSAGE_OCTET_LENGTH			24
 
 /* dynamic function codes returned in diagnostics area */
-#define SQL_DIAG_ALTER_DOMAIN                    3
-#define SQL_DIAG_ALTER_TABLE                     4
-#define SQL_DIAG_CREATE_ASSERTION                6
-#define SQL_DIAG_CREATE_CHARACTER_SET            8
-#define SQL_DIAG_CREATE_COLLATION               10
-#define SQL_DIAG_CREATE_DOMAIN                  23
-#define SQL_DIAG_CREATE_SCHEMA                  64
-#define SQL_DIAG_CREATE_TABLE                   77
-#define SQL_DIAG_CREATE_TRANSLATION             79
-#define SQL_DIAG_CREATE_VIEW                    84
-#define SQL_DIAG_DELETE_WHERE                   19
-#define SQL_DIAG_DROP_ASSERTION                 24
-#define SQL_DIAG_DROP_CHARACTER_SET             25
-#define SQL_DIAG_DROP_COLLATION                 26
-#define SQL_DIAG_DROP_DOMAIN                    27
-#define SQL_DIAG_DROP_SCHEMA                    31
-#define SQL_DIAG_DROP_TABLE                     32
-#define SQL_DIAG_DROP_TRANSLATION               33
-#define SQL_DIAG_DROP_VIEW                      36
-#define SQL_DIAG_DYNAMIC_DELETE_CURSOR          54
-#define SQL_DIAG_DYNAMIC_UPDATE_CURSOR          55
-#define SQL_DIAG_GRANT                          48
-#define SQL_DIAG_INSERT                         50
-#define SQL_DIAG_REVOKE                         59
-#define SQL_DIAG_SELECT                         41
-#define SQL_DIAG_SELECT_CURSOR                  85
-#define SQL_DIAG_SET_CATALOG                    66
-#define SQL_DIAG_SET_CONSTRAINT                 68
-#define SQL_DIAG_SET_NAMES                      72
-#define SQL_DIAG_SET_SCHEMA                     74
-#define SQL_DIAG_SET_SESSION_AUTHORIZATION      76
-#define SQL_DIAG_SET_TIME_ZONE                  71
-#define SQL_DIAG_SET_TRANSACTION                75
-#define SQL_DIAG_UNKNOWN_STATEMENT               0
-#define SQL_DIAG_UPDATE_WHERE                   82
+#define SQL_DIAG_ALTER_DOMAIN					 3
+#define SQL_DIAG_ALTER_TABLE					 4
+#define SQL_DIAG_CREATE_ASSERTION				 6
+#define SQL_DIAG_CREATE_CHARACTER_SET			 8
+#define SQL_DIAG_CREATE_COLLATION				10
+#define SQL_DIAG_CREATE_DOMAIN					23
+#define SQL_DIAG_CREATE_SCHEMA					64
+#define SQL_DIAG_CREATE_TABLE					77
+#define SQL_DIAG_CREATE_TRANSLATION				79
+#define SQL_DIAG_CREATE_VIEW					84
+#define SQL_DIAG_DELETE_WHERE					19
+#define SQL_DIAG_DROP_ASSERTION					24
+#define SQL_DIAG_DROP_CHARACTER_SET				25
+#define SQL_DIAG_DROP_COLLATION					26
+#define SQL_DIAG_DROP_DOMAIN					27
+#define SQL_DIAG_DROP_SCHEMA					31
+#define SQL_DIAG_DROP_TABLE						32
+#define SQL_DIAG_DROP_TRANSLATION				33
+#define SQL_DIAG_DROP_VIEW						36
+#define SQL_DIAG_DYNAMIC_DELETE_CURSOR			54
+#define SQL_DIAG_DYNAMIC_UPDATE_CURSOR			55
+#define SQL_DIAG_GRANT							48
+#define SQL_DIAG_INSERT							50
+#define SQL_DIAG_REVOKE							59
+#define SQL_DIAG_SELECT							41
+#define SQL_DIAG_SELECT_CURSOR					85
+#define SQL_DIAG_SET_CATALOG					66
+#define SQL_DIAG_SET_CONSTRAINT					68
+#define SQL_DIAG_SET_NAMES						72
+#define SQL_DIAG_SET_SCHEMA						74
+#define SQL_DIAG_SET_SESSION_AUTHORIZATION		76
+#define SQL_DIAG_SET_TIME_ZONE					71
+#define SQL_DIAG_SET_TRANSACTION				75
+#define SQL_DIAG_UNKNOWN_STATEMENT				 0
+#define SQL_DIAG_UPDATE_WHERE					82
 
 /* SQL data type codes */
-#define SQL_CHAR          1
-#define SQL_NUMERIC       2
-#define SQL_DECIMAL       3
-#define SQL_INTEGER       4
-#define SQL_SMALLINT      5
-#define SQL_FLOAT         6
-#define SQL_REAL          7
-#define SQL_DOUBLE        8
-#define SQL_DATETIME      9
-#define SQL_INTERVAL     10
-#define SQL_VARCHAR      12
-#define SQL_BIT          14
+#define SQL_CHAR		  1
+#define SQL_NUMERIC		  2
+#define SQL_DECIMAL		  3
+#define SQL_INTEGER		  4
+#define SQL_SMALLINT	  5
+#define SQL_FLOAT		  6
+#define SQL_REAL		  7
+#define SQL_DOUBLE		  8
+#define SQL_DATETIME	  9
+#define SQL_INTERVAL	 10
+#define SQL_VARCHAR		 12
+#define SQL_BIT			 14
 #define SQL_BIT_VARYING  15
 
 /* One-parameter shortcuts for datetime data types */
-#define SQL_TYPE_DATE                      91
-#define SQL_TYPE_TIME                      92
-#define SQL_TYPE_TIME_WITH_TIMEZONE        93
-#define SQL_TYPE_TIMESTAMP                 94
+#define SQL_TYPE_DATE					   91
+#define SQL_TYPE_TIME					   92
+#define SQL_TYPE_TIME_WITH_TIMEZONE		   93
+#define SQL_TYPE_TIMESTAMP				   94
 #define SQL_TYPE_TIMESTAMP_WITH_TIMEZONE   95
-#define SQL_INTERVAL_DAY                  103
-#define SQL_INTERVAL_DAY_TO_HOUR          108
-#define SQL_INTERVAL_DAY_TO_MINUTE        109
-#define SQL_INTERVAL_DAY_TO_SECOND        110
-#define SQL_INTERVAL_HOUR                 104
-#define SQL_INTERVAL_HOUR_TO_MINUTE       111
-#define SQL_INTERVAL_HOUR_TO_SECOND       112
-#define SQL_INTERVAL_MINUTE               105
-#define SQL_INTERVAL_MINUTE_TO_SECOND     113
-#define SQL_INTERVAL_MONTH                102
-#define SQL_INTERVAL_SECOND               106
-#define SQL_INTERVAL_YEAR                 101
-#define SQL_INTERVAL_YEAR_TO_MONTH        107
+#define SQL_INTERVAL_DAY				  103
+#define SQL_INTERVAL_DAY_TO_HOUR		  108
+#define SQL_INTERVAL_DAY_TO_MINUTE		  109
+#define SQL_INTERVAL_DAY_TO_SECOND		  110
+#define SQL_INTERVAL_HOUR				  104
+#define SQL_INTERVAL_HOUR_TO_MINUTE		  111
+#define SQL_INTERVAL_HOUR_TO_SECOND		  112
+#define SQL_INTERVAL_MINUTE				  105
+#define SQL_INTERVAL_MINUTE_TO_SECOND	  113
+#define SQL_INTERVAL_MONTH				  102
+#define SQL_INTERVAL_SECOND				  106
+#define SQL_INTERVAL_YEAR				  101
+#define SQL_INTERVAL_YEAR_TO_MONTH		  107
 
 /* GetTypeInfo request for all data types */
-#define SQL_ALL_TYPES            0
+#define SQL_ALL_TYPES			 0
 
 /* BindCol()  and BindParam() default conversion code */
-#define SQL_DEFAULT             99
+#define SQL_DEFAULT				99
 
 /* GetData code indicating that the application parameter */
 /* descriptor specifies the data type */
-#define SQL_ARD_TYPE           -99
+#define SQL_ARD_TYPE		   -99
 
 /* date/time type subcodes */
-#define SQL_CODE_DATE            1
-#define SQL_CODE_TIME            2
-#define SQL_CODE_TIMESTAMP       3
-#define SQL_CODE_TIME_ZONE       4
+#define SQL_CODE_DATE			 1
+#define SQL_CODE_TIME			 2
+#define SQL_CODE_TIMESTAMP		 3
+#define SQL_CODE_TIME_ZONE		 4
 #define SQL_CODE_TIMESTAMP_ZONE  5
 
 /* interval qualifier codes */
-#define SQL_DAY                  3
-#define SQL_DAY_TO_HOUR          8
-#define SQL_DAY_TO_MINUTE        9
-#define SQL_DAY_TO_SECOND       10
-#define SQL_HOUR                 4
-#define SQL_HOUR_TO_MINUTE      11
-#define SQL_HOUR_TO_SECOND      12
-#define SQL_MINUTE               5
-#define SQL_MINUTE_TO_SECOND    13
-#define SQL_MONTH                2
-#define SQL_SECOND               6
-#define SQL_YEAR                 1
-#define SQL_YEAR_TO_MONTH        7
+#define SQL_DAY					 3
+#define SQL_DAY_TO_HOUR			 8
+#define SQL_DAY_TO_MINUTE		 9
+#define SQL_DAY_TO_SECOND		10
+#define SQL_HOUR				 4
+#define SQL_HOUR_TO_MINUTE		11
+#define SQL_HOUR_TO_SECOND		12
+#define SQL_MINUTE				 5
+#define SQL_MINUTE_TO_SECOND	13
+#define SQL_MONTH				 2
+#define SQL_SECOND				 6
+#define SQL_YEAR				 1
+#define SQL_YEAR_TO_MONTH		 7
 
 /* CLI option values */
-#define SQL_FALSE                0
-#define SQL_TRUE                 1
-#define SQL_NONSCROLLABLE        0
-#define SQL_SCROLLABLE           1
+#define SQL_FALSE				 0
+#define SQL_TRUE				 1
+#define SQL_NONSCROLLABLE		 0
+#define SQL_SCROLLABLE			 1
 
 /* parameter modes */
-#define SQL_PARAM_MODE_IN        1
-#define SQL_PARAM_MODE_OUT       4
-#define SQL_PARAM_MODE_INOUT     2
-#define SQL_PARAM_MODE_NONE      0
+#define SQL_PARAM_MODE_IN		 1
+#define SQL_PARAM_MODE_OUT		 4
+#define SQL_PARAM_MODE_INOUT	 2
+#define SQL_PARAM_MODE_NONE		 0
 
 /* values of NULLABLE field in descriptor */
-#define SQL_NO_NULLS             0
-#define SQL_NULLABLE             1
+#define SQL_NO_NULLS			 0
+#define SQL_NULLABLE			 1
 
-/*      Values returned by GetTypeInfo for the SEARCHABLE column */
-#define SQL_PRED_NONE            0
-#define SQL_PRED_CHAR            1
-#define SQL_PRED_BASIC           2
+/*		Values returned by GetTypeInfo for the SEARCHABLE column */
+#define SQL_PRED_NONE			 0
+#define SQL_PRED_CHAR			 1
+#define SQL_PRED_BASIC			 2
 
 /* values of UNNAMED field in descriptor */
-#define SQL_NAMED                0
-#define SQL_UNNAMED              1
+#define SQL_NAMED				 0
+#define SQL_UNNAMED				 1
 
 /* values of ALLOC_TYPE field in descriptor */
-#define SQL_DESC_ALLOC_AUTO      1
-#define SQL_DESC_ALLOC_USER      2
+#define SQL_DESC_ALLOC_AUTO		 1
+#define SQL_DESC_ALLOC_USER		 2
 
 /* EndTran()  options */
-#define SQL_COMMIT               0
-#define SQL_ROLLBACK             1
+#define SQL_COMMIT				 0
+#define SQL_ROLLBACK			 1
 
 /* FreeStmt()  options */
-#define SQL_CLOSE                0
-#define SQL_DROP                 1
-#define SQL_UNBIND               2
-#define SQL_RESET_PARAMS         3
+#define SQL_CLOSE				 0
+#define SQL_DROP				 1
+#define SQL_UNBIND				 2
+#define SQL_RESET_PARAMS		 3
 
 /* null handles returned by AllocHandle() */
-#define SQL_NULL_HENV            0
-#define SQL_NULL_HDBC            0
-#define SQL_NULL_HSTMT           0
-#define SQL_NULL_HDESC           0
+#define SQL_NULL_HENV			 0
+#define SQL_NULL_HDBC			 0
+#define SQL_NULL_HSTMT			 0
+#define SQL_NULL_HDESC			 0
 
 /* GetFunctions values to identify CLI routines */
-#define SQL_API_SQLALLOCCONNECT         1
-#define SQL_API_SQLALLOCENV             2
-#define SQL_API_SQLALLOCHANDLE       1001
-#define SQL_API_SQLALLOCSTMT            3
-#define SQL_API_SQLBINDCOL              4
-#define SQL_API_SQLBINDPARAM         1002
-#define SQL_API_SQLCANCEL               5
-#define SQL_API_SQLCLOSECURSOR       1003
-#define SQL_API_SQLCOLATTRIBUTE         6
-#define SQL_API_SQLCONNECT              7
-#define SQL_API_SQLCOPYDESC          1004
-#define SQL_API_SQLDATASOURCES         57
-#define SQL_API_SQLDESCRIBECOL          8
-#define SQL_API_SQLDISCONNECT           9
-#define SQL_API_SQLENDTRAN           1005
-#define SQL_API_SQLERROR               10
-#define SQL_API_SQLEXECDIRECT          11
-#define SQL_API_SQLEXECUTE             12
-#define SQL_API_SQLFETCH               13
-#define SQL_API_SQLFETCHSCROLL       1021
-#define SQL_API_SQLFREECONNECT         14
-#define SQL_API_SQLFREEENV             15
-#define SQL_API_SQLFREEHANDLE        1006
-#define SQL_API_SQLFREESTMT            16
-#define SQL_API_SQLGETCONNECTATTR    1007
-#define SQL_API_SQLGETCURSORNAME       17
-#define SQL_API_SQLGETDATA             43
-#define SQL_API_SQLGETDESCFIELD      1008
-#define SQL_API_SQLGETDESCREC        1009
-#define SQL_API_SQLGETDIAGFIELD      1010
-#define SQL_API_SQLGETDIAGREC        1011
-#define SQL_API_SQLGETENVATTR        1012
-#define SQL_API_SQLGETFUNCTIONS        44
-#define SQL_API_SQLGETINFO             45
-#define SQL_API_SQLGETSTMTATTR       1014
-#define SQL_API_SQLGETTYPEINFO         47
-#define SQL_API_SQLNUMRESULTCOLS       18
-#define SQL_API_SQLPARAMDATA           48
-#define SQL_API_SQLPREPARE             19
-#define SQL_API_SQLPUTDATA             49
-#define SQL_API_SQLRELEASEENV        1015  /* Obsolete? */
-#define SQL_API_SQLROWCOUNT            20
-#define SQL_API_SQLSCROLLFETCH       1021  /* Obsolete? */
-#define SQL_API_SQLSETCONNECTATTR    1016
-#define SQL_API_SQLSETCURSORNAME       21
-#define SQL_API_SQLSETDESCFIELD      1017
-#define SQL_API_SQLSETDESCREC        1018
-#define SQL_API_SQLSETENVATTR        1019
-#define SQL_API_SQLSETSTMTATTR       1020
+#define SQL_API_SQLALLOCCONNECT			1
+#define SQL_API_SQLALLOCENV				2
+#define SQL_API_SQLALLOCHANDLE		 1001
+#define SQL_API_SQLALLOCSTMT			3
+#define SQL_API_SQLBINDCOL				4
+#define SQL_API_SQLBINDPARAM		 1002
+#define SQL_API_SQLCANCEL				5
+#define SQL_API_SQLCLOSECURSOR		 1003
+#define SQL_API_SQLCOLATTRIBUTE			6
+#define SQL_API_SQLCONNECT				7
+#define SQL_API_SQLCOPYDESC			 1004
+#define SQL_API_SQLDATASOURCES		   57
+#define SQL_API_SQLDESCRIBECOL			8
+#define SQL_API_SQLDISCONNECT			9
+#define SQL_API_SQLENDTRAN			 1005
+#define SQL_API_SQLERROR			   10
+#define SQL_API_SQLEXECDIRECT		   11
+#define SQL_API_SQLEXECUTE			   12
+#define SQL_API_SQLFETCH			   13
+#define SQL_API_SQLFETCHSCROLL		 1021
+#define SQL_API_SQLFREECONNECT		   14
+#define SQL_API_SQLFREEENV			   15
+#define SQL_API_SQLFREEHANDLE		 1006
+#define SQL_API_SQLFREESTMT			   16
+#define SQL_API_SQLGETCONNECTATTR	 1007
+#define SQL_API_SQLGETCURSORNAME	   17
+#define SQL_API_SQLGETDATA			   43
+#define SQL_API_SQLGETDESCFIELD		 1008
+#define SQL_API_SQLGETDESCREC		 1009
+#define SQL_API_SQLGETDIAGFIELD		 1010
+#define SQL_API_SQLGETDIAGREC		 1011
+#define SQL_API_SQLGETENVATTR		 1012
+#define SQL_API_SQLGETFUNCTIONS		   44
+#define SQL_API_SQLGETINFO			   45
+#define SQL_API_SQLGETSTMTATTR		 1014
+#define SQL_API_SQLGETTYPEINFO		   47
+#define SQL_API_SQLNUMRESULTCOLS	   18
+#define SQL_API_SQLPARAMDATA		   48
+#define SQL_API_SQLPREPARE			   19
+#define SQL_API_SQLPUTDATA			   49
+#define SQL_API_SQLRELEASEENV		 1015		/* Obsolete? */
+#define SQL_API_SQLROWCOUNT			   20
+#define SQL_API_SQLSCROLLFETCH		 1021		/* Obsolete? */
+#define SQL_API_SQLSETCONNECTATTR	 1016
+#define SQL_API_SQLSETCURSORNAME	   21
+#define SQL_API_SQLSETDESCFIELD		 1017
+#define SQL_API_SQLSETDESCREC		 1018
+#define SQL_API_SQLSETENVATTR		 1019
+#define SQL_API_SQLSETSTMTATTR		 1020
 
 /* information requested by GetInfo */
-#define SQL_MAXIMUM_DRIVER_CONNECTIONS      0
-#define SQL_MAXIMUM_CONCURRENT_ACTIVITIES   1
-#define SQL_DATA_SOURCE_NAME                2
-#define SQL_FETCH_DIRECTION                 8
-#define SQL_SERVER_NAME                    13
-#define SQL_DBMS_NAME                      17
-#define SQL_DBMS_VERSION                   18
-#define SQL_CURSOR_COMMIT_BEHAVIOR         23
-#define SQL_DATA_SOURCE_READ_ONLY          25
+#define SQL_MAXIMUM_DRIVER_CONNECTIONS		0
+#define SQL_MAXIMUM_CONCURRENT_ACTIVITIES	1
+#define SQL_DATA_SOURCE_NAME				2
+#define SQL_FETCH_DIRECTION					8
+#define SQL_SERVER_NAME					   13
+#define SQL_DBMS_NAME					   17
+#define SQL_DBMS_VERSION				   18
+#define SQL_CURSOR_COMMIT_BEHAVIOR		   23
+#define SQL_DATA_SOURCE_READ_ONLY		   25
 #define SQL_DEFAULT_TRANSACTION_ISOLATION  26
-#define SQL_IDENTIFIER_CASE                28
-#define SQL_MAXIMUM_COLUMN_NAME_LENGTH     30
-#define SQL_MAXIMUM_CURSOR_NAME_LENGTH     31
-#define SQL_MAXIMUM_SCHEMA_NAME_LENGTH     32
+#define SQL_IDENTIFIER_CASE				   28
+#define SQL_MAXIMUM_COLUMN_NAME_LENGTH	   30
+#define SQL_MAXIMUM_CURSOR_NAME_LENGTH	   31
+#define SQL_MAXIMUM_SCHEMA_NAME_LENGTH	   32
 #define SQL_MAXIMUM_CATALOG_NAME_LENGTH    34
-#define SQL_MAXIMUM_TABLE_NAME_LENGTH      35
-#define SQL_SCROLL_CONCURRENCY             43
-#define SQL_TRANSACTION_CAPABLE            46
-#define SQL_USER_NAME                      47
+#define SQL_MAXIMUM_TABLE_NAME_LENGTH	   35
+#define SQL_SCROLL_CONCURRENCY			   43
+#define SQL_TRANSACTION_CAPABLE			   46
+#define SQL_USER_NAME					   47
 #define SQL_TRANSACTION_ISOLATION_OPTION   72
-#define SQL_INTEGRITY                      73
-#define SQL_GETDATA_EXTENSIONS             81
-#define SQL_NULL_COLLATION                 85
-#define SQL_ALTER_TABLE                    86
-#define SQL_ORDER_BY_COLUMNS_IN_SELECT     90
-#define SQL_SPECIAL_CHARACTERS             94
+#define SQL_INTEGRITY					   73
+#define SQL_GETDATA_EXTENSIONS			   81
+#define SQL_NULL_COLLATION				   85
+#define SQL_ALTER_TABLE					   86
+#define SQL_ORDER_BY_COLUMNS_IN_SELECT	   90
+#define SQL_SPECIAL_CHARACTERS			   94
 #define SQL_MAXIMUM_COLUMNS_IN_GROUP_BY    97
 #define SQL_MAXIMUM_COLUMNS_IN_ORDER_BY    99
-#define SQL_MAXIMUM_COLUMNS_IN_SELECT     100
-#define SQL_MAXIMUM_COLUMNS_IN_TABLE      101
-#define SQL_MAXIMUM_STATEMENT_LENGTH      105
-#define SQL_MAXIMUM_TABLES_IN_SELECT      106
-#define SQL_MAXIMUM_USER_NAME_LENGTH      107
-#define SQL_OUTER_JOIN_CAPABILITIES       115
-#define SQL_CURSOR_SENSITIVITY          10001
-#define SQL_DESCRIBE_PARAMETER          10002
-#define SQL_CATALOG_NAME                10003
-#define SQL_COLLATING_SEQUENCE          10004
-#define SQL_MAXIMUM_IDENTIFIER_LENGTH   10005
+#define SQL_MAXIMUM_COLUMNS_IN_SELECT	  100
+#define SQL_MAXIMUM_COLUMNS_IN_TABLE	  101
+#define SQL_MAXIMUM_STATEMENT_LENGTH	  105
+#define SQL_MAXIMUM_TABLES_IN_SELECT	  106
+#define SQL_MAXIMUM_USER_NAME_LENGTH	  107
+#define SQL_OUTER_JOIN_CAPABILITIES		  115
+#define SQL_CURSOR_SENSITIVITY			10001
+#define SQL_DESCRIBE_PARAMETER			10002
+#define SQL_CATALOG_NAME				10003
+#define SQL_COLLATING_SEQUENCE			10004
+#define SQL_MAXIMUM_IDENTIFIER_LENGTH	10005
 
 /* S-resource attribute values for cursor sensitivity */
-#define SQL_UNSPECIFIED           0x00000000L
-#define SQL_INSENSITIVE           0x00000001L
+#define SQL_UNSPECIFIED			  0x00000000L
+#define SQL_INSENSITIVE			  0x00000001L
 
 /* null handle used when allocating HENV */
-#define SQL_NULL_HANDLE                    0L
+#define SQL_NULL_HANDLE					   0L
 
 /* SQL_ALTER_TABLE bitmasks */
-#define SQL_AT_ADD_COLUMN         0x00000001L
-#define SQL_AT_DROP_COLUMN        0x00000002L
-#define SQL_AT_ALTER_COLUMN       0x00000004L
-#define SQL_AT_ADD_CONSTRAINT     0x00000008L
-#define SQL_AT_DROP_CONSTRAINT    0x00000010L
+#define SQL_AT_ADD_COLUMN		  0x00000001L
+#define SQL_AT_DROP_COLUMN		  0x00000002L
+#define SQL_AT_ALTER_COLUMN		  0x00000004L
+#define SQL_AT_ADD_CONSTRAINT	  0x00000008L
+#define SQL_AT_DROP_CONSTRAINT	  0x00000010L
 
 /* SQL_CURSOR_COMMIT_BEHAVIOR values */
-#define SQL_CB_DELETE                       0
-#define SQL_CB_CLOSE                        1
-#define SQL_CB_PRESERVE                     2
+#define SQL_CB_DELETE						0
+#define SQL_CB_CLOSE						1
+#define SQL_CB_PRESERVE						2
 
 /* SQL_FETCH_DIRECTION bitmasks */
-#define SQL_FD_FETCH_NEXT         0x00000001L
-#define SQL_FD_FETCH_FIRST        0x00000002L
-#define SQL_FD_FETCH_LAST         0x00000004L
-#define SQL_FD_FETCH_PRIOR        0x00000008L
-#define SQL_FD_FETCH_ABSOLUTE     0x00000010L
-#define SQL_FD_FETCH_RELATIVE     0x00000020L
+#define SQL_FD_FETCH_NEXT		  0x00000001L
+#define SQL_FD_FETCH_FIRST		  0x00000002L
+#define SQL_FD_FETCH_LAST		  0x00000004L
+#define SQL_FD_FETCH_PRIOR		  0x00000008L
+#define SQL_FD_FETCH_ABSOLUTE	  0x00000010L
+#define SQL_FD_FETCH_RELATIVE	  0x00000020L
 
 /* SQL_GETDATA_EXTENSIONS bitmasks */
-#define SQL_GD_ANY_COLUMN         0x00000001L
-#define SQL_FD_ANY_ORDER          0x00000002L
+#define SQL_GD_ANY_COLUMN		  0x00000001L
+#define SQL_FD_ANY_ORDER		  0x00000002L
 
 /* SQL_IDENTIFIER_CASE values */
-#define SQL_IC_UPPER                        1
-#define SQL_IC_LOWER                        2
-#define SQL_IC_SENSITIVE                    3
-#define SQL_IC_MIXED                        4
+#define SQL_IC_UPPER						1
+#define SQL_IC_LOWER						2
+#define SQL_IC_SENSITIVE					3
+#define SQL_IC_MIXED						4
 
 /* SQL_IDENTIFIER_CASE values */
-#define SQL_NC_HIGH                         1
-#define SQL_NC_LOW                          2
+#define SQL_NC_HIGH							1
+#define SQL_NC_LOW							2
 
 /* SQL_OUTER_JOIN_CAPABILITIES bitmasks */
-#define SQL_OUTER_JOIN_LEFT                   0x00000001L
-#define SQL_OUTER_JOIN_RIGHT                  0x00000002L
-#define SQL_OUTER_JOIN_FULL                   0x00000004L
-#define SQL_OUTER_JOIN_NESTED                 0x00000008L
-#define SQL_OUTER_JOIN_NOT_ORDERED            0x00000010L
-#define SQL_OUTER_JOIN_INNER                  0x00000020L
-#define SQL_OUTER_JOIN_ALL_COMPARISION_OPS    0x00000040L
+#define SQL_OUTER_JOIN_LEFT					  0x00000001L
+#define SQL_OUTER_JOIN_RIGHT				  0x00000002L
+#define SQL_OUTER_JOIN_FULL					  0x00000004L
+#define SQL_OUTER_JOIN_NESTED				  0x00000008L
+#define SQL_OUTER_JOIN_NOT_ORDERED			  0x00000010L
+#define SQL_OUTER_JOIN_INNER				  0x00000020L
+#define SQL_OUTER_JOIN_ALL_COMPARISION_OPS	  0x00000040L
 
 /* SQL_SCROLL_CONCURRENCY bitmasks */
-#define SQL_SCCO_READ_ONLY                    0x00000001L
-#define SQL_SCCO_LOCK                         0x00000002L
-#define SQL_SCCO_OPT_ROWVER                   0x00000004L
-#define SQL_SCCO_OPT_VALUES                   0x00000008L
+#define SQL_SCCO_READ_ONLY					  0x00000001L
+#define SQL_SCCO_LOCK						  0x00000002L
+#define SQL_SCCO_OPT_ROWVER					  0x00000004L
+#define SQL_SCCO_OPT_VALUES					  0x00000008L
 
 /* SQL_IDENTIFIER_CASE values */
-#define SQL_TC_NONE                         0
-#define SQL_TC_DML                          1
-#define SQL_TC_ALL                          2
-#define SQL_TC_DDL_COMMIT                   3
-#define SQL_TC_DDL_IGNORE                   4
+#define SQL_TC_NONE							0
+#define SQL_TC_DML							1
+#define SQL_TC_ALL							2
+#define SQL_TC_DDL_COMMIT					3
+#define SQL_TC_DDL_IGNORE					4
 
 /* SQL_TRANSACTION_ISOLATION bitmasks */
-#define SQL_TRANSACTION_READ_UNCOMMITTED      0x00000001L
-#define SQL_TRANSACTION_READ_COMMITTED        0x00000002L
+#define SQL_TRANSACTION_READ_UNCOMMITTED	  0x00000001L
+#define SQL_TRANSACTION_READ_COMMITTED		  0x00000002L
 #define SQL_TRANSACTION_READ_REPEATABLE_READ  0x00000004L
-#define SQL_TRANSACTION_READ_SERIALIZABLE     0x00000008L
+#define SQL_TRANSACTION_READ_SERIALIZABLE	  0x00000008L
 
 
 
-#define SQL_TRANSACTION_READ_UNCOMMITTED    0x00000001L
-#define SQL_TRANSACTION_READ_UNCOMMITTED    0x00000001L
-#define SQL_FD_FETCH_NEXT         0x00000001L
+#define SQL_TRANSACTION_READ_UNCOMMITTED	0x00000001L
+#define SQL_TRANSACTION_READ_UNCOMMITTED	0x00000001L
+#define SQL_FD_FETCH_NEXT		  0x00000001L
 
 /* CLI function signatures */
 
-SQLRETURN  SQLAllocConnect(SQLHENV EnvironmentHandle,
-			   SQLHDBC *ConnectionHandle);
+SQLRETURN SQLAllocConnect(SQLHENV EnvironmentHandle,
+				SQLHDBC * ConnectionHandle);
 
-SQLRETURN  SQLAllocEnv(SQLHENV *EnvironmentHandle);
+SQLRETURN	SQLAllocEnv(SQLHENV * EnvironmentHandle);
 
-SQLRETURN  SQLAllocHandle(SQLSMALLINT HandleType,
-			  SQLINTEGER InputHandle,
-			  SQLINTEGER *OutputHandle);
+SQLRETURN SQLAllocHandle(SQLSMALLINT HandleType,
+			   SQLINTEGER InputHandle,
+			   SQLINTEGER * OutputHandle);
 
-SQLRETURN  SQLAllocStmt(SQLHDBC ConnectionHandle,
-                         SQLSTMT *StatementHandle);
+SQLRETURN SQLAllocStmt(SQLHDBC ConnectionHandle,
+			 SQLSTMT * StatementHandle);
 
-SQLRETURN  SQLBindCol(SQLHSTMT StatementHandle,
-		      SQLSMALLINT ColumnNumber,
-		      SQLSMALLINT BufferType,
-		      SQLPOINTER Data,
-		      SQLINTEGER BufferLength,
-		      SQLINTEGER *DataLength);
+SQLRETURN SQLBindCol(SQLHSTMT StatementHandle,
+		   SQLSMALLINT ColumnNumber,
+		   SQLSMALLINT BufferType,
+		   SQLPOINTER Data,
+		   SQLINTEGER BufferLength,
+		   SQLINTEGER * DataLength);
 
-SQLRETURN  SQLBindParam(SQLHSTMT StatementHandle,
-			SQLSMALLINT ParamNumber,
-			SQLSMALLINT BufferType,
-			SQLSMALLINT ParamType,
-			SQLINTEGER ParamLength,
-			SQLSMALLINT Scale,
-			SQLPOINTER Data,
-			SQLINTEGER *DataLength);
-
-SQLRETURN  SQLCancel(SQLHSTMT StatementHandle);
-
-SQLRETURN  SQLCloseCursor(SQLHSTMT StatementHandle);
-
-SQLRETURN  SQLColAttribute(SQLHSTMT StatementHandle,
+SQLRETURN SQLBindParam(SQLHSTMT StatementHandle,
+			 SQLSMALLINT ParamNumber,
+			 SQLSMALLINT BufferType,
+			 SQLSMALLINT ParamType,
+			 SQLINTEGER ParamLength,
+			 SQLSMALLINT Scale,
+			 SQLPOINTER Data,
+			 SQLINTEGER * DataLength);
+
+SQLRETURN	SQLCancel(SQLHSTMT StatementHandle);
+
+SQLRETURN	SQLCloseCursor(SQLHSTMT StatementHandle);
+
+SQLRETURN SQLColAttribute(SQLHSTMT StatementHandle,
+				SQLSMALLINT ColumnNumber,
+				SQLSMALLINT FieldIdentifier,
+				SQLCHAR * CharacterAttribute,
+				SQLINTEGER BufferLength,
+				SQLINTEGER * AttributetLength,
+				SQLINTEGER * NumericAttribute);
+
+SQLRETURN SQLConnect(SQLHDBC ConnectionHandle,
+		   SQLCHAR * ServerName,
+		   SQLSMALLINT NameLength1,
+		   SQLCHAR * UserName,
+		   SQLSMALLINT NameLength2,
+		   SQLCHAR * Authentication,
+		   SQLSMALLINT NameLength3);
+
+SQLRETURN SQLCopyDesc(SQLHDESC SourceDescHandle,
+			SQLHDESC TargetDescHandle);
+
+SQLRETURN SQLDataSources(SQLHENV EnvironmentHandle,
+			   SQLSMALLINT Direction,
+			   SQLCHAR * ServerName,
+			   SQLSMALLINT BufferLength1,
+			   SQLSMALLINT * NameLength1,
+			   SQLCHAR * Description,
+			   SQLSMALLINT BufferLength2,
+			   SQLSMALLINT * NameLength2);
+
+SQLRETURN SQLDescribeCol(SQLHSTMT StatementHandle,
 			   SQLSMALLINT ColumnNumber,
-			   SQLSMALLINT FieldIdentifier,
-			   SQLCHAR *CharacterAttribute,
-			   SQLINTEGER BufferLength,
-			   SQLINTEGER *AttributetLength,
-			   SQLINTEGER *NumericAttribute);
-
-SQLRETURN  SQLConnect(SQLHDBC ConnectionHandle,
-		      SQLCHAR *ServerName,
-		      SQLSMALLINT NameLength1,
-		      SQLCHAR *UserName,
-		      SQLSMALLINT NameLength2,
-		      SQLCHAR *Authentication,
-		      SQLSMALLINT NameLength3);
-
-SQLRETURN  SQLCopyDesc(SQLHDESC SourceDescHandle,
-		       SQLHDESC TargetDescHandle);
-
-SQLRETURN  SQLDataSources(SQLHENV EnvironmentHandle,
-			  SQLSMALLINT Direction,
-			  SQLCHAR *ServerName,
-			  SQLSMALLINT BufferLength1,
-			  SQLSMALLINT *NameLength1,
-			  SQLCHAR *Description,
-			  SQLSMALLINT BufferLength2,
-			  SQLSMALLINT *NameLength2);
-
-SQLRETURN  SQLDescribeCol(SQLHSTMT StatementHandle,
-			  SQLSMALLINT ColumnNumber,
-			  SQLCHAR *ColumnName,
+			   SQLCHAR * ColumnName,
+			   SQLSMALLINT BufferLength,
+			   SQLSMALLINT * ColumnNameLength,
+			   SQLSMALLINT * ColumnType,
+			   SQLINTEGER * ColumnLength,
+			   SQLSMALLINT * ColumnScale,
+			   SQLSMALLINT * Nullable);
+
+SQLRETURN	SQLDisconnect(SQLHDBC ConnectionHandle);
+
+SQLRETURN SQLEndTran(SQLSMALLINT HandleType,
+		   SQLHENV Handle,
+		   SQLSMALLINT CompletionType);
+
+SQLRETURN SQLError(SQLHENV EnvironmentHandle,
+		 SQLHDBC ConnectionHandle,
+		 SQLSTMT StatementHandle,
+		 SQLCHAR * Sqlstate,
+		 SQLINTEGER * NativeError,
+		 SQLCHAR * MessageText,
+		 SQLINTEGER BufferLength,
+		 SQLINTEGER * TextLength);
+
+SQLRETURN SQLExecDirect(SQLHSTMT StatementHandle,
+			  SQLCHAR * StatementText,
+			  SQLSMALLINT StringLength);
+
+SQLRETURN	SQLExecute(SQLHSTMT StatementHandle);
+
+SQLRETURN	SQLFetch(SQLHSTMT StatementHandle);
+
+SQLRETURN SQLFetchScroll(SQLHSTMT StatementHandle,
+			   SQLSMALLINT FetchOrientation,
+			   SQLINTEGER FetchOffset);
+
+SQLRETURN	SQLFreeConnect(SQLHDBC ConnectionHandle);
+
+SQLRETURN	SQLFreeEnv(SQLHENV EnvironmentHandle);
+
+SQLRETURN SQLFreeHandle(SQLSMALLINT HandleType,
+			  SQLINTEGER Handle);
+
+SQLRETURN	SQLFreeStmt(SQLHSTMT StatementHandle);
+
+SQLRETURN SQLGetConnectAttr(SQLHDBC ConnectionHandle,
+				  SQLINTEGER Attribute,
+				  SQLPOINTER Value,
+				  SQLINTEGER BufferLength,
+				  SQLINTEGER * StringLength);
+
+SQLRETURN SQLGetCursorName(SQLHSTMT StatementHandle,
+				 SQLCHAR * CursorName,
+				 SQLSMALLINT BufferLength,
+				 SQLSMALLINT * NameLength);
+
+SQLRETURN SQLGetData(SQLHSTMT StatementHandle,
+		   SQLSMALLINT ColumnNumber,
+		   SQLSMALLINT TargetType,
+		   SQLPOINTER TargetValue,
+		   SQLINTEGER BufferLength,
+		   SQLINTEGER * IndicatorValue);
+
+SQLRETURN SQLGetDescField(SQLHDESC DescriptorHandle,
+				SQLSMALLINT RecordNumber,
+				SQLSMALLINT FieldIdentifier,
+				SQLPOINTER Value,
+				SQLINTEGER BufferLength,
+				SQLINTEGER * StringLength);
+
+SQLRETURN SQLGetDescRec(SQLHDESC DescriptorHandle,
+			  SQLSMALLINT RecordNumber,
+			  SQLCHAR * Name,
 			  SQLSMALLINT BufferLength,
-			  SQLSMALLINT *ColumnNameLength,
-			  SQLSMALLINT *ColumnType,
-			  SQLINTEGER *ColumnLength,
-			  SQLSMALLINT *ColumnScale,
-			  SQLSMALLINT *Nullable);
-
-SQLRETURN  SQLDisconnect(SQLHDBC ConnectionHandle);
-
-SQLRETURN  SQLEndTran(SQLSMALLINT HandleType,
-		      SQLHENV Handle,
-		      SQLSMALLINT CompletionType);
-
-SQLRETURN  SQLError(SQLHENV EnvironmentHandle,
-		    SQLHDBC ConnectionHandle,
-		    SQLSTMT StatementHandle,
-		    SQLCHAR *Sqlstate,
-		    SQLINTEGER *NativeError,
-		    SQLCHAR *MessageText,
-		    SQLINTEGER BufferLength,
-		    SQLINTEGER *TextLength);
-
-SQLRETURN  SQLExecDirect(SQLHSTMT StatementHandle,
-                         SQLCHAR *StatementText,
-			 SQLSMALLINT StringLength);
-
-SQLRETURN  SQLExecute(SQLHSTMT StatementHandle);
-
-SQLRETURN  SQLFetch(SQLHSTMT StatementHandle);
-
-SQLRETURN  SQLFetchScroll(SQLHSTMT StatementHandle,
-			  SQLSMALLINT FetchOrientation,
-			  SQLINTEGER FetchOffset);
-
-SQLRETURN  SQLFreeConnect(SQLHDBC ConnectionHandle);
-
-SQLRETURN  SQLFreeEnv(SQLHENV EnvironmentHandle);
-
-SQLRETURN  SQLFreeHandle(SQLSMALLINT HandleType,
-                         SQLINTEGER Handle);
-
-SQLRETURN  SQLFreeStmt(SQLHSTMT StatementHandle);
+			  SQLSMALLINT * StringLength,
+			  SQLSMALLINT * Type,
+			  SQLSMALLINT * SubType,
+			  SQLINTEGER * Length,
+			  SQLSMALLINT * Precision,
+			  SQLSMALLINT * Scale,
+			  SQLSMALLINT * Nullable);
+
+SQLRETURN SQLGetDiagField(SQLSMALLINT HandleType,
+				SQLINTEGER Handle,
+				SQLSMALLINT RecordNumber,
+				SQLSMALLINT DiagIdentifier,
+				SQLPOINTER DiagInfo,
+				SQLSMALLINT BufferLength,
+				SQLSMALLINT * StringLength);
+
+
+SQLRETURN SQLGetDiagRec(SQLSMALLINT HandleType,
+			  SQLINTEGER Handle,
+			  SQLSMALLINT RecordNumber,
+			  SQLCHAR * Sqlstate,
+			  SQLINTEGER * NativeError,
+			  SQLCHAR * MessageText,
+			  SQLSMALLINT BufferLength,
+			  SQLSMALLINT * StringLength);
 
-SQLRETURN  SQLGetConnectAttr(SQLHDBC ConnectionHandle,
-			     SQLINTEGER Attribute,
-			     SQLPOINTER Value,
-			     SQLINTEGER BufferLength,
-			     SQLINTEGER *StringLength);
+SQLRETURN SQLGetEnvAttr(SQLHENV EnvironmentHandle,
+			  SQLINTEGER Attribute,
+			  SQLPOINTER Value,
+			  SQLINTEGER BufferLength,
+			  SQLINTEGER * StringLength);
 
-SQLRETURN  SQLGetCursorName(SQLHSTMT StatementHandle,
-			    SQLCHAR *CursorName,
-			    SQLSMALLINT BufferLength,
-			    SQLSMALLINT *NameLength);
+SQLRETURN SQLGetFunctions(SQLHDBC ConnectionHandle,
+				SQLSMALLINT FunctionId,
+				SQLSMALLINT * Supported);
 
-SQLRETURN  SQLGetData(SQLHSTMT StatementHandle,
-		      SQLSMALLINT ColumnNumber,
-		      SQLSMALLINT TargetType,
-		      SQLPOINTER TargetValue,
-		      SQLINTEGER BufferLength,
-		      SQLINTEGER *IndicatorValue);
+SQLRETURN SQLGetInfo(SQLHDBC ConnectionHandle,
+		   SQLSMALLINT InfoType,
+		   SQLPOINTER InfoValue,
+		   SQLSMALLINT BufferLength,
+		   SQLSMALLINT * StringLength);
 
-SQLRETURN  SQLGetDescField(SQLHDESC DescriptorHandle,
-			   SQLSMALLINT RecordNumber,
-			   SQLSMALLINT FieldIdentifier,
+SQLRETURN SQLGetStmtAttr(SQLHSTMT StatementHandle,
+			   SQLINTEGER Attribute,
 			   SQLPOINTER Value,
 			   SQLINTEGER BufferLength,
-			   SQLINTEGER *StringLength);
-
-SQLRETURN  SQLGetDescRec(SQLHDESC DescriptorHandle,
-                         SQLSMALLINT RecordNumber,
-			 SQLCHAR *Name,
-                         SQLSMALLINT BufferLength,
-			 SQLSMALLINT *StringLength,
-                         SQLSMALLINT *Type,
-			 SQLSMALLINT *SubType,
-                         SQLINTEGER *Length,
-			 SQLSMALLINT *Precision,
-                         SQLSMALLINT *Scale,
-			 SQLSMALLINT *Nullable);
-
-SQLRETURN  SQLGetDiagField(SQLSMALLINT HandleType,
-			   SQLINTEGER Handle,
-			   SQLSMALLINT RecordNumber,
-			   SQLSMALLINT DiagIdentifier,
-			   SQLPOINTER DiagInfo,
-			   SQLSMALLINT BufferLength,
-			   SQLSMALLINT *StringLength);
-
-
-SQLRETURN  SQLGetDiagRec(SQLSMALLINT HandleType,
-			 SQLINTEGER Handle,
-                         SQLSMALLINT RecordNumber,
-			 SQLCHAR *Sqlstate,
-                         SQLINTEGER *NativeError,
-			 SQLCHAR *MessageText,
-                         SQLSMALLINT BufferLength,
-			 SQLSMALLINT *StringLength);
-
-SQLRETURN  SQLGetEnvAttr(SQLHENV EnvironmentHandle,
-                         SQLINTEGER Attribute,
-			 SQLPOINTER Value,
-                         SQLINTEGER BufferLength,
-			 SQLINTEGER *StringLength);
-
-SQLRETURN  SQLGetFunctions(SQLHDBC ConnectionHandle,
-			   SQLSMALLINT FunctionId,
-			   SQLSMALLINT *Supported);
-
-SQLRETURN  SQLGetInfo(SQLHDBC ConnectionHandle,
-		      SQLSMALLINT InfoType,
-		      SQLPOINTER InfoValue,
-		      SQLSMALLINT BufferLength,
-		      SQLSMALLINT *StringLength);
-
-SQLRETURN  SQLGetStmtAttr(SQLHSTMT StatementHandle,
-			  SQLINTEGER Attribute,
-			  SQLPOINTER Value,
-			  SQLINTEGER BufferLength,
-			  SQLINTEGER *StringLength);
+			   SQLINTEGER * StringLength);
 
-SQLRETURN  SQLGetTypeInfo(SQLHSTMT StatementHandle,
-			  SQLSMALLINT DataType);
+SQLRETURN SQLGetTypeInfo(SQLHSTMT StatementHandle,
+			   SQLSMALLINT DataType);
 
-SQLRETURN  SQLNumResultCols(SQLHSTMT StatementHandle,
-			    SQLINTEGER *ColumnCount);
+SQLRETURN SQLNumResultCols(SQLHSTMT StatementHandle,
+				 SQLINTEGER * ColumnCount);
 
-SQLRETURN  SQLParamData(SQLHSTMT StatementHandle,
-			SQLPOINTER *Value);
+SQLRETURN SQLParamData(SQLHSTMT StatementHandle,
+			 SQLPOINTER * Value);
 
-SQLRETURN  SQLPrepare(SQLHSTMT StatementHandle,
-		      SQLCHAR *StatementText,
-		      SQLSMALLINT StringLength);
+SQLRETURN SQLPrepare(SQLHSTMT StatementHandle,
+		   SQLCHAR * StatementText,
+		   SQLSMALLINT StringLength);
 
 
-SQLRETURN  SQLPutData(SQLHSTMT StatementHandle,
-		      SQLPOINTER Data,
-		      SQLINTEGER StringLength);
+SQLRETURN SQLPutData(SQLHSTMT StatementHandle,
+		   SQLPOINTER Data,
+		   SQLINTEGER StringLength);
 
-SQLRETURN  SQLRowCount(SQLHSTMT StatementHandle,
-		       SQLINTEGER *RowCount);
+SQLRETURN SQLRowCount(SQLHSTMT StatementHandle,
+			SQLINTEGER * RowCount);
 
-SQLRETURN  SQLSetConnectAttr(SQLHDBC ConnectionHandle,
-			     SQLINTEGER AttributeCursorName,
-			     SQLPOINTER Value,
-			     SQLINTEGER StringLength);
+SQLRETURN SQLSetConnectAttr(SQLHDBC ConnectionHandle,
+				  SQLINTEGER AttributeCursorName,
+				  SQLPOINTER Value,
+				  SQLINTEGER StringLength);
 
-SQLRETURN  SQLSetCursorName(SQLHSTMT StatementHandle,
-			    SQLCHAR *CursorName,
-			    SQLSMALLINT NameLength);
+SQLRETURN SQLSetCursorName(SQLHSTMT StatementHandle,
+				 SQLCHAR * CursorName,
+				 SQLSMALLINT NameLength);
 
-SQLRETURN  SQLSetDescField(SQLHDESC DescriptorHandle,
-			   SQLSMALLINT RecordNumber,
-			   SQLSMALLINT FieldIdentifier,
-			   SQLPOINTER Value, SQLINTEGER BufferLength);
+SQLRETURN SQLSetDescField(SQLHDESC DescriptorHandle,
+				SQLSMALLINT RecordNumber,
+				SQLSMALLINT FieldIdentifier,
+				SQLPOINTER Value, SQLINTEGER BufferLength);
 
-SQLRETURN  SQLSetDescRec(SQLHDESC DescriptorHandle,
-                         SQLSMALLINT RecordNumber,
-			 SQLSMALLINT Type,
-                         SQLSMALLINT SubType,
-			 SQLINTEGER Length,
-                         SQLSMALLINT Precision,
-			 SQLSMALLINT Scale,
-                         SQLPOINTER Data,
-			 SQLINTEGER *StringLength,
-                         SQLSMALLINT *Indicator);
+SQLRETURN SQLSetDescRec(SQLHDESC DescriptorHandle,
+			  SQLSMALLINT RecordNumber,
+			  SQLSMALLINT Type,
+			  SQLSMALLINT SubType,
+			  SQLINTEGER Length,
+			  SQLSMALLINT Precision,
+			  SQLSMALLINT Scale,
+			  SQLPOINTER Data,
+			  SQLINTEGER * StringLength,
+			  SQLSMALLINT * Indicator);
 
-SQLRETURN  SQLSetEnvAttr(SQLHENV EnvironmentHandle,
-                         SQLINTEGER Attribute,
-			 SQLPOINTER Value,
-                         SQLINTEGER StringLength);
-
-SQLRETURN  SQLSetStmtAttr(SQLHSTMT StatementHandle,
+SQLRETURN SQLSetEnvAttr(SQLHENV EnvironmentHandle,
 			  SQLINTEGER Attribute,
 			  SQLPOINTER Value,
 			  SQLINTEGER StringLength);
 
+SQLRETURN SQLSetStmtAttr(SQLHSTMT StatementHandle,
+			   SQLINTEGER Attribute,
+			   SQLPOINTER Value,
+			   SQLINTEGER StringLength);
+
 /* These are in SQL3 from August 1994
  * but not in Date and Darwen, 1997
  * - Thomas Lockhart 1999-06-17
diff --git a/src/interfaces/ecpg/include/ecpgerrno.h b/src/interfaces/ecpg/include/ecpgerrno.h
index 37443badcd2add18ede253f490b3b8b710d1d1cf..2a826988be5ea1b8a03481818c57db99a5a024fd 100644
--- a/src/interfaces/ecpg/include/ecpgerrno.h
+++ b/src/interfaces/ecpg/include/ecpgerrno.h
@@ -14,7 +14,7 @@
 
 /* first we have a set of ecpg messages, they start at 200 */
 #define ECPG_UNSUPPORTED		-200
-#define ECPG_TOO_MANY_ARGUMENTS 	-201
+#define ECPG_TOO_MANY_ARGUMENTS		-201
 #define ECPG_TOO_FEW_ARGUMENTS		-202
 #define ECPG_TOO_MANY_MATCHES		-203
 #define ECPG_INT_FORMAT			-204
diff --git a/src/interfaces/ecpg/include/ecpglib.h b/src/interfaces/ecpg/include/ecpglib.h
index 8b8dd3f3b5cda891d38e4e425468bc4d9aa47471..8b7e1ecd40362bf584c708e0e9fa520260079f75 100644
--- a/src/interfaces/ecpg/include/ecpglib.h
+++ b/src/interfaces/ecpg/include/ecpglib.h
@@ -17,27 +17,27 @@ extern		"C"
 	bool		ECPGprepare(int, char *, char *);
 	bool		ECPGdeallocate(int, char *);
 	bool		ECPGdeallocate_all(int);
-	char		*ECPGprepared_statement(char *);
-	
+	char	   *ECPGprepared_statement(char *);
+
 	void		ECPGlog(const char *format,...);
-	
+
 	/* print an error message */
 	void		sqlprint(void);
-	
+
 /* define this for simplicity as well as compatibility */
 
 #define		  SQLCODE	 sqlca.sqlcode
 
 /* dynamic SQL */
 
-	bool		ECPGdo_descriptor(int line,const char *connection,
-							const char *descriptor,const char *query);
-	bool		ECPGdeallocate_desc(int line,const char *name);
-	bool		ECPGallocate_desc(int line,const char *name);
+	bool		ECPGdo_descriptor(int line, const char *connection,
+							  const char *descriptor, const char *query);
+	bool		ECPGdeallocate_desc(int line, const char *name);
+	bool		ECPGallocate_desc(int line, const char *name);
 	void		ECPGraise(int line, int code, char *str);
 	bool		ECPGget_desc_header(int, char *, int *);
-	bool		ECPGget_desc(int, char *, int, ...);
-	
+	bool		ECPGget_desc(int, char *, int,...);
+
 
 #ifdef __cplusplus
 }
diff --git a/src/interfaces/ecpg/include/ecpgtype.h b/src/interfaces/ecpg/include/ecpgtype.h
index b19ba177c0c31e122873b18f44190eab980ad74e..8268e5495bdea70bb2f5f1c3035c41b98068a1e2 100644
--- a/src/interfaces/ecpg/include/ecpgtype.h
+++ b/src/interfaces/ecpg/include/ecpgtype.h
@@ -50,7 +50,7 @@ extern		"C"
 		ECPGt_NO_INDICATOR		/* no indicator */
 	};
 
-	/* descriptor items */	
+	/* descriptor items */
 	enum ECPGdtype
 	{
 		ECPGd_count,
diff --git a/src/interfaces/ecpg/include/sql3types.h b/src/interfaces/ecpg/include/sql3types.h
index 3aa86f50f0998eaa371d66459667ff5a5cc4a66f..e7e153f34ca019b8492d207636beea31a6e8fba2 100644
--- a/src/interfaces/ecpg/include/sql3types.h
+++ b/src/interfaces/ecpg/include/sql3types.h
@@ -2,12 +2,14 @@
  *
  * Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
  *
- * $Header: /cvsroot/pgsql/src/interfaces/ecpg/include/sql3types.h,v 1.3 2000/03/17 23:26:30 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/include/sql3types.h,v 1.4 2000/04/12 17:17:01 momjian Exp $
  */
 
 /* chapter 13.1 table 2: Codes used for SQL data types in Dynamic SQL */
 
-enum { 	SQL3_CHARACTER=1,
+enum
+{
+	SQL3_CHARACTER = 1,
 	SQL3_NUMERIC,
 	SQL3_DECIMAL,
 	SQL3_INTEGER,
@@ -16,23 +18,26 @@ enum { 	SQL3_CHARACTER=1,
 	SQL3_REAL,
 	SQL3_DOUBLE_PRECISION,
 	SQL3_DATE_TIME_TIMESTAMP,
-	SQL3_INTERVAL, /* 10 */
-	SQL3_CHARACTER_VARYING=12,
+	SQL3_INTERVAL,				/* 10 */
+	SQL3_CHARACTER_VARYING = 12,
 	SQL3_ENUMERATED,
 	SQL3_BIT,
 	SQL3_BIT_VARYING,
 	SQL3_BOOLEAN,
 	SQL3_abstract
 	/* the rest is xLOB stuff */
-     };
+};
 
 /* chapter 13.1 table 3: Codes associated with datetime data types in Dynamic SQL */
 
-enum {	SQL3_DDT_DATE=1,
+enum
+{
+	SQL3_DDT_DATE = 1,
 	SQL3_DDT_TIME,
 	SQL3_DDT_TIMESTAMP,
 	SQL3_DDT_TIME_WITH_TIME_ZONE,
 	SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE,
-	
-	SQL3_DDT_ILLEGAL /* not a datetime data type (not part of standard) */
-     };
+
+	SQL3_DDT_ILLEGAL			/* not a datetime data type (not part of
+								 * standard) */
+};
diff --git a/src/interfaces/ecpg/include/sqlca.h b/src/interfaces/ecpg/include/sqlca.h
index 0fa4a62418159cb6b17ed6a6b2e6e046fee8fa11..71987648b4d0e428d802a2204702a4362f0bedf3 100644
--- a/src/interfaces/ecpg/include/sqlca.h
+++ b/src/interfaces/ecpg/include/sqlca.h
@@ -21,7 +21,7 @@ extern		"C"
 		char		sqlerrp[8];
 		long		sqlerrd[6];
 		/* Element 0: empty						*/
-		/* 1: OID of processed tuple if applicable  		*/
+		/* 1: OID of processed tuple if applicable			*/
 		/* 2: number of rows processed	*/
 		/* after an INSERT, UPDATE or */
 		/* DELETE statement			 */
@@ -48,6 +48,7 @@ extern		"C"
 
 #ifdef __cplusplus
 }
+
 #endif
 
 #endif
diff --git a/src/interfaces/ecpg/lib/connect.c b/src/interfaces/ecpg/lib/connect.c
index 0a4d915c3e932f8039023f40382cd00ec22b4b8d..8452271926ec6348a3e876512201a230851afb96 100644
--- a/src/interfaces/ecpg/lib/connect.c
+++ b/src/interfaces/ecpg/lib/connect.c
@@ -4,7 +4,8 @@
 #include "extern.h"
 #include <sqlca.h>
 
-static struct connection *all_connections = NULL, *actual_connection = NULL;
+static struct connection *all_connections = NULL,
+		   *actual_connection = NULL;
 
 struct connection *
 get_connection(const char *connection_name)
@@ -58,10 +59,10 @@ ECPGsetcommit(int lineno, const char *mode, const char *connection_name)
 	PGresult   *results;
 
 	if (!ecpg_init(con, connection_name, lineno))
-		return(false);
+		return (false);
 
 	ECPGlog("ECPGsetcommit line %d action = %s connection = %s\n", lineno, mode, con->name);
-	
+
 	if (con->autocommit == true && strncmp(mode, "off", strlen("off")) == 0)
 	{
 		if (con->committed)
@@ -100,7 +101,7 @@ ECPGsetconn(int lineno, const char *connection_name)
 	struct connection *con = get_connection(connection_name);
 
 	if (!ecpg_init(con, connection_name, lineno))
-		return(false);
+		return (false);
 
 	actual_connection = con;
 	return true;
@@ -112,7 +113,7 @@ ECPGconnect(int lineno, const char *dbname, const char *user, const char *passwd
 	struct connection *this;
 
 	init_sqlca();
-	
+
 	if ((this = (struct connection *) ecpg_alloc(sizeof(struct connection), lineno)) == NULL)
 		return false;
 
@@ -171,7 +172,7 @@ ECPGdisconnect(int lineno, const char *connection_name)
 		con = get_connection(connection_name);
 
 		if (!ecpg_init(con, connection_name, lineno))
-		        return(false);
+			return (false);
 		else
 			ecpg_finish(con);
 	}
diff --git a/src/interfaces/ecpg/lib/data.c b/src/interfaces/ecpg/lib/data.c
index b7398caf6d750d5c60b40f2497e8b7b9a95b1601..1b97478e20daeb3be7506712da5cc568b94b5a51 100644
--- a/src/interfaces/ecpg/lib/data.c
+++ b/src/interfaces/ecpg/lib/data.c
@@ -8,11 +8,11 @@
 
 bool
 get_data(PGresult *results, int act_tuple, int act_field, int lineno,
-	 enum ECPGttype type, enum ECPGttype ind_type,
-	 void *var, void *ind, long varcharsize, long offset,
-	 bool isarray)
+		 enum ECPGttype type, enum ECPGttype ind_type,
+		 void *var, void *ind, long varcharsize, long offset,
+		 bool isarray)
 {
-	char *pval = (char *)PQgetvalue(results, act_tuple, act_field);
+	char	   *pval = (char *) PQgetvalue(results, act_tuple, act_field);
 
 	ECPGlog("get_data line %d: RESULT: %s\n", lineno, pval ? pval : "");
 
@@ -20,20 +20,20 @@ get_data(PGresult *results, int act_tuple, int act_field, int lineno,
 	/* let's check is it really is an array if it should be */
 	if (isarray)
 	{
-		if (*pval !=  '{')
+		if (*pval != '{')
 		{
 			ECPGlog("get_data data entry does not look like an array in line %d\n", lineno);
 			ECPGraise(lineno, ECPG_DATA_NOT_ARRAY, NULL);
-			return(false);
+			return (false);
 		}
-		else ++pval;
+		else
+			++pval;
 	}
 
 	/* We will have to decode the value */
 
 	/*
-	 * check for null value and set indicator
-	 * accordingly
+	 * check for null value and set indicator accordingly
 	 */
 	switch (ind_type)
 	{
@@ -61,226 +61,226 @@ get_data(PGresult *results, int act_tuple, int act_field, int lineno,
 			return (false);
 			break;
 	}
-	
+
 	do
-	{	
-	   switch (type)
-	   {
-		long		res;
-		unsigned long	ures;
-		double		dres;
-		char 		*scan_length;
+	{
+		switch (type)
+		{
+				long		res;
+				unsigned long ures;
+				double		dres;
+				char	   *scan_length;
 
-		case ECPGt_short:
-		case ECPGt_int:
-		case ECPGt_long:
-			if (pval)
-			{
-				res = strtol(pval, &scan_length, 10);
-				if ((isarray && *scan_length != ',' && *scan_length != '}')
-					|| (!isarray && *scan_length != '\0'))	/* Garbage left */
+			case ECPGt_short:
+			case ECPGt_int:
+			case ECPGt_long:
+				if (pval)
 				{
-					ECPGraise(lineno, ECPG_INT_FORMAT, pval);
-					return (false);
-					res = 0L;
+					res = strtol(pval, &scan_length, 10);
+					if ((isarray && *scan_length != ',' && *scan_length != '}')
+						|| (!isarray && *scan_length != '\0'))	/* Garbage left */
+					{
+						ECPGraise(lineno, ECPG_INT_FORMAT, pval);
+						return (false);
+						res = 0L;
+					}
 				}
-			}
-			else
-				res = 0L;
-
-			switch (type)
-			{
-				case ECPGt_short:
-					((short *) var)[act_tuple] = (short) res;
-					break;
-				case ECPGt_int:
-					((int *) var)[act_tuple] = (int) res;
-					break;
-				case ECPGt_long:
-					((long *) var)[act_tuple] = res;
-					break;
-				default:
-					/* Cannot happen */
-					break;
-			}
-			break;
+				else
+					res = 0L;
 
-		case ECPGt_unsigned_short:
-		case ECPGt_unsigned_int:
-		case ECPGt_unsigned_long:
-			if (pval)
-			{
-				ures = strtoul(pval, &scan_length, 10);
-				if ((isarray && *scan_length != ',' && *scan_length != '}')
-					|| (!isarray && *scan_length != '\0'))	/* Garbage left */
+				switch (type)
 				{
-					ECPGraise(lineno, ECPG_UINT_FORMAT, pval);
-					return (false);
-					ures = 0L;
+					case ECPGt_short:
+						((short *) var)[act_tuple] = (short) res;
+						break;
+					case ECPGt_int:
+						((int *) var)[act_tuple] = (int) res;
+						break;
+					case ECPGt_long:
+						((long *) var)[act_tuple] = res;
+						break;
+					default:
+						/* Cannot happen */
+						break;
 				}
-			}
-			else
-				ures = 0L;
-
-			switch (type)
-			{
-				case ECPGt_unsigned_short:
-					((unsigned short *) var)[act_tuple] = (unsigned short) ures;
-					break;
-				case ECPGt_unsigned_int:
-					((unsigned int *) var)[act_tuple] = (unsigned int) ures;
-					break;
-				case ECPGt_unsigned_long:
-					((unsigned long *) var)[act_tuple] = ures;
-					break;
-				default:
-					/* Cannot happen */
-					break;
-			}
-			break;
+				break;
 
+			case ECPGt_unsigned_short:
+			case ECPGt_unsigned_int:
+			case ECPGt_unsigned_long:
+				if (pval)
+				{
+					ures = strtoul(pval, &scan_length, 10);
+					if ((isarray && *scan_length != ',' && *scan_length != '}')
+						|| (!isarray && *scan_length != '\0'))	/* Garbage left */
+					{
+						ECPGraise(lineno, ECPG_UINT_FORMAT, pval);
+						return (false);
+						ures = 0L;
+					}
+				}
+				else
+					ures = 0L;
 
-		case ECPGt_float:
-		case ECPGt_double:
-			if (pval)
-			{
-				dres = strtod(pval, &scan_length);
-				if ((isarray && *scan_length != ',' && *scan_length != '}')
-					|| (!isarray && *scan_length != '\0'))	/* Garbage left */
+				switch (type)
 				{
-					ECPGraise(lineno, ECPG_FLOAT_FORMAT, pval);
-					return (false);
-					dres = 0.0;
+					case ECPGt_unsigned_short:
+						((unsigned short *) var)[act_tuple] = (unsigned short) ures;
+						break;
+					case ECPGt_unsigned_int:
+						((unsigned int *) var)[act_tuple] = (unsigned int) ures;
+						break;
+					case ECPGt_unsigned_long:
+						((unsigned long *) var)[act_tuple] = ures;
+						break;
+					default:
+						/* Cannot happen */
+						break;
 				}
-			}
-			else
-				dres = 0.0;
+				break;
 
-			switch (type)
-			{
-				case ECPGt_float:
-					((float *) var)[act_tuple] = dres;
-					break;
-				case ECPGt_double:
-					((double *) var)[act_tuple] = dres;
-					break;
-				default:
-					/* Cannot happen */
-					break;
-			}
-			break;
 
-		case ECPGt_bool:
-			if (pval)
-			{
-				if (pval[0] == 'f' && pval[1] == '\0')
+			case ECPGt_float:
+			case ECPGt_double:
+				if (pval)
 				{
-					((char *) var)[act_tuple] = false;
-					break;
+					dres = strtod(pval, &scan_length);
+					if ((isarray && *scan_length != ',' && *scan_length != '}')
+						|| (!isarray && *scan_length != '\0'))	/* Garbage left */
+					{
+						ECPGraise(lineno, ECPG_FLOAT_FORMAT, pval);
+						return (false);
+						dres = 0.0;
+					}
 				}
-				else if (pval[0] == 't' && pval[1] == '\0')
+				else
+					dres = 0.0;
+
+				switch (type)
 				{
-					((char *) var)[act_tuple] = true;
-					break;
+					case ECPGt_float:
+						((float *) var)[act_tuple] = dres;
+						break;
+					case ECPGt_double:
+						((double *) var)[act_tuple] = dres;
+						break;
+					default:
+						/* Cannot happen */
+						break;
 				}
-				else if (pval[0] == '\0' && PQgetisnull(results, act_tuple, act_field))
+				break;
+
+			case ECPGt_bool:
+				if (pval)
 				{
-					/* NULL is valid */
-					break;
+					if (pval[0] == 'f' && pval[1] == '\0')
+					{
+						((char *) var)[act_tuple] = false;
+						break;
+					}
+					else if (pval[0] == 't' && pval[1] == '\0')
+					{
+						((char *) var)[act_tuple] = true;
+						break;
+					}
+					else if (pval[0] == '\0' && PQgetisnull(results, act_tuple, act_field))
+					{
+						/* NULL is valid */
+						break;
+					}
 				}
-			}
 
-			ECPGraise(lineno, ECPG_CONVERT_BOOL, pval);
-			return (false);
-			break;
+				ECPGraise(lineno, ECPG_CONVERT_BOOL, pval);
+				return (false);
+				break;
 
-		case ECPGt_char:
-		case ECPGt_unsigned_char:
-			{
-				strncpy((char *) ((long) var + offset * act_tuple), pval, varcharsize);
-				if (varcharsize && varcharsize < strlen(pval))
+			case ECPGt_char:
+			case ECPGt_unsigned_char:
 				{
-					/* truncation */
-					switch (ind_type)
+					strncpy((char *) ((long) var + offset * act_tuple), pval, varcharsize);
+					if (varcharsize && varcharsize < strlen(pval))
 					{
-						case ECPGt_short:
-						case ECPGt_unsigned_short:
-							((short *) ind)[act_tuple] = varcharsize;
-							break;
-						case ECPGt_int:
-						case ECPGt_unsigned_int:
-							((int *) ind)[act_tuple] = varcharsize;
-							break;
-						case ECPGt_long:
-						case ECPGt_unsigned_long:
-							((long *) ind)[act_tuple] = varcharsize;
-							break;
-						default:
-							break;
+						/* truncation */
+						switch (ind_type)
+						{
+							case ECPGt_short:
+							case ECPGt_unsigned_short:
+								((short *) ind)[act_tuple] = varcharsize;
+								break;
+							case ECPGt_int:
+							case ECPGt_unsigned_int:
+								((int *) ind)[act_tuple] = varcharsize;
+								break;
+							case ECPGt_long:
+							case ECPGt_unsigned_long:
+								((long *) ind)[act_tuple] = varcharsize;
+								break;
+							default:
+								break;
+						}
+						sqlca.sqlwarn[0] = sqlca.sqlwarn[1] = 'W';
 					}
-					sqlca.sqlwarn[0] = sqlca.sqlwarn[1] = 'W';
 				}
-			}
-			break;
+				break;
 
-		case ECPGt_varchar:
-			{
-				struct ECPGgeneric_varchar *variable =
-				(struct ECPGgeneric_varchar *) ((long) var + offset * act_tuple);
+			case ECPGt_varchar:
+				{
+					struct ECPGgeneric_varchar *variable =
+					(struct ECPGgeneric_varchar *) ((long) var + offset * act_tuple);
 
-				if (varcharsize == 0)
-					strncpy(variable->arr, pval, strlen(pval));
-				else
-					strncpy(variable->arr, pval, varcharsize);
+					if (varcharsize == 0)
+						strncpy(variable->arr, pval, strlen(pval));
+					else
+						strncpy(variable->arr, pval, varcharsize);
 
-				variable->len = strlen(pval);
-				if (varcharsize > 0 && variable->len > varcharsize)
-				{
-					/* truncation */
-					switch (ind_type)
+					variable->len = strlen(pval);
+					if (varcharsize > 0 && variable->len > varcharsize)
 					{
-						case ECPGt_short:
-						case ECPGt_unsigned_short:
-							((short *) ind)[act_tuple] = varcharsize;
-							break;
-						case ECPGt_int:
-						case ECPGt_unsigned_int:
-							((int *) ind)[act_tuple] = varcharsize;
-							break;
-						case ECPGt_long:
-						case ECPGt_unsigned_long:
-							((long *) ind)[act_tuple] = varcharsize;
-							break;
-						default:
-							break;
-					}
-					sqlca.sqlwarn[0] = sqlca.sqlwarn[1] = 'W';
+						/* truncation */
+						switch (ind_type)
+						{
+							case ECPGt_short:
+							case ECPGt_unsigned_short:
+								((short *) ind)[act_tuple] = varcharsize;
+								break;
+							case ECPGt_int:
+							case ECPGt_unsigned_int:
+								((int *) ind)[act_tuple] = varcharsize;
+								break;
+							case ECPGt_long:
+							case ECPGt_unsigned_long:
+								((long *) ind)[act_tuple] = varcharsize;
+								break;
+							default:
+								break;
+						}
+						sqlca.sqlwarn[0] = sqlca.sqlwarn[1] = 'W';
 
-					variable->len = varcharsize;
+						variable->len = varcharsize;
+					}
 				}
-			}
-			break;
+				break;
 
-		default:
-			ECPGraise(lineno, ECPG_UNSUPPORTED, ECPGtype_name(type));
-			return (false);
-			break;
-	   }
-	   if (isarray)
-	   {
-	   	bool string = false;
-	   	
-	   	/* set array to next entry */
-	   	++act_tuple;
-	   	
-	   	/* set pval to the next entry */
-	   	for (; string || (*pval != ',' && *pval != '}'); ++pval)
-	   		if (*pval == '"')
-	   			string = string ? false : true;
-	   	
-	   	if (*pval == ',')
-	   		++pval;
-	   }
+			default:
+				ECPGraise(lineno, ECPG_UNSUPPORTED, ECPGtype_name(type));
+				return (false);
+				break;
+		}
+		if (isarray)
+		{
+			bool		string = false;
+
+			/* set array to next entry */
+			++act_tuple;
+
+			/* set pval to the next entry */
+			for (; string || (*pval != ',' && *pval != '}'); ++pval)
+				if (*pval == '"')
+					string = string ? false : true;
+
+			if (*pval == ',')
+				++pval;
+		}
 	} while (isarray && *pval != '}');
 
 	return (true);
diff --git a/src/interfaces/ecpg/lib/descriptor.c b/src/interfaces/ecpg/lib/descriptor.c
index b1fe2b79d0498dc6e88b62fe66f2b4d5727a36a8..c79baf799acda5a08ed878fe25069197a5fddc69 100644
--- a/src/interfaces/ecpg/lib/descriptor.c
+++ b/src/interfaces/ecpg/lib/descriptor.c
@@ -6,265 +6,270 @@
 
 struct descriptor
 {
-        char *name;
-        PGresult *result;
-        struct descriptor *next;
-} *all_descriptors = NULL;
-                        
+	char	   *name;
+	PGresult   *result;
+	struct descriptor *next;
+}		   *all_descriptors = NULL;
+
 static PGresult
-*ECPGresultByDescriptor(int line,const char *name)
+		   *
+ECPGresultByDescriptor(int line, const char *name)
 {
 	struct descriptor *i;
-	
+
 	for (i = all_descriptors; i != NULL; i = i->next)
 	{
-		if (!strcmp(name, i->name)) return i->result;
+		if (!strcmp(name, i->name))
+			return i->result;
 	}
-	
+
 	ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, name);
-	
+
 	return NULL;
-} 
+}
 
 static unsigned int
 ECPGDynamicType_DDT(Oid type)
 {
-	switch(type)
-	{	
-		case 1082:	return SQL3_DDT_DATE;	/* date */
-		case 1083:	return SQL3_DDT_TIME;	/* time */
-		case 1184:	return SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE;	/* datetime */
-		case 1296:	return SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE;	/* timestamp */
+	switch (type)
+	{
+			case 1082:return SQL3_DDT_DATE;		/* date */
+		case 1083:
+			return SQL3_DDT_TIME;		/* time */
+		case 1184:
+			return SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE;	/* datetime */
+		case 1296:
+			return SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE;	/* timestamp */
 		default:
 			return SQL3_DDT_ILLEGAL;
 	}
 }
 
 bool
-ECPGget_desc_header(int lineno, char * desc_name, int *count)
+ECPGget_desc_header(int lineno, char *desc_name, int *count)
 {
-	PGresult *ECPGresult = ECPGresultByDescriptor(lineno, desc_name);
-	
+	PGresult   *ECPGresult = ECPGresultByDescriptor(lineno, desc_name);
+
 	if (!ECPGresult)
 		return false;
 
 	*count = PQnfields(ECPGresult);
 	ECPGlog("ECPGget_desc_header: found %d attributes.\n", *count);
 	return true;
-}	
+}
 
 static bool
 get_int_item(int lineno, void *var, enum ECPGdtype vartype, int value)
 {
 	switch (vartype)
-     	{
-       		case ECPGt_short:
-              		*(short *)var = value;
-               		break;
+	{
+			case ECPGt_short:
+			*(short *) var = value;
+			break;
 		case ECPGt_int:
-	       		*(int *)var = value;
-	  		break;
-  		case ECPGt_long:
-  			*(long *)var = value;
-	  		break;
-  		case ECPGt_unsigned_short:
-  			*(unsigned short *)var = value;
-	  		break;
+			*(int *) var = value;
+			break;
+		case ECPGt_long:
+			*(long *) var = value;
+			break;
+		case ECPGt_unsigned_short:
+			*(unsigned short *) var = value;
+			break;
 		case ECPGt_unsigned_int:
-  			*(unsigned int *)var = value;
-	  		break;
-  		case ECPGt_unsigned_long:
-  			*(unsigned long *)var = value;
-	  		break;
-  		case ECPGt_float:
-  			*(float *)var = value;
-	  		break;
-  		case ECPGt_double:
-  			*(double *)var = value;
-	  		break;
-  		default:
-  			ECPGraise(lineno, ECPG_VAR_NOT_NUMERIC, NULL);
-  			return (false);
+			*(unsigned int *) var = value;
+			break;
+		case ECPGt_unsigned_long:
+			*(unsigned long *) var = value;
+			break;
+		case ECPGt_float:
+			*(float *) var = value;
+			break;
+		case ECPGt_double:
+			*(double *) var = value;
+			break;
+		default:
+			ECPGraise(lineno, ECPG_VAR_NOT_NUMERIC, NULL);
+			return (false);
 	}
-	
-	return(true);
+
+	return (true);
 }
 
 static bool
 get_char_item(int lineno, void *var, enum ECPGdtype vartype, char *value, int varcharsize)
 {
 	switch (vartype)
-     	{
-       		case ECPGt_char:
-       		case ECPGt_unsigned_char:
-       			strncpy((char *) var, value, varcharsize);
-               		break;
-  		case ECPGt_varchar:
-  			{
-  				struct ECPGgeneric_varchar *variable =
-  				                                (struct ECPGgeneric_varchar *) var;
-  				                                
-	  			if (varcharsize == 0)
+	{
+			case ECPGt_char:
+			case ECPGt_unsigned_char:
+			strncpy((char *) var, value, varcharsize);
+			break;
+		case ECPGt_varchar:
+			{
+				struct ECPGgeneric_varchar *variable =
+				(struct ECPGgeneric_varchar *) var;
+
+				if (varcharsize == 0)
 					strncpy(variable->arr, value, strlen(value));
-  				else
-  				        strncpy(variable->arr, value, varcharsize);
-  			        
-  			        variable->len = strlen(value);
-  			        if (varcharsize > 0 && variable->len > varcharsize)
-  			        	variable->len = varcharsize;
-  			}
-	  		break;
-  		default:
-  			ECPGraise(lineno, ECPG_VAR_NOT_CHAR, NULL);
-  			return (false);
+				else
+					strncpy(variable->arr, value, varcharsize);
+
+				variable->len = strlen(value);
+				if (varcharsize > 0 && variable->len > varcharsize)
+					variable->len = varcharsize;
+			}
+			break;
+		default:
+			ECPGraise(lineno, ECPG_VAR_NOT_CHAR, NULL);
+			return (false);
 	}
-	
-	return(true);
+
+	return (true);
 }
 
 bool
-ECPGget_desc(int lineno, char *desc_name, int index, ...)
+ECPGget_desc(int lineno, char *desc_name, int index,...)
 {
-	va_list         args;
-	PGresult 	*ECPGresult = ECPGresultByDescriptor(lineno, desc_name);
-	enum ECPGdtype	type;
+	va_list		args;
+	PGresult   *ECPGresult = ECPGresultByDescriptor(lineno, desc_name);
+	enum ECPGdtype type;
 	bool		DataButNoIndicator = false;
-	
+
 	va_start(args, index);
-        if (!ECPGresult)
-        	return (false);
-
-       	if (PQntuples(ECPGresult) < 1)
-       	{
-       		ECPGraise(lineno, ECPG_NOT_FOUND, NULL);
-       		return (false);
-       	}
-        
-        if (index < 1 || index >PQnfields(ECPGresult))
-        {
-                ECPGraise(lineno, ECPG_INVALID_DESCRIPTOR_INDEX, NULL);
-                return (false);
-        }
+	if (!ECPGresult)
+		return (false);
+
+	if (PQntuples(ECPGresult) < 1)
+	{
+		ECPGraise(lineno, ECPG_NOT_FOUND, NULL);
+		return (false);
+	}
+
+	if (index < 1 || index > PQnfields(ECPGresult))
+	{
+		ECPGraise(lineno, ECPG_INVALID_DESCRIPTOR_INDEX, NULL);
+		return (false);
+	}
 
 	ECPGlog("ECPGget_desc: reading items for tuple %d\n", index);
-    	--index;
-    	
-    	type =  va_arg(args, enum ECPGdtype);
-    	
-    	while (type != ECPGd_EODT)
-    	{
-    		char type_str[20];
-    		long varcharsize;
-    		long offset;
-    		long arrsize;
-    		enum ECPGttype vartype;
-    		void *var;
-    		
-    		vartype = va_arg(args, enum ECPGttype);
-    		var = va_arg(args, void *);
-    		varcharsize = va_arg(args, long);
-    		arrsize = va_arg(args, long);
+	--index;
+
+	type = va_arg(args, enum ECPGdtype);
+
+	while (type != ECPGd_EODT)
+	{
+		char		type_str[20];
+		long		varcharsize;
+		long		offset;
+		long		arrsize;
+		enum ECPGttype vartype;
+		void	   *var;
+
+		vartype = va_arg(args, enum ECPGttype);
+		var = va_arg(args, void *);
+		varcharsize = va_arg(args, long);
+		arrsize = va_arg(args, long);
 		offset = va_arg(args, long);
-		
-    		switch (type)
-    		{ 
-	        	case (ECPGd_indicator):
-	        		if (!get_int_item(lineno, var, vartype, -PQgetisnull(ECPGresult, 0, index)))
-	        			return (false);
-	        		
-	        		ECPGlog("ECPGget_desc: INDICATOR = %d\n", -PQgetisnull(ECPGresult, 0, index));
-	                 	break;
-
-	                case ECPGd_name:
-	                 	if (!get_char_item(lineno, var, vartype, PQfname(ECPGresult, index), varcharsize))
-	                 		return(false);
-	                 		
-	                 	ECPGlog("ECPGget_desc: NAME = %s\n", PQfname(ECPGresult, index));
-	                 	break;
-	                 	
-	                case ECPGd_nullable:
-	                	if (!get_int_item(lineno, var, vartype, 1))
-	        			return (false);
-	        			
-	        		break;
-	                	
-	                case ECPGd_key_member:
-	                	if (!get_int_item(lineno, var, vartype, 0))
-	        			return (false);
-	        			
-	                	break;
-	                 
-	                case ECPGd_scale:
-	                	if (!get_int_item(lineno, var, vartype, (PQfmod(ECPGresult, index) - VARHDRSZ) & 0xffff))
-	        			return (false);
-	        			
-	        		ECPGlog("ECPGget_desc: SCALE = %d\n", (PQfmod(ECPGresult, index) - VARHDRSZ) & 0xffff);
-		                break;
-		                 
-		        case ECPGd_precision:
-		        	if (!get_int_item(lineno, var, vartype, PQfmod(ECPGresult, index) >> 16))
-	        			return (false);
-	        			
-	        		ECPGlog("ECPGget_desc: PRECISION = %d\n", PQfmod(ECPGresult, index) >> 16);
-		                break;
-		                 
-		        case ECPGd_ret_length:
+
+		switch (type)
+		{
+			case (ECPGd_indicator):
+				if (!get_int_item(lineno, var, vartype, -PQgetisnull(ECPGresult, 0, index)))
+					return (false);
+
+				ECPGlog("ECPGget_desc: INDICATOR = %d\n", -PQgetisnull(ECPGresult, 0, index));
+				break;
+
+			case ECPGd_name:
+				if (!get_char_item(lineno, var, vartype, PQfname(ECPGresult, index), varcharsize))
+					return (false);
+
+				ECPGlog("ECPGget_desc: NAME = %s\n", PQfname(ECPGresult, index));
+				break;
+
+			case ECPGd_nullable:
+				if (!get_int_item(lineno, var, vartype, 1))
+					return (false);
+
+				break;
+
+			case ECPGd_key_member:
+				if (!get_int_item(lineno, var, vartype, 0))
+					return (false);
+
+				break;
+
+			case ECPGd_scale:
+				if (!get_int_item(lineno, var, vartype, (PQfmod(ECPGresult, index) - VARHDRSZ) & 0xffff))
+					return (false);
+
+				ECPGlog("ECPGget_desc: SCALE = %d\n", (PQfmod(ECPGresult, index) - VARHDRSZ) & 0xffff);
+				break;
+
+			case ECPGd_precision:
+				if (!get_int_item(lineno, var, vartype, PQfmod(ECPGresult, index) >> 16))
+					return (false);
+
+				ECPGlog("ECPGget_desc: PRECISION = %d\n", PQfmod(ECPGresult, index) >> 16);
+				break;
+
+			case ECPGd_ret_length:
 			case ECPGd_ret_octet:
 				if (!get_int_item(lineno, var, vartype, PQgetlength(ECPGresult, 0, index)))
-	        			return (false);
-	        			
-	        		ECPGlog("ECPGget_desc: RETURNED = %d\n", PQgetlength(ECPGresult, 0, index));
-			 	break;
-			 	
+					return (false);
+
+				ECPGlog("ECPGget_desc: RETURNED = %d\n", PQgetlength(ECPGresult, 0, index));
+				break;
+
 			case ECPGd_octet:
 				if (!get_int_item(lineno, var, vartype, PQfsize(ECPGresult, index)))
-	        			return (false);
-	        			
-	        		ECPGlog("ECPGget_desc: OCTET_LENGTH = %d\n", PQfsize(ECPGresult, index));
-	                        break;
+					return (false);
+
+				ECPGlog("ECPGget_desc: OCTET_LENGTH = %d\n", PQfsize(ECPGresult, index));
+				break;
 
 			case ECPGd_length:
 				if (!get_int_item(lineno, var, vartype, PQfmod(ECPGresult, index) - VARHDRSZ))
-	        			return (false);
-	        			
-	        		ECPGlog("ECPGget_desc: LENGTH = %d\n", PQfmod(ECPGresult, index) - VARHDRSZ);
+					return (false);
+
+				ECPGlog("ECPGget_desc: LENGTH = %d\n", PQfmod(ECPGresult, index) - VARHDRSZ);
+				break;
+
+			case ECPGd_type:
+				if (!get_int_item(lineno, var, vartype, ECPGDynamicType(PQftype(ECPGresult, index))))
+					return (false);
+
+				ECPGlog("ECPGget_desc: TYPE = %d\n", ECPGDynamicType(PQftype(ECPGresult, index)));
+				break;
+
+			case ECPGd_di_code:
+				if (!get_int_item(lineno, var, vartype, ECPGDynamicType_DDT(PQftype(ECPGresult, index))))
+					return (false);
+
+				ECPGlog("ECPGget_desc: TYPE = %d\n", ECPGDynamicType_DDT(PQftype(ECPGresult, index)));
 				break;
-				
-                        case ECPGd_type:
-                        	if (!get_int_item(lineno, var, vartype, ECPGDynamicType(PQftype(ECPGresult, index))))
-	        			return (false);
-	        			
-	        		ECPGlog("ECPGget_desc: TYPE = %d\n", ECPGDynamicType(PQftype(ECPGresult, index)));
-                        	break;
-
-                        case ECPGd_di_code:
-                        	if (!get_int_item(lineno, var, vartype, ECPGDynamicType_DDT(PQftype(ECPGresult, index))))
-	        			return (false);
-	        			
-	        		ECPGlog("ECPGget_desc: TYPE = %d\n", ECPGDynamicType_DDT(PQftype(ECPGresult, index)));
-                        	break;
 			case ECPGd_data:
 				if (!get_data(ECPGresult, 0, index, lineno, vartype, ECPGt_NO_INDICATOR, var, NULL, varcharsize, offset, false))
-					return (false);                        	
-					
+					return (false);
+
 				break;
-				
-                        default:
-                        	snprintf(type_str, sizeof(type_str), "%d", type);
-                        	ECPGraise(lineno, ECPG_UNKNOWN_DESCRIPTOR_ITEM, type_str);
-                        	return(false);
+
+			default:
+				snprintf(type_str, sizeof(type_str), "%d", type);
+				ECPGraise(lineno, ECPG_UNKNOWN_DESCRIPTOR_ITEM, type_str);
+				return (false);
 		}
-		
-		type =  va_arg(args, enum ECPGdtype);
+
+		type = va_arg(args, enum ECPGdtype);
+	}
+
+	if (DataButNoIndicator && PQgetisnull(ECPGresult, 0, index))
+	{
+		ECPGraise(lineno, ECPG_MISSING_INDICATOR, NULL);
+		return (false);
 	}
-                        
-        if (DataButNoIndicator && PQgetisnull(ECPGresult, 0, index))
-        {
-               	ECPGraise(lineno, ECPG_MISSING_INDICATOR, NULL);
-               	return (false);
-        }
-
-	return (true);                	
+
+	return (true);
 }
 
 bool
@@ -272,7 +277,7 @@ ECPGdeallocate_desc(int line, const char *name)
 {
 	struct descriptor *i;
 	struct descriptor **lastptr = &all_descriptors;
-	
+
 	for (i = all_descriptors; i; lastptr = &i->next, i = i->next)
 	{
 		if (!strcmp(name, i->name))
@@ -286,15 +291,15 @@ ECPGdeallocate_desc(int line, const char *name)
 	}
 	ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, name);
 	return false;
-} 
+}
 
 bool
-ECPGallocate_desc(int line,const char *name)
+ECPGallocate_desc(int line, const char *name)
 {
-	struct descriptor *new = (struct descriptor *)malloc(sizeof(struct descriptor));
-	
+	struct descriptor *new = (struct descriptor *) malloc(sizeof(struct descriptor));
+
 	new->next = all_descriptors;
-	new->name = malloc(strlen(name)+1);
+	new->name = malloc(strlen(name) + 1);
 	new->result = PQmakeEmptyPGresult(NULL, 0);
 	strcpy(new->name, name);
 	all_descriptors = new;
diff --git a/src/interfaces/ecpg/lib/error.c b/src/interfaces/ecpg/lib/error.c
index e7e976116b8a909be20e30086eeb1174bcdb6520..e2da331757afc417aa1a222484c3cd3b099d1dc9 100644
--- a/src/interfaces/ecpg/lib/error.c
+++ b/src/interfaces/ecpg/lib/error.c
@@ -10,143 +10,143 @@ void
 ECPGraise(int line, int code, char *str)
 {
 	sqlca.sqlcode = code;
-	
+
 	switch (code)
-	{ 
-		case ECPG_NOT_FOUND: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"No data found in line %d.", line);
-			break;
-			
-		case ECPG_OUT_OF_MEMORY: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"Out of memory in line %d.", line);
-			break;
-			
-		case ECPG_UNSUPPORTED: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"Unsupported type %s in line %d.", str, line);
-			break;
-			
-		case ECPG_TOO_MANY_ARGUMENTS: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"Too many arguments in line %d.", line);
-			break;
-		
-		case ECPG_TOO_FEW_ARGUMENTS: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"Too few arguments in line %d.", line);
-			break;
-		
-		case ECPG_INT_FORMAT: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"Not correctly formatted int type: %s line %d.", str, line);
-			break;
-			
-		case ECPG_UINT_FORMAT: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"Not correctly formatted unsigned type: %s in line %d.", str, line);
-			break;
-				
-		case ECPG_FLOAT_FORMAT: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"Not correctly formatted floating point type: %s in line %d.", str, line);
-			break;
-
-		case ECPG_CONVERT_BOOL: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"Unable to convert %s to bool on line %d.", str, line);
-			break;
-
-		case ECPG_EMPTY: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"Empty query in line %d.", line);
-			break;
-
-		case ECPG_MISSING_INDICATOR: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"NULL value without indicator in line %d.", line);
-			break;
-		
-		case ECPG_NO_ARRAY: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"variable is not an array in line %d.", line);
-			break;
-			
-		case ECPG_DATA_NOT_ARRAY: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"data read from backend is not an array in line %d.", line);
-			break;
-			
-		case ECPG_NO_CONN: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"No such connection %s in line %d.", str, line);
-			break;
-			
-		case ECPG_NOT_CONN: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"Not connected in line %d.", line);
-			break;
-
-		case ECPG_INVALID_STMT: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"Invalid statement name in line %d.", line);
-			break;
-			
-		case ECPG_UNKNOWN_DESCRIPTOR: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"Sescriptor %s not found in line %d.", str, line);
-			break;
-			
-		case ECPG_INVALID_DESCRIPTOR_INDEX: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"Sescriptor index out of range in line %d.", line);
-			break;
-		
-		case ECPG_UNKNOWN_DESCRIPTOR_ITEM: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"Unknown descriptor item %s in line %d.", str, line);
-			break;
-		
-		case ECPG_VAR_NOT_NUMERIC: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"Variable is not a numeric type in line %d.", line);
-			break;
-		
-		case ECPG_VAR_NOT_CHAR: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"Variable is not a character type in line %d.", line);
+	{
+		case ECPG_NOT_FOUND:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+					 "No data found in line %d.", line);
+			break;
+
+		case ECPG_OUT_OF_MEMORY:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+					 "Out of memory in line %d.", line);
+			break;
+
+		case ECPG_UNSUPPORTED:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+					 "Unsupported type %s in line %d.", str, line);
+			break;
+
+		case ECPG_TOO_MANY_ARGUMENTS:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+					 "Too many arguments in line %d.", line);
+			break;
+
+		case ECPG_TOO_FEW_ARGUMENTS:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+					 "Too few arguments in line %d.", line);
+			break;
+
+		case ECPG_INT_FORMAT:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+			 "Not correctly formatted int type: %s line %d.", str, line);
+			break;
+
+		case ECPG_UINT_FORMAT:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+					 "Not correctly formatted unsigned type: %s in line %d.", str, line);
+			break;
+
+		case ECPG_FLOAT_FORMAT:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+					 "Not correctly formatted floating point type: %s in line %d.", str, line);
+			break;
+
+		case ECPG_CONVERT_BOOL:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+				  "Unable to convert %s to bool on line %d.", str, line);
+			break;
+
+		case ECPG_EMPTY:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+					 "Empty query in line %d.", line);
+			break;
+
+		case ECPG_MISSING_INDICATOR:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+					 "NULL value without indicator in line %d.", line);
+			break;
+
+		case ECPG_NO_ARRAY:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+					 "variable is not an array in line %d.", line);
+			break;
+
+		case ECPG_DATA_NOT_ARRAY:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+			 "data read from backend is not an array in line %d.", line);
 			break;
-			
+
+		case ECPG_NO_CONN:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+					 "No such connection %s in line %d.", str, line);
+			break;
+
+		case ECPG_NOT_CONN:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+					 "Not connected in line %d.", line);
+			break;
+
+		case ECPG_INVALID_STMT:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+					 "Invalid statement name in line %d.", line);
+			break;
+
+		case ECPG_UNKNOWN_DESCRIPTOR:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+					 "Sescriptor %s not found in line %d.", str, line);
+			break;
+
+		case ECPG_INVALID_DESCRIPTOR_INDEX:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+					 "Sescriptor index out of range in line %d.", line);
+			break;
+
+		case ECPG_UNKNOWN_DESCRIPTOR_ITEM:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+					 "Unknown descriptor item %s in line %d.", str, line);
+			break;
+
+		case ECPG_VAR_NOT_NUMERIC:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+					 "Variable is not a numeric type in line %d.", line);
+			break;
+
+		case ECPG_VAR_NOT_CHAR:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+				   "Variable is not a character type in line %d.", line);
+			break;
+
 		case ECPG_PGSQL:
 			/* strip trailing newline */
-			if (str[strlen(str)-1] == '\n') 
-				str[strlen(str)-1] = '\0';
-							
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"'%s' in line %d.", str, line);
-			break;
-			
-		case ECPG_TRANS: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"Error in transaction processing in line %d.", line);
-			break;
-			
-		case ECPG_CONNECT: 
-			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"Could not connect to database %s in line %d.", str, line);
-			break;
-			
+			if (str[strlen(str) - 1] == '\n')
+				str[strlen(str) - 1] = '\0';
+
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+					 "'%s' in line %d.", str, line);
+			break;
+
+		case ECPG_TRANS:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+					 "Error in transaction processing in line %d.", line);
+			break;
+
+		case ECPG_CONNECT:
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+			  "Could not connect to database %s in line %d.", str, line);
+			break;
+
 		default:
-		    	snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"SQL error #%d in line %d.", code, line);
+			snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
+					 "SQL error #%d in line %d.", code, line);
 			break;
 	}
-	
+
 	sqlca.sqlerrm.sqlerrml = strlen(sqlca.sqlerrm.sqlerrmc);
 
-        /* free all memory we have allocated for the user */
-        free_auto_mem();
+	/* free all memory we have allocated for the user */
+	free_auto_mem();
 }
 
 /* print out an error message */
diff --git a/src/interfaces/ecpg/lib/execute.c b/src/interfaces/ecpg/lib/execute.c
index f8910aa7e8f8bf7c808876a5b8619ee8b57a1c47..43b7a6038765f7ebca6b2e7c8e4e56940cdb003a 100644
--- a/src/interfaces/ecpg/lib/execute.c
+++ b/src/interfaces/ecpg/lib/execute.c
@@ -54,9 +54,9 @@ struct variable
 /* keep a list of memory we allocated for the user */
 static struct auto_mem
 {
-       	void       *pointer;
-        struct auto_mem *next;
-} *auto_allocs = NULL;
+	void	   *pointer;
+	struct auto_mem *next;
+}		   *auto_allocs = NULL;
 
 static void
 add_mem(void *ptr, int lineno)
@@ -67,20 +67,21 @@ add_mem(void *ptr, int lineno)
 	auto_allocs = am;
 }
 
-void free_auto_mem(void)
+void
+free_auto_mem(void)
 {
 	struct auto_mem *am;
-	
-        /* free all memory we have allocated for the user */
-        for (am = auto_allocs; am;)
-        {
-        	struct auto_mem *act = am;
-	        
-	        am = am->next;
-	        free(act->pointer);
-	        free(act);
+
+	/* free all memory we have allocated for the user */
+	for (am = auto_allocs; am;)
+	{
+		struct auto_mem *act = am;
+
+		am = am->next;
+		free(act->pointer);
+		free(act);
 	}
-	
+
 	auto_allocs = NULL;
 }
 
@@ -245,7 +246,7 @@ next_insert(char *text)
 	bool		string = false;
 
 	for (; *ptr != '\0' && (*ptr != '?' || string); ptr++)
-		if (*ptr == '\'' && *(ptr-1) != '\\')
+		if (*ptr == '\'' && *(ptr - 1) != '\\')
 			string = string ? false : true;
 
 	return (*ptr == '\0') ? NULL : ptr;
@@ -256,7 +257,8 @@ ECPGexecute(struct statement * stmt)
 {
 	bool		status = false;
 	char	   *copiedquery;
-	PGresult   *results, *query;
+	PGresult   *results,
+			   *query;
 	PGnotify   *notify;
 	struct variable *var;
 
@@ -275,7 +277,7 @@ ECPGexecute(struct statement * stmt)
 		char	   *mallocedval = NULL;
 		char	   *tobeinserted = NULL;
 		char	   *p;
-		char	    buff[20];
+		char		buff[20];
 
 		/*
 		 * Some special treatment is needed for records since we want
@@ -311,20 +313,20 @@ ECPGexecute(struct statement * stmt)
 		{
 			switch (var->type)
 			{
-				int element;
-				
+					int			element;
+
 				case ECPGt_short:
 					if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
 						return false;
 
 					if (var->arrsize > 1)
 					{
-						strncpy(mallocedval, "'{", sizeof("'{")); 
-						
+						strncpy(mallocedval, "'{", sizeof("'{"));
+
 						for (element = 0; element < var->arrsize; element++)
 							sprintf(mallocedval + strlen(mallocedval), "%hd,", ((short *) var->value)[element]);
-						
-						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); 
+
+						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
 					}
 					else
 						sprintf(mallocedval, "%hd", *((short *) var->value));
@@ -338,12 +340,12 @@ ECPGexecute(struct statement * stmt)
 
 					if (var->arrsize > 1)
 					{
-						strncpy(mallocedval, "'{", sizeof("'{")); 
-						
+						strncpy(mallocedval, "'{", sizeof("'{"));
+
 						for (element = 0; element < var->arrsize; element++)
 							sprintf(mallocedval + strlen(mallocedval), "%d,", ((int *) var->value)[element]);
-						
-						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); 
+
+						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
 					}
 					else
 						sprintf(mallocedval, "%d", *((int *) var->value));
@@ -357,12 +359,12 @@ ECPGexecute(struct statement * stmt)
 
 					if (var->arrsize > 1)
 					{
-						strncpy(mallocedval, "'{", sizeof("'{")); 
-						
+						strncpy(mallocedval, "'{", sizeof("'{"));
+
 						for (element = 0; element < var->arrsize; element++)
 							sprintf(mallocedval + strlen(mallocedval), "%hu,", ((unsigned short *) var->value)[element]);
-						
-						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); 
+
+						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
 					}
 					else
 						sprintf(mallocedval, "%hu", *((unsigned short *) var->value));
@@ -376,12 +378,12 @@ ECPGexecute(struct statement * stmt)
 
 					if (var->arrsize > 1)
 					{
-						strncpy(mallocedval, "'{", sizeof("'{")); 
-						
+						strncpy(mallocedval, "'{", sizeof("'{"));
+
 						for (element = 0; element < var->arrsize; element++)
 							sprintf(mallocedval + strlen(mallocedval), "%u,", ((unsigned int *) var->value)[element]);
-						
-						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); 
+
+						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
 					}
 					else
 						sprintf(mallocedval, "%u", *((unsigned int *) var->value));
@@ -392,15 +394,15 @@ ECPGexecute(struct statement * stmt)
 				case ECPGt_long:
 					if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
 						return false;
-						
+
 					if (var->arrsize > 1)
 					{
-						strncpy(mallocedval, "'{", sizeof("'{")); 
-						
+						strncpy(mallocedval, "'{", sizeof("'{"));
+
 						for (element = 0; element < var->arrsize; element++)
 							sprintf(mallocedval + strlen(mallocedval), "%ld,", ((long *) var->value)[element]);
-						
-						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); 
+
+						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
 					}
 					else
 						sprintf(mallocedval, "%ld", *((long *) var->value));
@@ -414,12 +416,12 @@ ECPGexecute(struct statement * stmt)
 
 					if (var->arrsize > 1)
 					{
-						strncpy(mallocedval, "'{", sizeof("'{")); 
-						
+						strncpy(mallocedval, "'{", sizeof("'{"));
+
 						for (element = 0; element < var->arrsize; element++)
 							sprintf(mallocedval + strlen(mallocedval), "%lu,", ((unsigned long *) var->value)[element]);
-						
-						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); 
+
+						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
 					}
 					else
 						sprintf(mallocedval, "%lu", *((unsigned long *) var->value));
@@ -433,12 +435,12 @@ ECPGexecute(struct statement * stmt)
 
 					if (var->arrsize > 1)
 					{
-						strncpy(mallocedval, "'{", sizeof("'{")); 
-						
+						strncpy(mallocedval, "'{", sizeof("'{"));
+
 						for (element = 0; element < var->arrsize; element++)
 							sprintf(mallocedval + strlen(mallocedval), "%.14g,", ((float *) var->value)[element]);
-						
-						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); 
+
+						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
 					}
 					else
 						sprintf(mallocedval, "%.14g", *((float *) var->value));
@@ -452,12 +454,12 @@ ECPGexecute(struct statement * stmt)
 
 					if (var->arrsize > 1)
 					{
-						strncpy(mallocedval, "'{", sizeof("'{")); 
-						
+						strncpy(mallocedval, "'{", sizeof("'{"));
+
 						for (element = 0; element < var->arrsize; element++)
 							sprintf(mallocedval + strlen(mallocedval), "%.14g,", ((double *) var->value)[element]);
-						
-						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); 
+
+						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
 					}
 					else
 						sprintf(mallocedval, "%.14g", *((double *) var->value));
@@ -471,12 +473,12 @@ ECPGexecute(struct statement * stmt)
 
 					if (var->arrsize > 1)
 					{
-						strncpy(mallocedval, "'{", sizeof("'{")); 
-						
+						strncpy(mallocedval, "'{", sizeof("'{"));
+
 						for (element = 0; element < var->arrsize; element++)
 							sprintf(mallocedval + strlen(mallocedval), "%c,", (((char *) var->value)[element]) ? 't' : 'f');
-						
-						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); 
+
+						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
 					}
 					else
 						sprintf(mallocedval, "'%c'", (*((char *) var->value)) ? 't' : 'f');
@@ -541,7 +543,7 @@ ECPGexecute(struct statement * stmt)
 
 				default:
 					/* Not implemented yet */
-					ECPGraise(stmt->lineno, ECPG_UNSUPPORTED, (char *)ECPGtype_name(var->type));
+					ECPGraise(stmt->lineno, ECPG_UNSUPPORTED, (char *) ECPGtype_name(var->type));
 					return false;
 					break;
 			}
@@ -656,7 +658,7 @@ ECPGexecute(struct statement * stmt)
 				for (act_field = 0; act_field < nfields && status; act_field++)
 				{
 					char	   *array_query;
-					
+
 					if (var == NULL)
 					{
 						ECPGlog("ECPGexecute line %d: Too few arguments.\n", stmt->lineno);
@@ -664,16 +666,21 @@ ECPGexecute(struct statement * stmt)
 						return (false);
 					}
 
-					array_query = (char *)ecpg_alloc(strlen("select typelem from pg_type where oid=") + 11, stmt -> lineno);
+					array_query = (char *) ecpg_alloc(strlen("select typelem from pg_type where oid=") + 11, stmt->lineno);
 					sprintf(array_query, "select typelem from pg_type where oid=%d", PQftype(results, act_field));
 					query = PQexec(stmt->connection->connection, array_query);
 					isarray = 0;
-					if (PQresultStatus(query) == PGRES_TUPLES_OK) {
-						isarray = atol((char *)PQgetvalue(query, 0, 0));
+					if (PQresultStatus(query) == PGRES_TUPLES_OK)
+					{
+						isarray = atol((char *) PQgetvalue(query, 0, 0));
 						if (ECPGDynamicType(PQftype(results, act_field)) == SQL3_CHARACTER ||
-						    ECPGDynamicType(PQftype(results, act_field)) == SQL3_CHARACTER_VARYING)
+							ECPGDynamicType(PQftype(results, act_field)) == SQL3_CHARACTER_VARYING)
 						{
-							/* arrays of character strings are not yet implemented */
+
+							/*
+							 * arrays of character strings are not yet
+							 * implemented
+							 */
 							isarray = false;
 						}
 						ECPGlog("ECPGexecute line %d: TYPE database: %d C: %d array: %s\n", stmt->lineno, PQftype(results, act_field), var->type, isarray ? "yes" : "no");
@@ -682,14 +689,15 @@ ECPGexecute(struct statement * stmt)
 
 					if (!isarray)
 					{
+
 						/*
-						 * if we don't have enough space, we cannot read all
-						 * tuples
+						 * if we don't have enough space, we cannot read
+						 * all tuples
 						 */
 						if ((var->arrsize > 0 && ntuples > var->arrsize) || (var->ind_arrsize > 0 && ntuples > var->ind_arrsize))
 						{
 							ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d don't fit into array of %d\n",
-								stmt->lineno, ntuples, var->arrsize);
+									stmt->lineno, ntuples, var->arrsize);
 							ECPGraise(stmt->lineno, ECPG_TOO_MANY_MATCHES, NULL);
 							status = false;
 							break;
@@ -697,6 +705,7 @@ ECPGexecute(struct statement * stmt)
 					}
 					else
 					{
+
 						/*
 						 * since we read an array, the variable has to be
 						 * an array too
@@ -707,9 +716,9 @@ ECPGexecute(struct statement * stmt)
 							ECPGraise(stmt->lineno, ECPG_NO_ARRAY, NULL);
 							status = false;
 							break;
-						} 
+						}
 					}
-					
+
 					/*
 					 * allocate memory for NULL pointers
 					 */
@@ -744,13 +753,13 @@ ECPGexecute(struct statement * stmt)
 						*((void **) var->pointer) = var->value;
 						add_mem(var->value, stmt->lineno);
 					}
-										
+
 					for (act_tuple = 0; act_tuple < ntuples && status; act_tuple++)
 					{
 						if (!get_data(results, act_tuple, act_field, stmt->lineno,
-						         var->type, var->ind_type, var->value,
-						         var->ind_value, var->varcharsize, var->offset, isarray))
-						         status = false;
+									var->type, var->ind_type, var->value,
+									  var->ind_value, var->varcharsize, var->offset, isarray))
+							status = false;
 					}
 					var = var->next;
 				}
@@ -811,13 +820,13 @@ ECPGexecute(struct statement * stmt)
 }
 
 bool
-ECPGdo(int lineno, const char *connection_name, char *query, ...)
+ECPGdo(int lineno, const char *connection_name, char *query,...)
 {
-	va_list			args;
-	struct statement 	*stmt;
-	struct connection 	*con = get_connection(connection_name);
-	bool			status=true;
-	char 			*locale = setlocale(LC_NUMERIC, NULL);
+	va_list		args;
+	struct statement *stmt;
+	struct connection *con = get_connection(connection_name);
+	bool		status = true;
+	char	   *locale = setlocale(LC_NUMERIC, NULL);
 
 	/* Make sure we do NOT honor the locale for numeric input/output */
 	/* since the database wants teh standard decimal point */
@@ -826,7 +835,7 @@ ECPGdo(int lineno, const char *connection_name, char *query, ...)
 	if (!ecpg_init(con, connection_name, lineno))
 	{
 		setlocale(LC_NUMERIC, locale);
-		return(false);
+		return (false);
 	}
 
 	va_start(args, query);
@@ -859,26 +868,27 @@ ECPGdo(int lineno, const char *connection_name, char *query, ...)
  *
  * Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
  *
- * $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.5 2000/04/05 15:51:25 meskes Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.6 2000/04/12 17:17:03 momjian Exp $
  */
 
-PGconn *ECPG_internal_get_connection(char *name);
+PGconn	   *ECPG_internal_get_connection(char *name);
 
 extern struct descriptor
 {
-   char *name;
-   PGresult *result;
-   struct descriptor *next;
-} *all_descriptors;
+	char	   *name;
+	PGresult   *result;
+	struct descriptor *next;
+}		   *all_descriptors;
 
 /* like ECPGexecute */
-static bool execute_descriptor(int lineno,const char *query
-							,struct connection *con,PGresult **resultptr)
+static bool
+execute_descriptor(int lineno, const char *query
+				   ,struct connection * con, PGresult **resultptr)
 {
-	bool	status = false;
+	bool		status = false;
 	PGresult   *results;
 	PGnotify   *notify;
-	
+
 	/* Now the request is built. */
 
 	if (con->committed && !con->autocommit)
@@ -902,9 +912,12 @@ static bool execute_descriptor(int lineno,const char *query
 		ECPGraise(lineno, ECPG_PGSQL, PQerrorMessage(con->connection));
 	}
 	else
-	{	*resultptr=results;
+	{
+		*resultptr = results;
 		switch (PQresultStatus(results))
-		{	int ntuples;
+		{
+				int			ntuples;
+
 			case PGRES_TUPLES_OK:
 				status = true;
 				sqlca.sqlerrd[2] = ntuples = PQntuples(results);
@@ -917,7 +930,7 @@ static bool execute_descriptor(int lineno,const char *query
 					break;
 				}
 				break;
-#if 1 /* strictly these are not needed (yet) */
+#if 1							/* strictly these are not needed (yet) */
 			case PGRES_EMPTY_QUERY:
 				/* do nothing */
 				ECPGraise(lineno, ECPG_EMPTY, NULL);
@@ -972,20 +985,22 @@ static bool execute_descriptor(int lineno,const char *query
 }
 
 /* like ECPGdo */
-static bool do_descriptor2(int lineno,const char *connection_name,
-					PGresult **resultptr, const char *query)
+static bool
+do_descriptor2(int lineno, const char *connection_name,
+			   PGresult **resultptr, const char *query)
 {
 	struct connection *con = get_connection(connection_name);
-	bool		status=true;
-	char *locale = setlocale(LC_NUMERIC, NULL);
+	bool		status = true;
+	char	   *locale = setlocale(LC_NUMERIC, NULL);
 
 	/* Make sure we do NOT honor the locale for numeric input/output */
 	/* since the database wants teh standard decimal point */
 	setlocale(LC_NUMERIC, "C");
 
 	if (!ecpg_init(con, connection_name, lineno))
-	{	setlocale(LC_NUMERIC, locale);
-		return(false);
+	{
+		setlocale(LC_NUMERIC, locale);
+		return (false);
 	}
 
 	/* are we connected? */
@@ -997,33 +1012,38 @@ static bool do_descriptor2(int lineno,const char *connection_name,
 		return false;
 	}
 
-	status = execute_descriptor(lineno,query,con,resultptr);
+	status = execute_descriptor(lineno, query, con, resultptr);
 
 	/* and reset locale value so our application is not affected */
 	setlocale(LC_NUMERIC, locale);
 	return (status);
 }
 
-bool ECPGdo_descriptor(int line,const char *connection,
-							const char *descriptor,const char *query)
+bool
+ECPGdo_descriptor(int line, const char *connection,
+				  const char *descriptor, const char *query)
 {
 	struct descriptor *i;
-	for (i=all_descriptors;i!=NULL;i=i->next)
-	{	if (!strcmp(descriptor,i->name)) 
-	    {	
-			bool status;
+
+	for (i = all_descriptors; i != NULL; i = i->next)
+	{
+		if (!strcmp(descriptor, i->name))
+		{
+			bool		status;
 
 			/* free previous result */
-			if (i->result) PQclear(i->result);
-		    	i->result=NULL;
-	    	
-			status=do_descriptor2(line,connection,&i->result,query);
-			
-			if (!i->result) PQmakeEmptyPGresult(NULL, 0);
+			if (i->result)
+				PQclear(i->result);
+			i->result = NULL;
+
+			status = do_descriptor2(line, connection, &i->result, query);
+
+			if (!i->result)
+				PQmakeEmptyPGresult(NULL, 0);
 			return (status);
-	    }
+		}
 	}
-	
+
 	ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, (char *) descriptor);
 	return false;
 }
diff --git a/src/interfaces/ecpg/lib/extern.h b/src/interfaces/ecpg/lib/extern.h
index ef9515d7c964d382fe52ee63094adaa4d9b96d2a..86cc8bbab8749e30efa9f907664531b794b4135f 100644
--- a/src/interfaces/ecpg/lib/extern.h
+++ b/src/interfaces/ecpg/lib/extern.h
@@ -3,14 +3,14 @@
 
 /* Here are some methods used by the lib. */
 /* Returns a pointer to a string containing a simple type name. */
-void free_auto_mem(void);
+void		free_auto_mem(void);
 bool get_data(PGresult *, int, int, int, enum ECPGttype type,
-		enum ECPGttype, void *, void *, long, long, bool);
+		 enum ECPGttype, void *, void *, long, long, bool);
 struct connection *get_connection(const char *);
-void init_sqlca(void);
-char *ecpg_alloc(long, int);
-bool ecpg_init(const struct connection *, const char *, const int);
-char *ecpg_strdup(const char *, int);
+void		init_sqlca(void);
+char	   *ecpg_alloc(long, int);
+bool		ecpg_init(const struct connection *, const char *, const int);
+char	   *ecpg_strdup(const char *, int);
 const char *ECPGtype_name(enum ECPGttype);
 unsigned int ECPGDynamicType(Oid);
 
@@ -24,20 +24,19 @@ struct ECPGgeneric_varchar
 /* structure to store one statement */
 struct statement
 {
-        int                     lineno;
-        char       *command;
-        struct connection *connection;
-        struct variable *inlist;
-        struct variable *outlist;
+	int			lineno;
+	char	   *command;
+	struct connection *connection;
+	struct variable *inlist;
+	struct variable *outlist;
 };
 
 /* structure to store connections */
 struct connection
 {
-       	char            *name;
-       	PGconn          *connection;
-        bool            committed;
-        int             autocommit;
-        struct connection *next;
+	char	   *name;
+	PGconn	   *connection;
+	bool		committed;
+	int			autocommit;
+	struct connection *next;
 };
-                
diff --git a/src/interfaces/ecpg/lib/misc.c b/src/interfaces/ecpg/lib/misc.c
index 55e0cfc81775aba9a0efbb74fe24f0412d4a2cf6..dbfb8b810de2dbd98538dd5e8df4a188c371c3a2 100644
--- a/src/interfaces/ecpg/lib/misc.c
+++ b/src/interfaces/ecpg/lib/misc.c
@@ -27,7 +27,7 @@ init_sqlca(void)
 }
 
 bool
-ecpg_init(const struct connection *con, const char * connection_name, const int lineno)
+ecpg_init(const struct connection * con, const char *connection_name, const int lineno)
 {
 	init_sqlca();
 	if (con == NULL)
@@ -35,7 +35,7 @@ ecpg_init(const struct connection *con, const char * connection_name, const int
 		ECPGraise(lineno, ECPG_NO_CONN, connection_name ? connection_name : "NULL");
 		return (false);
 	}
-	
+
 	return (true);
 }
 
@@ -45,7 +45,7 @@ ECPGstatus(int lineno, const char *connection_name)
 	struct connection *con = get_connection(connection_name);
 
 	if (!ecpg_init(con, connection_name, lineno))
-		return(false);
+		return (false);
 
 	/* are we connected? */
 	if (con->connection == NULL)
@@ -65,7 +65,7 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction)
 	struct connection *con = get_connection(connection_name);
 
 	if (!ecpg_init(con, connection_name, lineno))
-		return(false);
+		return (false);
 
 	ECPGlog("ECPGtrans line %d action = %s connection = %s\n", lineno, transaction, con->name);
 
@@ -79,14 +79,14 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction)
 		}
 		PQclear(res);
 	}
-	
+
 	if (strcmp(transaction, "commit") == 0 || strcmp(transaction, "rollback") == 0)
 	{
 		con->committed = true;
 
 		/* deallocate all prepared statements */
 		if (!ECPGdeallocate_all(lineno))
-				return false;
+			return false;
 	}
 
 	return true;
diff --git a/src/interfaces/ecpg/lib/prepare.c b/src/interfaces/ecpg/lib/prepare.c
index 2155177edec0615e8f15616b4f7fbe6ace6ce5bb..c49d44ab8d8a46622dd3ba0ffe4cae2a5f5af265 100644
--- a/src/interfaces/ecpg/lib/prepare.c
+++ b/src/interfaces/ecpg/lib/prepare.c
@@ -8,10 +8,10 @@
 
 static struct prepared_statement
 {
-        char       *name;
-        struct statement *stmt;
-        struct prepared_statement *next;
-}                  *prep_stmts = NULL;
+	char	   *name;
+	struct statement *stmt;
+	struct prepared_statement *next;
+}		   *prep_stmts = NULL;
 
 static bool
 isvarchar(unsigned char c)
@@ -47,7 +47,7 @@ replace_variables(char *text)
 		}
 	}
 }
-                        
+
 /* handle the EXEC SQL PREPARE statement */
 bool
 ECPGprepare(int lineno, char *name, char *variable)
@@ -117,7 +117,7 @@ ECPGdeallocate(int lineno, char *name)
 			prev->next = this->next;
 		else
 			prep_stmts = this->next;
-		
+
 		free(this);
 		return true;
 	}
@@ -130,15 +130,15 @@ bool
 ECPGdeallocate_all(int lineno)
 {
 	/* deallocate all prepared statements */
-	 while(prep_stmts != NULL)
-	 {
-		bool b = ECPGdeallocate(lineno, prep_stmts->name);
-		
-	        if (!b)
+	while (prep_stmts != NULL)
+	{
+		bool		b = ECPGdeallocate(lineno, prep_stmts->name);
+
+		if (!b)
 			return false;
-         }
-         
-         return true;
+	}
+
+	return true;
 }
 
 /* return the prepared statement */
diff --git a/src/interfaces/ecpg/lib/typename.c b/src/interfaces/ecpg/lib/typename.c
index 2b64c19a8ce20c3ac78acb48ed84b614ab7ad513..19f1fcdbf23c645006a07ff995b1bcb178daaeed 100644
--- a/src/interfaces/ecpg/lib/typename.c
+++ b/src/interfaces/ecpg/lib/typename.c
@@ -12,7 +12,7 @@ ECPGtype_name(enum ECPGttype typ)
 {
 	switch (typ)
 	{
-		case ECPGt_char:
+			case ECPGt_char:
 			return "char";
 		case ECPGt_unsigned_char:
 			return "unsigned char";
@@ -47,21 +47,34 @@ ECPGtype_name(enum ECPGttype typ)
 unsigned int
 ECPGDynamicType(Oid type)
 {
-	switch(type)
+	switch (type)
 	{
-		case 16:	return SQL3_BOOLEAN;	/* bool */
-		case 21:	return SQL3_SMALLINT;	/* int2 */
-		case 23:	return SQL3_INTEGER;	/* int4 */
-		case 25:	return SQL3_CHARACTER;	/* text */
-		case 700:	return SQL3_REAL;		/* float4 */
-		case 701:	return SQL3_DOUBLE_PRECISION;	/* float8 */
-		case 1042:	return SQL3_CHARACTER;	/* bpchar */
-		case 1043:	return SQL3_CHARACTER_VARYING;	/* varchar */
-		case 1082:	return SQL3_DATE_TIME_TIMESTAMP;	/* date */
-		case 1083:	return SQL3_DATE_TIME_TIMESTAMP;	/* time */
-		case 1184:	return SQL3_DATE_TIME_TIMESTAMP;	/* datetime */
-		case 1296:	return SQL3_DATE_TIME_TIMESTAMP;	/* timestamp */
-		case 1700:	return SQL3_NUMERIC;	/* numeric */
-		default:	return -type;
+			case 16:return SQL3_BOOLEAN;		/* bool */
+		case 21:
+			return SQL3_SMALLINT;		/* int2 */
+		case 23:
+			return SQL3_INTEGER;/* int4 */
+		case 25:
+			return SQL3_CHARACTER;		/* text */
+		case 700:
+			return SQL3_REAL;	/* float4 */
+		case 701:
+			return SQL3_DOUBLE_PRECISION;		/* float8 */
+		case 1042:
+			return SQL3_CHARACTER;		/* bpchar */
+		case 1043:
+			return SQL3_CHARACTER_VARYING;		/* varchar */
+		case 1082:
+			return SQL3_DATE_TIME_TIMESTAMP;	/* date */
+		case 1083:
+			return SQL3_DATE_TIME_TIMESTAMP;	/* time */
+		case 1184:
+			return SQL3_DATE_TIME_TIMESTAMP;	/* datetime */
+		case 1296:
+			return SQL3_DATE_TIME_TIMESTAMP;	/* timestamp */
+		case 1700:
+			return SQL3_NUMERIC;/* numeric */
+		default:
+			return -type;
 	}
 }
diff --git a/src/interfaces/ecpg/preproc/descriptor.c b/src/interfaces/ecpg/preproc/descriptor.c
index e55aa886cf807fff3350df97be07bd346925e1d4..792b286d8c0cd21109b4344246871e681bb43bb3 100644
--- a/src/interfaces/ecpg/preproc/descriptor.c
+++ b/src/interfaces/ecpg/preproc/descriptor.c
@@ -3,18 +3,19 @@
  */
 
 #include "postgres.h"
-#include "extern.h" 
+#include "extern.h"
 
 /*
  * assignment handling function (descriptor)
  */
- 
+
 struct assignment *assignments;
 
-void push_assignment(char *var, enum ECPGdtype value)
+void
+push_assignment(char *var, enum ECPGdtype value)
 {
-	struct assignment *new = (struct assignment *)mm_alloc(sizeof(struct assignment));
-	
+	struct assignment *new = (struct assignment *) mm_alloc(sizeof(struct assignment));
+
 	new->next = assignments;
 	new->variable = mm_alloc(strlen(var) + 1);
 	strcpy(new->variable, var);
@@ -35,91 +36,94 @@ drop_assignments(void)
 	}
 }
 
-static void ECPGnumeric_lvalue(FILE *f,char *name)
+static void
+ECPGnumeric_lvalue(FILE *f, char *name)
 {
-	const struct variable *v=find_variable(name);
+	const struct variable *v = find_variable(name);
 
-	switch(v->type->typ)
+	switch (v->type->typ)
 	{
 		case ECPGt_short:
-		case ECPGt_int: 
+		case ECPGt_int:
 		case ECPGt_long:
 		case ECPGt_unsigned_short:
 		case ECPGt_unsigned_int:
 		case ECPGt_unsigned_long:
-			fputs(name,yyout);
+			fputs(name, yyout);
 			break;
 		default:
-			snprintf(errortext,sizeof errortext,"variable %s: numeric type needed"
-					,name);
-			mmerror(ET_ERROR,errortext);
+			snprintf(errortext, sizeof errortext, "variable %s: numeric type needed"
+					 ,name);
+			mmerror(ET_ERROR, errortext);
 			break;
-	}	 
+	}
 }
 
 /*
  * descriptor name lookup
  */
- 
+
 static struct descriptor *descriptors;
 
-void add_descriptor(char *name,char *connection)
+void
+add_descriptor(char *name, char *connection)
 {
-	struct descriptor *new = (struct descriptor *)mm_alloc(sizeof(struct descriptor));
-	
+	struct descriptor *new = (struct descriptor *) mm_alloc(sizeof(struct descriptor));
+
 	new->next = descriptors;
 	new->name = mm_alloc(strlen(name) + 1);
-	strcpy(new->name,name);
-	if (connection) 
+	strcpy(new->name, name);
+	if (connection)
 	{
 		new->connection = mm_alloc(strlen(connection) + 1);
 		strcpy(new->connection, connection);
 	}
-	else new->connection = connection;
+	else
+		new->connection = connection;
 	descriptors = new;
 }
 
 void
-drop_descriptor(char *name,char *connection)
+drop_descriptor(char *name, char *connection)
 {
 	struct descriptor *i;
-	struct descriptor **lastptr=&descriptors;
-	
-	for (i=descriptors;i;lastptr=&i->next,i=i->next)
+	struct descriptor **lastptr = &descriptors;
+
+	for (i = descriptors; i; lastptr = &i->next, i = i->next)
 	{
-		if (!strcmp(name,i->name))
+		if (!strcmp(name, i->name))
 		{
-			if ((!connection && !i->connection) 
-				|| (connection && i->connection 
-					&& !strcmp(connection,i->connection)))
+			if ((!connection && !i->connection)
+				|| (connection && i->connection
+					&& !strcmp(connection, i->connection)))
 			{
-				*lastptr=i->next;
-				if (i->connection) free(i->connection);
+				*lastptr = i->next;
+				if (i->connection)
+					free(i->connection);
 				free(i->name);
 				free(i);
 				return;
 			}
 		}
 	}
-	snprintf(errortext,sizeof errortext,"unknown descriptor %s",name);
-	mmerror(ET_WARN,errortext);
+	snprintf(errortext, sizeof errortext, "unknown descriptor %s", name);
+	mmerror(ET_WARN, errortext);
 }
 
 struct descriptor
-*lookup_descriptor(char *name, char *connection)
+		   *
+lookup_descriptor(char *name, char *connection)
 {
 	struct descriptor *i;
-	
+
 	for (i = descriptors; i; i = i->next)
 	{
 		if (!strcmp(name, i->name))
 		{
-			if ((!connection && !i->connection) 
-				|| (connection && i->connection 
-					&& !strcmp(connection,i->connection)))
-			{
+			if ((!connection && !i->connection)
+				|| (connection && i->connection
+					&& !strcmp(connection, i->connection)))
 				return i;
-			}
 		}
 	}
 	snprintf(errortext, sizeof errortext, "unknown descriptor %s", name);
@@ -136,14 +140,14 @@ output_get_descr_header(char *desc_name)
 	for (results = assignments; results != NULL; results = results->next)
 	{
 		if (results->value == ECPGd_count)
-			ECPGnumeric_lvalue(yyout,results->variable);
+			ECPGnumeric_lvalue(yyout, results->variable);
 		else
 		{
 			snprintf(errortext, sizeof errortext, "unknown descriptor header item '%d'", results->value);
 			mmerror(ET_WARN, errortext);
 		}
 	}
-	
+
 	drop_assignments();
 	fprintf(yyout, "));\n");
 	whenever_action(3);
@@ -154,27 +158,27 @@ output_get_descr(char *desc_name, char *index)
 {
 	struct assignment *results;
 
-	fprintf(yyout, "{ ECPGget_desc(%d,\"%s\",%s,", yylineno, desc_name, index);	
+	fprintf(yyout, "{ ECPGget_desc(%d,\"%s\",%s,", yylineno, desc_name, index);
 	for (results = assignments; results != NULL; results = results->next)
 	{
 		const struct variable *v = find_variable(results->variable);
-		
+
 		switch (results->value)
 		{
 			case ECPGd_nullable:
-				mmerror(ET_WARN,"nullable is always 1");
+				mmerror(ET_WARN, "nullable is always 1");
 				break;
 			case ECPGd_key_member:
-				mmerror(ET_WARN,"key_member is always 0");
+				mmerror(ET_WARN, "key_member is always 0");
 				break;
 			default:
-				break; 
+				break;
 		}
 		fprintf(yyout, "%s,", get_dtype(results->value));
 		ECPGdump_a_type(yyout, v->name, v->type, NULL, NULL, NULL, NULL);
 	}
 	drop_assignments();
-	fputs("ECPGd_EODT);\n",yyout);
-	
-	whenever_action(2|1);
+	fputs("ECPGd_EODT);\n", yyout);
+
+	whenever_action(2 | 1);
 }
diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c
index 31bc48752f76dc3b6adb7b7a62306cbe711331fe..1cc00dbcc7cb01925b117202614c3b34b2be89c6 100644
--- a/src/interfaces/ecpg/preproc/ecpg.c
+++ b/src/interfaces/ecpg/preproc/ecpg.c
@@ -11,7 +11,8 @@
 
 #include "extern.h"
 
-int		ret_value = OK, autocommit = 0;
+int			ret_value = OK,
+			autocommit = 0;
 struct _include_path *include_paths = NULL;
 struct cursor *cur = NULL;
 struct typedefs *types = NULL;
@@ -85,8 +86,8 @@ main(int argc, char *const argv[])
 				verbose = true;
 				break;
 			case 'D':
-                		add_preprocessor_define(optarg);
-		                break;
+				add_preprocessor_define(optarg);
+				break;
 			default:
 				usage(argv[0]);
 				return ILLEGAL_OPTION;
@@ -102,7 +103,7 @@ main(int argc, char *const argv[])
 		fprintf(stderr, "End of search list.\n");
 		return OK;
 	}
-	
+
 	if (optind >= argc)			/* no files specified */
 	{
 		usage(argv[0]);
@@ -123,7 +124,7 @@ main(int argc, char *const argv[])
 			/* take care of relative paths */
 			ptr2ext = strrchr(input_filename, '/');
 			ptr2ext = (ptr2ext ? strrchr(ptr2ext, '.') : strrchr(input_filename, '.'));
-			
+
 			/* no extension? */
 			if (ptr2ext == NULL)
 			{
@@ -137,7 +138,7 @@ main(int argc, char *const argv[])
 				ptr2ext[4] = '\0';
 			}
 
-			if (out_option == 0) /* calculate the output name */
+			if (out_option == 0)/* calculate the output name */
 			{
 				output_filename = strdup(input_filename);
 
@@ -177,7 +178,8 @@ main(int argc, char *const argv[])
 				for (ptr = cur; ptr != NULL;)
 				{
 					struct cursor *this = ptr;
-					struct arguments *l1, *l2;
+					struct arguments *l1,
+							   *l2;
 
 					free(ptr->command);
 					free(ptr->connection);
@@ -198,26 +200,28 @@ main(int argc, char *const argv[])
 				cur = NULL;
 
 				/* remove non-pertinent old defines as well */
-				while ( defines && !defines->pertinent ) {
-				    defptr = defines;
-				    defines = defines->next;
+				while (defines && !defines->pertinent)
+				{
+					defptr = defines;
+					defines = defines->next;
 
-				    free(defptr->new);
-				    free(defptr->old);
-				    free(defptr);
+					free(defptr->new);
+					free(defptr->old);
+					free(defptr);
 				}
 
-				for (defptr = defines; defptr != NULL; defptr = defptr->next )
+				for (defptr = defines; defptr != NULL; defptr = defptr->next)
 				{
-				    struct _defines *this = defptr->next;
-					
-				    if ( this && !this->pertinent ) {
-					defptr->next = this->next;
+					struct _defines *this = defptr->next;
 
-					free(this->new);
-					free(this->old);
-					free(this);
-				    }
+					if (this && !this->pertinent)
+					{
+						defptr->next = this->next;
+
+						free(this->new);
+						free(this->old);
+						free(this);
+					}
 				}
 
 				/* and old typedefs */
@@ -232,18 +236,18 @@ main(int argc, char *const argv[])
 					free(this);
 				}
 				types = NULL;
-				
+
 				/* initialize whenever structures */
 				memset(&when_error, 0, sizeof(struct when));
 				memset(&when_nf, 0, sizeof(struct when));
 				memset(&when_warn, 0, sizeof(struct when));
-				
+
 				/* and structure member lists */
 				memset(struct_member_list, 0, sizeof(struct_member_list));
-				
+
 				/* finally the actual connection */
 				connection = NULL;
-				
+
 				/* initialize lex */
 				lex_init();
 
diff --git a/src/interfaces/ecpg/preproc/ecpg_keywords.c b/src/interfaces/ecpg/preproc/ecpg_keywords.c
index 0a468c041eadd598f5bd183d51009140e76ee1c1..a1a0452e1cbb2e35e27b5e250ea969c34eac2468 100644
--- a/src/interfaces/ecpg/preproc/ecpg_keywords.c
+++ b/src/interfaces/ecpg/preproc/ecpg_keywords.c
@@ -61,7 +61,8 @@ static ScanKeyword ScanKeywords[] = {
 	{"section", SQL_SECTION},
 	{"short", SQL_SHORT},
 	{"signed", SQL_SIGNED},
-	{"sql",SQL_SQL}, /* strange thing, used for into sql descriptor MYDESC; */
+	{"sql", SQL_SQL},			/* strange thing, used for into sql
+								 * descriptor MYDESC; */
 	{"sqlerror", SQL_SQLERROR},
 	{"sqlprint", SQL_SQLPRINT},
 	{"sqlwarning", SQL_SQLWARNING},
diff --git a/src/interfaces/ecpg/preproc/extern.h b/src/interfaces/ecpg/preproc/extern.h
index bcdba111915701126902284c18e3699bc01142b7..779985ac16914ab0c1b9a94e907368bb65fbe8ea 100644
--- a/src/interfaces/ecpg/preproc/extern.h
+++ b/src/interfaces/ecpg/preproc/extern.h
@@ -10,16 +10,19 @@
 /* variables */
 
 extern int	braces_open,
-		autocommit,
-		ret_value,
-		struct_level;
+			autocommit,
+			ret_value,
+			struct_level;
 extern char *descriptor_index;
 extern char *descriptor_name;
 extern char *connection;
-extern char 	*input_filename;
-extern char 	*yytext, errortext[128];
-extern int	yylineno, yyleng;
-extern FILE *yyin, *yyout;
+extern char *input_filename;
+extern char *yytext,
+			errortext[128];
+extern int	yylineno,
+			yyleng;
+extern FILE *yyin,
+		   *yyout;
 
 extern struct _include_path *include_paths;
 extern struct cursor *cur;
@@ -29,7 +32,9 @@ extern struct ECPGtype ecpg_no_indicator;
 extern struct variable no_indicator;
 extern struct arguments *argsinsert;
 extern struct arguments *argsresult;
-extern struct when when_error, when_nf, when_warn;
+extern struct when when_error,
+			when_nf,
+			when_warn;
 extern struct ECPGstruct_member *struct_member_list[STRUCT_DEPTH];
 extern struct descriptor *descriptors;
 
@@ -47,19 +52,19 @@ extern int	yylex(void);
 extern void yyerror(char *);
 extern void *mm_alloc(size_t), *mm_realloc(void *, size_t);
 extern char *mm_strdup(const char *);
-extern void mmerror(enum errortype, char * );
+extern void mmerror(enum errortype, char *);
 extern ScanKeyword *ScanECPGKeywordLookup(char *);
 extern ScanKeyword *ScanCKeywordLookup(char *);
 extern void output_get_descr_header(char *);
 extern void output_get_descr(char *, char *);
 extern void push_assignment(char *, enum ECPGdtype);
-extern struct variable * find_variable(char *);
+extern struct variable *find_variable(char *);
 extern void whenever_action(int);
-extern void add_descriptor(char *,char *);
-extern void drop_descriptor(char *,char *);
-extern struct descriptor *lookup_descriptor(char *,char *);
-extern void add_variable(struct arguments ** , struct variable * , struct variable *);
-extern void append_variable(struct arguments ** , struct variable * , struct variable *);
+extern void add_descriptor(char *, char *);
+extern void drop_descriptor(char *, char *);
+extern struct descriptor *lookup_descriptor(char *, char *);
+extern void add_variable(struct arguments **, struct variable *, struct variable *);
+extern void append_variable(struct arguments **, struct variable *, struct variable *);
 extern void dump_variables(struct arguments *, int);
 extern struct typedefs *get_typedef(char *);
 extern void adjust_array(enum ECPGttype, int *, int *, int, int, bool);
@@ -67,13 +72,13 @@ extern void reset_variables(void);
 extern void check_indicator(struct ECPGtype *);
 extern void remove_variables(int);
 extern struct variable *new_variable(const char *, struct ECPGtype *);
- 
+
 /* return codes */
 
 #define OK			 0
 #define PARSE_ERROR		-1
 #define ILLEGAL_OPTION		-2
-#define INDICATOR_NOT_ARRAY	-3
+#define INDICATOR_NOT_ARRAY -3
 
 #define NO_INCLUDE_FILE		ENOENT
 #define OUT_OF_MEMORY		ENOMEM
diff --git a/src/interfaces/ecpg/preproc/output.c b/src/interfaces/ecpg/preproc/output.c
index 760751affd3a6bd48effda2b4643ea73ee529a9b..7fe282586f62efc869c590e687a6d8f5a8588b77 100644
--- a/src/interfaces/ecpg/preproc/output.c
+++ b/src/interfaces/ecpg/preproc/output.c
@@ -6,74 +6,83 @@
 void
 output_line_number()
 {
-    if (input_filename)
-       fprintf(yyout, "\n#line %d \"%s\"\n", yylineno, input_filename);
+	if (input_filename)
+		fprintf(yyout, "\n#line %d \"%s\"\n", yylineno, input_filename);
 }
 
 void
 output_simple_statement(char *cmd)
 {
-	int i, j = strlen(cmd);;
-	
+	int			i,
+				j = strlen(cmd);;
+
 	/* do this char by char as we have to filter '\"' */
-	for (i = 0; i < j; i++) {
+	for (i = 0; i < j; i++)
+	{
 		if (cmd[i] != '"')
 			fputc(cmd[i], yyout);
 		else
 			fputs("\\\"", yyout);
 	}
 	output_line_number();
-        free(cmd);
+	free(cmd);
 }
 
 /*
  * store the whenever action here
  */
-struct when when_error, when_nf, when_warn;
+struct when when_error,
+			when_nf,
+			when_warn;
 
 static void
-print_action(struct when *w)
+print_action(struct when * w)
 {
 	switch (w->code)
 	{
-		case W_SQLPRINT: fprintf(yyout, "sqlprint();");
-                                 break;
-		case W_GOTO:	 fprintf(yyout, "goto %s;", w->command);
-				 break;
-		case W_DO:	 fprintf(yyout, "%s;", w->command);
-				 break;
-		case W_STOP:	 fprintf(yyout, "exit (1);");
-				 break;
-		case W_BREAK:	 fprintf(yyout, "break;");
-				 break;
-		default:	 fprintf(yyout, "{/* %d not implemented yet */}", w->code);
-				 break;
+			case W_SQLPRINT:fprintf(yyout, "sqlprint();");
+			break;
+		case W_GOTO:
+			fprintf(yyout, "goto %s;", w->command);
+			break;
+		case W_DO:
+			fprintf(yyout, "%s;", w->command);
+			break;
+		case W_STOP:
+			fprintf(yyout, "exit (1);");
+			break;
+		case W_BREAK:
+			fprintf(yyout, "break;");
+			break;
+		default:
+			fprintf(yyout, "{/* %d not implemented yet */}", w->code);
+			break;
 	}
 }
 
 void
 whenever_action(int mode)
 {
-	if ((mode&1) ==  1 && when_nf.code != W_NOTHING)
+	if ((mode & 1) == 1 && when_nf.code != W_NOTHING)
 	{
 		output_line_number();
 		fprintf(yyout, "\nif (sqlca.sqlcode == ECPG_NOT_FOUND) ");
 		print_action(&when_nf);
 	}
 	if (when_warn.code != W_NOTHING)
-        {
+	{
 		output_line_number();
-                fprintf(yyout, "\nif (sqlca.sqlwarn[0] == 'W') ");
+		fprintf(yyout, "\nif (sqlca.sqlwarn[0] == 'W') ");
 		print_action(&when_warn);
-        }
+	}
 	if (when_error.code != W_NOTHING)
-        {
+	{
 		output_line_number();
-                fprintf(yyout, "\nif (sqlca.sqlcode < 0) ");
+		fprintf(yyout, "\nif (sqlca.sqlcode < 0) ");
 		print_action(&when_error);
-        }
+	}
 
-	if ((mode&2) == 2)
+	if ((mode & 2) == 2)
 		fputc('}', yyout);
 
 	output_line_number();
@@ -82,30 +91,33 @@ whenever_action(int mode)
 char *
 hashline_number(void)
 {
-    if (input_filename)
-    {
-	char* line = mm_alloc(strlen("\n#line %d \"%s\"\n") + 21 + strlen(input_filename));
-	sprintf(line, "\n#line %d \"%s\"\n", yylineno, input_filename);
+	if (input_filename)
+	{
+		char	   *line = mm_alloc(strlen("\n#line %d \"%s\"\n") + 21 + strlen(input_filename));
 
-	return line;
-    }
+		sprintf(line, "\n#line %d \"%s\"\n", yylineno, input_filename);
 
-    return EMPTY;
+		return line;
+	}
+
+	return EMPTY;
 }
 
 void
-output_statement(char * stmt, int mode, char *descriptor, char *con)
+output_statement(char *stmt, int mode, char *descriptor, char *con)
 {
-	int i, j = strlen(stmt);
+	int			i,
+				j = strlen(stmt);
 
 	if (descriptor == NULL)
 		fprintf(yyout, "{ ECPGdo(__LINE__, %s, \"", con ? con : "NULL");
 	else
-	        fprintf(yyout, "{ ECPGdo_descriptor(__LINE__, %s, \"%s\", \"",
-	                        con ? con : "NULL", descriptor);
+		fprintf(yyout, "{ ECPGdo_descriptor(__LINE__, %s, \"%s\", \"",
+				con ? con : "NULL", descriptor);
 
 	/* do this char by char as we have to filter '\"' */
-	for (i = 0; i < j; i++) {
+	for (i = 0; i < j; i++)
+	{
 		if (stmt[i] != '"')
 			fputc(stmt[i], yyout);
 		else
@@ -115,7 +127,7 @@ output_statement(char * stmt, int mode, char *descriptor, char *con)
 	if (descriptor == NULL)
 	{
 		fputs("\", ", yyout);
-		
+
 		/* dump variables to C file */
 		dump_variables(argsinsert, 1);
 		fputs("ECPGt_EOIT, ", yyout);
@@ -125,7 +137,7 @@ output_statement(char * stmt, int mode, char *descriptor, char *con)
 	}
 	else
 		fputs("\");", yyout);
-	
+
 	mode |= 2;
 	whenever_action(mode);
 	free(stmt);
@@ -134,4 +146,3 @@ output_statement(char * stmt, int mode, char *descriptor, char *con)
 	if (connection != NULL)
 		free(connection);
 }
-
diff --git a/src/interfaces/ecpg/preproc/type.c b/src/interfaces/ecpg/preproc/type.c
index 95c79e3f09ea8683fdefa8be6e2b6571d4257218..8d292e1109816b97c0cecc910f96a9a03341a0dd 100644
--- a/src/interfaces/ecpg/preproc/type.c
+++ b/src/interfaces/ecpg/preproc/type.c
@@ -124,7 +124,7 @@ get_type(enum ECPGttype typ)
 {
 	switch (typ)
 	{
-		case ECPGt_char:
+			case ECPGt_char:
 			return ("ECPGt_char");
 			break;
 		case ECPGt_unsigned_char:
@@ -163,7 +163,7 @@ get_type(enum ECPGttype typ)
 			return ("ECPGt_NO_INDICATOR");
 			break;
 		case ECPGt_char_variable:		/* string that should not be
-							 * quoted */
+										 * quoted */
 			return ("ECPGt_char_variable");
 			break;
 		default:
@@ -200,10 +200,10 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * typ, const char *in
 {
 	switch (typ->typ)
 	{
-		case ECPGt_array:
+			case ECPGt_array:
 			switch (typ->u.element->typ)
 			{
-				case ECPGt_array:
+					case ECPGt_array:
 					yyerror("No nested arrays allowed (except strings)");		/* array of array */
 					break;
 				case ECPGt_struct:
@@ -269,7 +269,11 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype typ,
 		switch (typ)
 		{
 			case ECPGt_varchar:
-				/* we have to use the pointer except for arrays with given bounds */
+
+				/*
+				 * we have to use the pointer except for arrays with given
+				 * bounds
+				 */
 				if (arrsize > 0)
 					sprintf(variable, "(%s%s)", prefix ? prefix : "", name);
 				else
@@ -280,7 +284,11 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype typ,
 			case ECPGt_char:
 			case ECPGt_unsigned_char:
 			case ECPGt_char_variable:
-				/* we have to use the pointer except for arrays with given bounds */
+
+				/*
+				 * we have to use the pointer except for arrays with given
+				 * bounds
+				 */
 				if (varcharsize > 1 || arrsize > 0)
 					sprintf(variable, "(%s%s)", prefix ? prefix : "", name);
 				else
@@ -289,7 +297,11 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype typ,
 				sprintf(offset, "%ld*sizeof(char)", varcharsize == 0 ? 1 : varcharsize);
 				break;
 			default:
-				/* we have to use the pointer except for arrays with given bounds */
+
+				/*
+				 * we have to use the pointer except for arrays with given
+				 * bounds
+				 */
 				if (arrsize > 0)
 					sprintf(variable, "(%s%s)", prefix ? prefix : "", name);
 				else
@@ -375,10 +387,10 @@ ECPGfree_type(struct ECPGtype * typ)
 	{
 		switch (typ->typ)
 		{
-			case ECPGt_array:
+				case ECPGt_array:
 				switch (typ->u.element->typ)
 				{
-					case ECPGt_array:
+						case ECPGt_array:
 						yyerror("internal error, found multi-dimensional array\n");
 						break;
 					case ECPGt_struct:
@@ -412,7 +424,7 @@ get_dtype(enum ECPGdtype typ)
 {
 	switch (typ)
 	{
-		case ECPGd_count:
+			case ECPGd_count:
 			return ("ECPGd_countr");
 			break;
 		case ECPGd_data:
@@ -450,10 +462,10 @@ get_dtype(enum ECPGdtype typ)
 		case ECPGd_ret_octet:
 			return ("ECPGd_ret_octet");
 			break;
-		case ECPGd_scale:	
+		case ECPGd_scale:
 			return ("ECPGd_scale");
 			break;
-		case ECPGd_type:	
+		case ECPGd_type:
 			return ("ECPGd_type");
 			break;
 		default:
diff --git a/src/interfaces/ecpg/preproc/type.h b/src/interfaces/ecpg/preproc/type.h
index 29525c392c3d9cefa0f5de17d962e58cf87c4a85..7ce1e89287055fdac919d468adea60dac3a54f41 100644
--- a/src/interfaces/ecpg/preproc/type.h
+++ b/src/interfaces/ecpg/preproc/type.h
@@ -119,7 +119,7 @@ struct _defines
 {
 	char	   *old;
 	char	   *new;
-	int	   pertinent;
+	int			pertinent;
 	struct _defines *next;
 };
 
@@ -141,22 +141,25 @@ struct arguments
 
 struct descriptor
 {
-	char	*name;
-	char	*connection;
+	char	   *name;
+	char	   *connection;
 	struct descriptor *next;
 };
 
 struct assignment
-{	
-	char 			*variable;
-	enum ECPGdtype		value;
-	struct assignment 	*next;
+{
+	char	   *variable;
+	enum ECPGdtype value;
+	struct assignment *next;
 };
 
-enum errortype {ET_WARN, ET_ERROR, ET_FATAL};
+enum errortype
+{
+	ET_WARN, ET_ERROR, ET_FATAL
+};
 
 struct fetch_desc
 {
-	char *str;
-	char *name;
+	char	   *str;
+	char	   *name;
 };
diff --git a/src/interfaces/ecpg/preproc/variable.c b/src/interfaces/ecpg/preproc/variable.c
index 3de45350b1cf2af8c3e44cc822302e3af0cfdb17..f3d2dca05976fbbbc50f0eb04d28f9dbc9df3e1f 100644
--- a/src/interfaces/ecpg/preproc/variable.c
+++ b/src/interfaces/ecpg/preproc/variable.c
@@ -2,174 +2,177 @@
 
 #include "extern.h"
 
-struct variable * allvariables = NULL;
+struct variable *allvariables = NULL;
 
 struct variable *
-new_variable(const char * name, struct ECPGtype * type)
+new_variable(const char *name, struct ECPGtype * type)
 {
-    struct variable * p = (struct variable*) mm_alloc(sizeof(struct variable));
+	struct variable *p = (struct variable *) mm_alloc(sizeof(struct variable));
 
-    p->name = mm_strdup(name);
-    p->type = type;
-    p->brace_level = braces_open;
+	p->name = mm_strdup(name);
+	p->type = type;
+	p->brace_level = braces_open;
 
-    p->next = allvariables;
-    allvariables = p;
+	p->next = allvariables;
+	allvariables = p;
 
-    return(p);
+	return (p);
 }
 
 static struct variable *
-find_struct_member(char *name, char *str, struct ECPGstruct_member *members)
+find_struct_member(char *name, char *str, struct ECPGstruct_member * members)
 {
-    char *next = strchr(++str, '.'), c = '\0';
+	char	   *next = strchr(++str, '.'),
+				c = '\0';
 
-    if (next != NULL)
-    {
-	c = *next;
-	*next = '\0';
-    }
+	if (next != NULL)
+	{
+		c = *next;
+		*next = '\0';
+	}
 
-    for (; members; members = members->next)
-    {
-        if (strcmp(members->name, str) == 0)
+	for (; members; members = members->next)
 	{
-		if (c == '\0')
+		if (strcmp(members->name, str) == 0)
 		{
-			/* found the end */
-			switch (members->typ->typ)
+			if (c == '\0')
 			{
-			   case ECPGt_array:
-				return(new_variable(name, ECPGmake_array_type(members->typ->u.element, members->typ->size)));
-			   case ECPGt_struct:
-			   case ECPGt_union:
-				return(new_variable(name, ECPGmake_struct_type(members->typ->u.members, members->typ->typ)));
-			   default:
-				return(new_variable(name, ECPGmake_simple_type(members->typ->typ, members->typ->size)));
+				/* found the end */
+				switch (members->typ->typ)
+				{
+					case ECPGt_array:
+						return (new_variable(name, ECPGmake_array_type(members->typ->u.element, members->typ->size)));
+					case ECPGt_struct:
+					case ECPGt_union:
+						return (new_variable(name, ECPGmake_struct_type(members->typ->u.members, members->typ->typ)));
+					default:
+						return (new_variable(name, ECPGmake_simple_type(members->typ->typ, members->typ->size)));
+				}
 			}
-		}
-		else
-		{
-			*next = c;
-			if (c == '-')
+			else
 			{
-				next++;
-				return(find_struct_member(name, next, members->typ->u.element->u.members));
+				*next = c;
+				if (c == '-')
+				{
+					next++;
+					return (find_struct_member(name, next, members->typ->u.element->u.members));
+				}
+				else
+					return (find_struct_member(name, next, members->typ->u.members));
 			}
-			else return(find_struct_member(name, next, members->typ->u.members));
 		}
 	}
-    }
 
-    return(NULL);
+	return (NULL);
 }
 
 static struct variable *
-find_struct(char * name, char *next)
+find_struct(char *name, char *next)
 {
-    struct variable * p;
-    char c = *next;
-
-    /* first get the mother structure entry */
-    *next = '\0';
-    p = find_variable(name);
-
-    if (c == '-')
-    {
-	if (p->type->typ != ECPGt_struct && p->type->typ != ECPGt_union)
-        {
-                sprintf(errortext, "variable %s is not a pointer", name);
-                mmerror(ET_FATAL, errortext);
-        }
-
-	if (p->type->u.element->typ  != ECPGt_struct && p->type->u.element->typ != ECPGt_union)
-        {
-                sprintf(errortext, "variable %s is not a pointer to a structure or a union", name);
-                mmerror(ET_FATAL, errortext);
-        }
-
-	/* restore the name, we will need it later on */
-	*next = c;
-	next++;
-
-	return find_struct_member(name, next, p->type->u.element->u.members);
-    }
-    else
-    {
-	if (p->type->typ != ECPGt_struct && p->type->typ != ECPGt_union)
+	struct variable *p;
+	char		c = *next;
+
+	/* first get the mother structure entry */
+	*next = '\0';
+	p = find_variable(name);
+
+	if (c == '-')
 	{
-		sprintf(errortext, "variable %s is neither a structure nor a union", name);
-		mmerror(ET_FATAL, errortext);
+		if (p->type->typ != ECPGt_struct && p->type->typ != ECPGt_union)
+		{
+			sprintf(errortext, "variable %s is not a pointer", name);
+			mmerror(ET_FATAL, errortext);
+		}
+
+		if (p->type->u.element->typ != ECPGt_struct && p->type->u.element->typ != ECPGt_union)
+		{
+			sprintf(errortext, "variable %s is not a pointer to a structure or a union", name);
+			mmerror(ET_FATAL, errortext);
+		}
+
+		/* restore the name, we will need it later on */
+		*next = c;
+		next++;
+
+		return find_struct_member(name, next, p->type->u.element->u.members);
 	}
+	else
+	{
+		if (p->type->typ != ECPGt_struct && p->type->typ != ECPGt_union)
+		{
+			sprintf(errortext, "variable %s is neither a structure nor a union", name);
+			mmerror(ET_FATAL, errortext);
+		}
 
-	/* restore the name, we will need it later on */
-	*next = c;
+		/* restore the name, we will need it later on */
+		*next = c;
 
-	return find_struct_member(name, next, p->type->u.members);
-    }
+		return find_struct_member(name, next, p->type->u.members);
+	}
 }
 
 static struct variable *
-find_simple(char * name)
+find_simple(char *name)
 {
-    struct variable * p;
+	struct variable *p;
 
-    for (p = allvariables; p; p = p->next)
-    {
-        if (strcmp(p->name, name) == 0)
-	    return p;
-    }
+	for (p = allvariables; p; p = p->next)
+	{
+		if (strcmp(p->name, name) == 0)
+			return p;
+	}
 
-    return(NULL);
+	return (NULL);
 }
 
 /* Note that this function will end the program in case of an unknown */
 /* variable */
 struct variable *
-find_variable(char * name)
+find_variable(char *name)
 {
-    char * next;
-    struct variable * p;
-
-    if ((next = strchr(name, '.')) != NULL)
-	p = find_struct(name, next);
-    else if ((next = strstr(name, "->")) != NULL)
-	p = find_struct(name, next);
-    else
-	p = find_simple(name);
-
-    if (p == NULL)
-    {
-	sprintf(errortext, "The variable %s is not declared", name);
-	mmerror(ET_FATAL, errortext);
-    }
-
-    return(p);
+	char	   *next;
+	struct variable *p;
+
+	if ((next = strchr(name, '.')) != NULL)
+		p = find_struct(name, next);
+	else if ((next = strstr(name, "->")) != NULL)
+		p = find_struct(name, next);
+	else
+		p = find_simple(name);
+
+	if (p == NULL)
+	{
+		sprintf(errortext, "The variable %s is not declared", name);
+		mmerror(ET_FATAL, errortext);
+	}
+
+	return (p);
 }
 
 void
 remove_variables(int brace_level)
 {
-    struct variable * p, *prev;
+	struct variable *p,
+			   *prev;
 
-    for (p = prev = allvariables; p; p = p ? p->next : NULL)
-    {
-	if (p->brace_level >= brace_level)
+	for (p = prev = allvariables; p; p = p ? p->next : NULL)
 	{
-	    /* remove it */
-	    if (p == allvariables)
-		prev = allvariables = p->next;
-	    else
-		prev->next = p->next;
-
-	    ECPGfree_type(p->type);
-	    free(p->name);
-	    free(p);
-	    p = prev;
+		if (p->brace_level >= brace_level)
+		{
+			/* remove it */
+			if (p == allvariables)
+				prev = allvariables = p->next;
+			else
+				prev->next = p->next;
+
+			ECPGfree_type(p->type);
+			free(p->name);
+			free(p);
+			p = prev;
+		}
+		else
+			prev = p;
 	}
-	else
-	    prev = p;
-    }
 }
 
 
@@ -179,44 +182,45 @@ remove_variables(int brace_level)
  * I will make two lists for them.
  */
 
-struct arguments * argsinsert = NULL;
-struct arguments * argsresult = NULL;
+struct arguments *argsinsert = NULL;
+struct arguments *argsresult = NULL;
 
 void
 reset_variables(void)
 {
-    argsinsert = NULL;
-    argsresult = NULL;
+	argsinsert = NULL;
+	argsresult = NULL;
 }
 
 /* Insert a new variable into our request list. */
 void
 add_variable(struct arguments ** list, struct variable * var, struct variable * ind)
 {
-    struct arguments *p = (struct arguments *)mm_alloc(sizeof(struct arguments));
-    
-    p->variable = var;
-    p->indicator = ind;
-    p->next = *list;
-    *list = p;
+	struct arguments *p = (struct arguments *) mm_alloc(sizeof(struct arguments));
+
+	p->variable = var;
+	p->indicator = ind;
+	p->next = *list;
+	*list = p;
 }
 
 /* Append a new variable to our request list. */
 void
 append_variable(struct arguments ** list, struct variable * var, struct variable * ind)
 {
-    struct arguments *p, *new = (struct arguments *)mm_alloc(sizeof(struct arguments));
-
-    for (p = *list; p && p->next; p = p->next);
-    
-    new->variable = var;
-    new->indicator = ind;
-    new->next = NULL;
-    
-    if (p)
-    	p->next = new;
-    else
-	*list = new;
+	struct arguments *p,
+			   *new = (struct arguments *) mm_alloc(sizeof(struct arguments));
+
+	for (p = *list; p && p->next; p = p->next);
+
+	new->variable = var;
+	new->indicator = ind;
+	new->next = NULL;
+
+	if (p)
+		p->next = new;
+	else
+		*list = new;
 }
 
 /* Dump out a list of all the variable on this list.
@@ -226,33 +230,32 @@ append_variable(struct arguments ** list, struct variable * var, struct variable
 void
 dump_variables(struct arguments * list, int mode)
 {
-    if (list == NULL)
-    {
-        return;
-    }
+	if (list == NULL)
+		return;
 
-    /* The list is build up from the beginning so lets first dump the
-       end of the list:
-     */
+	/*
+	 * The list is build up from the beginning so lets first dump the end
+	 * of the list:
+	 */
 
-    dump_variables(list->next, mode);
+	dump_variables(list->next, mode);
 
-    /* Then the current element and its indicator */
-    ECPGdump_a_type(yyout, list->variable->name, list->variable->type,
-	list->indicator->name, list->indicator->type, NULL, NULL);
+	/* Then the current element and its indicator */
+	ECPGdump_a_type(yyout, list->variable->name, list->variable->type,
+			   list->indicator->name, list->indicator->type, NULL, NULL);
 
-    /* Then release the list element. */
-    if (mode != 0)
-    	free(list);
+	/* Then release the list element. */
+	if (mode != 0)
+		free(list);
 }
 
 void
-check_indicator(struct ECPGtype *var)
+check_indicator(struct ECPGtype * var)
 {
 	/* make sure this is a valid indicator variable */
 	switch (var->typ)
 	{
-		struct ECPGstruct_member *p;
+			struct ECPGstruct_member *p;
 
 		case ECPGt_short:
 		case ECPGt_int:
@@ -271,7 +274,7 @@ check_indicator(struct ECPGtype *var)
 		case ECPGt_array:
 			check_indicator(var->u.element);
 			break;
-		default: 
+		default:
 			mmerror(ET_ERROR, "indicator variable must be integer type");
 			break;
 	}
@@ -289,20 +292,20 @@ get_typedef(char *name)
 		mmerror(ET_FATAL, errortext);
 	}
 
-	return(this);
+	return (this);
 }
 
 void
 adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dimension, int type_index, bool pointer)
 {
-	if (type_index >= 0) 
+	if (type_index >= 0)
 	{
 		if (*length >= 0)
-                      	mmerror(ET_FATAL, "No multi-dimensional array support");
+			mmerror(ET_FATAL, "No multi-dimensional array support");
 
 		*length = type_index;
 	}
-		       
+
 	if (type_dimension >= 0)
 	{
 		if (*dimension >= 0 && *length >= 0)
@@ -319,56 +322,57 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
 
 	switch (type_enum)
 	{
-	   case ECPGt_struct:
-	   case ECPGt_union:
-	        /* pointer has to get dimension 0 */
-                if (pointer)
-	        {
-		    *length = *dimension;
-                    *dimension = 0;
-	        }
-
-                if (*length >= 0)
-                   mmerror(ET_FATAL, "No multi-dimensional array support for structures");
-
-                break;
-           case ECPGt_varchar:
-	        /* pointer has to get dimension 0 */
-                if (pointer)
-                    *dimension = 0;
-
-                /* one index is the string length */
-                if (*length < 0)
-                {
-                   *length = *dimension;
-                   *dimension = -1;
-                }
-
-                break;
-           case ECPGt_char:
-           case ECPGt_unsigned_char:
-	        /* pointer has to get length 0 */
-                if (pointer)
-                    *length=0;
-
-                /* one index is the string length */
-                if (*length < 0)
-                {
-                   *length = (*dimension < 0) ? 1 : *dimension;
-                   *dimension = -1;
-                }
-
-                break;
-           default:
- 	        /* a pointer has dimension = 0 */
-                if (pointer) {
-                    *length = *dimension;
-		    *dimension = 0;
-	        }
-
-                if (*length >= 0)
-                   mmerror(ET_FATAL, "No multi-dimensional array support for simple data types");
-
-                break;
+		case ECPGt_struct:
+		case ECPGt_union:
+			/* pointer has to get dimension 0 */
+			if (pointer)
+			{
+				*length = *dimension;
+				*dimension = 0;
+			}
+
+			if (*length >= 0)
+				mmerror(ET_FATAL, "No multi-dimensional array support for structures");
+
+			break;
+		case ECPGt_varchar:
+			/* pointer has to get dimension 0 */
+			if (pointer)
+				*dimension = 0;
+
+			/* one index is the string length */
+			if (*length < 0)
+			{
+				*length = *dimension;
+				*dimension = -1;
+			}
+
+			break;
+		case ECPGt_char:
+		case ECPGt_unsigned_char:
+			/* pointer has to get length 0 */
+			if (pointer)
+				*length = 0;
+
+			/* one index is the string length */
+			if (*length < 0)
+			{
+				*length = (*dimension < 0) ? 1 : *dimension;
+				*dimension = -1;
+			}
+
+			break;
+		default:
+			/* a pointer has dimension = 0 */
+			if (pointer)
+			{
+				*length = *dimension;
+				*dimension = 0;
+			}
+
+			if (*length >= 0)
+				mmerror(ET_FATAL, "No multi-dimensional array support for simple data types");
+
+			break;
 	}
 }
diff --git a/src/interfaces/ecpg/test/header_test.h b/src/interfaces/ecpg/test/header_test.h
index 71017aacbbd2ba6e8c7521d752f40e40e78052fb..741c6fa4b7aba74aaf69194c01d4c094358d0e29 100644
--- a/src/interfaces/ecpg/test/header_test.h
+++ b/src/interfaces/ecpg/test/header_test.h
@@ -1,26 +1,32 @@
 exec sql include sqlca;
 
-void Finish(msg)
+void
+Finish(msg)
 {
 	fprintf(stderr, "Error in statement '%s':\n", msg);
 	sqlprint();
-	
+
 	/* finish transaction */
-	exec sql rollback;
-	
+	exec sql	rollback;
+
 	/* and remove test table */
 	exec sql drop table meskes;
-	exec sql commit;
+	exec sql	commit;
+
+	exec sql	disconnect;
 
-	exec sql disconnect;
-		
 	exit(-1);
 }
 
-void warn(void)
+void
+warn(void)
 {
 	fprintf(stderr, "Warning: At least one column was truncated\n");
 }
 
-exec sql whenever sqlerror do Finish(msg);
-exec sql whenever sqlwarning do warn();
+exec sql whenever sqlerror
+do
+				Finish(msg);
+exec sql whenever sqlwarning
+do
+				warn();
diff --git a/src/interfaces/libpgeasy/halt.c b/src/interfaces/libpgeasy/halt.c
index 9d9796a6cbaaa020681d3544a03e3fc6f128316d..2173f7adf6e0197d1989db46ac76a3dc7de37b9f 100644
--- a/src/interfaces/libpgeasy/halt.c
+++ b/src/interfaces/libpgeasy/halt.c
@@ -20,7 +20,7 @@
 **------------------------------------------------------------------------*/
 
 void
-halt(char *format, ...)
+halt(char *format,...)
 {
 	va_list		arg_ptr;
 	char	   *pstr;
diff --git a/src/interfaces/libpgeasy/libpgeasy.h b/src/interfaces/libpgeasy/libpgeasy.h
index 43fbeaba85e9eea9e59a2c29e3844f573fdfcbf8..e58d5a1cd60e8ad2bf8d71d92996a516d7785420 100644
--- a/src/interfaces/libpgeasy/libpgeasy.h
+++ b/src/interfaces/libpgeasy/libpgeasy.h
@@ -4,11 +4,11 @@
 */
 
 PGresult   *doquery(char *query);
-PGconn	   *connectdb(char *dbName,
-				char *pghost,
-				char *pgport,
-				char *pgoptions,
-				char *pgtty);
+PGconn *connectdb(char *dbName,
+		  char *pghost,
+		  char *pgport,
+		  char *pgoptions,
+		  char *pgtty);
 void		disconnectdb(void);
 int			fetch(void *param,...);
 int			fetchwithnulls(void *param,...);
diff --git a/src/interfaces/libpgtcl/pgtclCmds.c b/src/interfaces/libpgtcl/pgtclCmds.c
index 10aa2f01bc080f59e6c6f462e7723c0be5c3a48f..fb0341b857d536d7a9724f749b44f60c72b9c4c6 100644
--- a/src/interfaces/libpgtcl/pgtclCmds.c
+++ b/src/interfaces/libpgtcl/pgtclCmds.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.48 2000/03/11 03:08:35 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.49 2000/04/12 17:17:11 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1381,7 +1381,7 @@ Pg_select(ClientData cData, Tcl_Interp *interp, int argc, char **argv)
  */
 
 static int
-Pg_have_listener(Pg_ConnectionId *connid, const char *relname)
+Pg_have_listener(Pg_ConnectionId * connid, const char *relname)
 {
 	Pg_TclNotifies *notifies;
 	Tcl_HashEntry *entry;
diff --git a/src/interfaces/libpgtcl/pgtclCmds.h b/src/interfaces/libpgtcl/pgtclCmds.h
index 2cb20211e10b0b46196e7bb42b24d6c57350595c..b1d908fbee28e556d87b4f408652e3aff8dc9154 100644
--- a/src/interfaces/libpgtcl/pgtclCmds.h
+++ b/src/interfaces/libpgtcl/pgtclCmds.h
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pgtclCmds.h,v 1.16 2000/01/26 05:58:43 momjian Exp $
+ * $Id: pgtclCmds.h,v 1.17 2000/04/12 17:17:11 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -39,7 +39,7 @@ typedef struct Pg_TclNotifies_s
 	 * got round to deleting the Pg_TclNotifies structure.
 	 */
 	Tcl_HashTable notify_hash;	/* Active pg_listen requests */
-} Pg_TclNotifies;
+}			Pg_TclNotifies;
 
 typedef struct Pg_ConnectionId_s
 {
@@ -56,7 +56,7 @@ typedef struct Pg_ConnectionId_s
 	Pg_TclNotifies *notify_list;/* head of list of notify info */
 	int			notifier_running;		/* notify event source is live */
 	int			notifier_socket;/* PQsocket on which notifier is listening */
-} Pg_ConnectionId;
+}			Pg_ConnectionId;
 
 /* Values of res_copyStatus */
 #define RES_COPY_NONE	0
diff --git a/src/interfaces/libpgtcl/pgtclId.c b/src/interfaces/libpgtcl/pgtclId.c
index 1ecf7e02f8b3fdf7784bc9f42095dcd01b1346ba..2cb0cb9de41c3170ccde1214a13d8c1e373dd7da 100644
--- a/src/interfaces/libpgtcl/pgtclId.c
+++ b/src/interfaces/libpgtcl/pgtclId.c
@@ -13,7 +13,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.22 2000/01/26 05:58:43 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.23 2000/04/12 17:17:11 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 
 
 static int
-PgEndCopy(Pg_ConnectionId *connid, int *errorCodePtr)
+PgEndCopy(Pg_ConnectionId * connid, int *errorCodePtr)
 {
 	connid->res_copyStatus = RES_COPY_NONE;
 	if (PQendcopy(connid->conn))
@@ -197,7 +197,7 @@ PgSetConnectionId(Tcl_Interp *interp, PGconn *conn)
  * Get back the connection from the Id
  */
 PGconn *
-PgGetConnectionId(Tcl_Interp *interp, char *id, Pg_ConnectionId **connid_p)
+PgGetConnectionId(Tcl_Interp *interp, char *id, Pg_ConnectionId ** connid_p)
 {
 	Tcl_Channel conn_chan;
 	Pg_ConnectionId *connid;
@@ -333,7 +333,7 @@ PgSetResultId(Tcl_Interp *interp, char *connid_c, PGresult *res)
 }
 
 static int
-getresid(Tcl_Interp *interp, char *id, Pg_ConnectionId **connid_p)
+getresid(Tcl_Interp *interp, char *id, Pg_ConnectionId ** connid_p)
 {
 	Tcl_Channel conn_chan;
 	char	   *mark;
@@ -477,7 +477,7 @@ typedef struct
 	Tcl_Event	header;			/* Standard Tcl event info */
 	PGnotify	info;			/* Notify name from SQL server */
 	Pg_ConnectionId *connid;	/* Connection for server */
-} NotifyEvent;
+}			NotifyEvent;
 
 /* Dispatch a NotifyEvent that has reached the front of the event queue */
 
@@ -569,7 +569,7 @@ Pg_Notify_EventProc(Tcl_Event *evPtr, int flags)
  */
 
 void
-PgNotifyTransferEvents(Pg_ConnectionId *connid)
+PgNotifyTransferEvents(Pg_ConnectionId * connid)
 {
 	PGnotify   *notify;
 
@@ -678,7 +678,7 @@ Pg_Notify_FileHandler(ClientData clientData, int mask)
  */
 
 void
-PgStartNotifyEventSource(Pg_ConnectionId *connid)
+PgStartNotifyEventSource(Pg_ConnectionId * connid)
 {
 	/* Start the notify event source if it isn't already running */
 	if (!connid->notifier_running)
@@ -705,7 +705,7 @@ PgStartNotifyEventSource(Pg_ConnectionId *connid)
 }
 
 void
-PgStopNotifyEventSource(Pg_ConnectionId *connid)
+PgStopNotifyEventSource(Pg_ConnectionId * connid)
 {
 	/* Remove the event source */
 	if (connid->notifier_running)
diff --git a/src/interfaces/libpgtcl/pgtclId.h b/src/interfaces/libpgtcl/pgtclId.h
index abe41e761f9eda69d0cf48b7ac299b2e079de9c2..1cbb262dd59d67b1e9e817a042baa2cad92108eb 100644
--- a/src/interfaces/libpgtcl/pgtclId.h
+++ b/src/interfaces/libpgtcl/pgtclId.h
@@ -10,7 +10,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pgtclId.h,v 1.14 2000/01/26 05:58:43 momjian Exp $
+ * $Id: pgtclId.h,v 1.15 2000/04/12 17:17:12 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -43,9 +43,9 @@ extern int	PgSetResultId(Tcl_Interp *interp, char *connid, PGresult *res);
 extern PGresult *PgGetResultId(Tcl_Interp *interp, char *id);
 extern void PgDelResultId(Tcl_Interp *interp, char *id);
 extern int	PgGetConnByResultId(Tcl_Interp *interp, char *resid);
-extern void PgStartNotifyEventSource(Pg_ConnectionId *connid);
-extern void PgStopNotifyEventSource(Pg_ConnectionId *connid);
-extern void PgNotifyTransferEvents(Pg_ConnectionId *connid);
+extern void PgStartNotifyEventSource(Pg_ConnectionId * connid);
+extern void PgStopNotifyEventSource(Pg_ConnectionId * connid);
+extern void PgNotifyTransferEvents(Pg_ConnectionId * connid);
 extern void PgNotifyInterpDelete(ClientData clientData, Tcl_Interp *interp);
 
 /* GetFileProc is needed in Tcl 7.6 *only* ... it went away again in 8.0 */
diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c
index fe870963df4e3d3acc9e43d5c115a68996a7cf35..bf5a21bee9aa3a3e1e014cda4fb23da7d3f9fe5f 100644
--- a/src/interfaces/libpq/fe-auth.c
+++ b/src/interfaces/libpq/fe-auth.c
@@ -10,7 +10,7 @@
  * exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.38 2000/03/11 03:08:36 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.39 2000/04/12 17:17:13 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -94,7 +94,7 @@ static const struct authsvc authsvcs[] = {
 	{"password", STARTUP_PASSWORD_MSG, 0}
 };
 
-static const int	n_authsvcs = sizeof(authsvcs) / sizeof(struct authsvc);
+static const int n_authsvcs = sizeof(authsvcs) / sizeof(struct authsvc);
 
 #ifdef KRB4
 /*----------------------------------------------------------------
@@ -475,12 +475,12 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
 			const char *password, char *PQerrormsg)
 {
 #if !defined(KRB4) && !defined(KRB5)
-    (void)hostname; /*not used*/
+	(void) hostname;			/* not used */
 #endif
 
 	switch (areq)
 	{
-			case AUTH_REQ_OK:
+		case AUTH_REQ_OK:
 			break;
 
 		case AUTH_REQ_KRB4:
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index df572884ebf7aa39340de4b93679f0fe9b499a81..c400a7ebb1604c9aa9915975188fc5479fd33510 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.125 2000/03/24 01:39:55 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.126 2000/04/12 17:17:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -46,18 +46,23 @@
 #endif
 
 #ifdef WIN32
-static int inet_aton(const char *cp, struct in_addr *inp) {
+static int
+inet_aton(const char *cp, struct in_addr * inp)
+{
 	unsigned long a = inet_addr(cp);
+
 	if (a == -1)
 		return 0;
-	inp->s_addr = a;	
+	inp->s_addr = a;
 	return 1;
 }
+
 #endif
 
 
 #ifdef USE_SSL
 static SSL_CTX *SSL_context = NULL;
+
 #endif
 
 #define NOTIFYLIST_INITIAL_SIZE 10
@@ -85,15 +90,17 @@ static SSL_CTX *SSL_context = NULL;
  *
  * PQconninfoOptions[] is a constant static array that we use to initialize
  * a dynamically allocated working copy.  All the "val" fields in
- * PQconninfoOptions[] *must* be NULL.  In a working copy, non-null "val"
+ * PQconninfoOptions[] *must* be NULL.	In a working copy, non-null "val"
  * fields point to malloc'd strings that should be freed when the working
  * array is freed (see PQconninfoFree).
  * ----------
  */
 static const PQconninfoOption PQconninfoOptions[] = {
-	/* "authtype" is no longer used, so mark it "don't show".  We keep it
-	 * in the array so as not to reject conninfo strings from old apps that
-	 * might still try to set it.
+
+	/*
+	 * "authtype" is no longer used, so mark it "don't show".  We keep it
+	 * in the array so as not to reject conninfo strings from old apps
+	 * that might still try to set it.
 	 */
 	{"authtype", "PGAUTHTYPE", DefaultAuthtype, NULL,
 	"Database-Authtype", "D", 20},
@@ -111,7 +118,8 @@ static const PQconninfoOption PQconninfoOptions[] = {
 	"Database-Host", "", 40},
 
 	{"hostaddr", "PGHOSTADDR", NULL, NULL,
-	 "Database-Host-IPv4-Address", "", 15}, /* Room for abc.def.ghi.jkl */
+	"Database-Host-IPv4-Address", "", 15},		/* Room for
+												 * abc.def.ghi.jkl */
 
 	{"port", "PGPORT", DEF_PGPORT, NULL,
 	"Database-Port", "", 6},
@@ -156,22 +164,22 @@ static const struct EnvironmentOptions
 };
 
 
-static int connectDBStart(PGconn *conn);
-static int connectDBComplete(PGconn *conn);
+static int	connectDBStart(PGconn *conn);
+static int	connectDBComplete(PGconn *conn);
 static bool PQsetenvStart(PGconn *conn);
 static PostgresPollingStatusType PQsetenvPoll(PGconn *conn);
 static PGconn *makeEmptyPGconn(void);
 static void freePGconn(PGconn *conn);
 static void closePGconn(PGconn *conn);
 static PQconninfoOption *conninfo_parse(const char *conninfo,
-										PQExpBuffer errorMessage);
+			   PQExpBuffer errorMessage);
 static char *conninfo_getval(PQconninfoOption *connOptions,
-							 const char *keyword);
+				const char *keyword);
 static void defaultNoticeProcessor(void *arg, const char *message);
 
 
 /* ----------------
- *      Connecting to a Database
+ *		Connecting to a Database
  *
  * There are now four different ways a user of this API can connect to the
  * database.  Two are not recommended for use in new code, because of their
@@ -187,7 +195,7 @@ static void defaultNoticeProcessor(void *arg, const char *message);
  *
  * Internally, the static functions connectDBStart, connectDBComplete
  * are part of the connection procedure.
- * 
+ *
  * ----------------
  */
 
@@ -218,7 +226,7 @@ static void defaultNoticeProcessor(void *arg, const char *message);
 PGconn *
 PQconnectdb(const char *conninfo)
 {
-	PGconn *conn = PQconnectStart(conninfo);
+	PGconn	   *conn = PQconnectStart(conninfo);
 
 	if (conn && conn->status != CONNECTION_BAD)
 		(void) connectDBComplete(conn);
@@ -235,7 +243,7 @@ PQconnectdb(const char *conninfo)
  * See comment for PQconnectdb for the definition of the string format.
  *
  * Returns a PGconn*.  If NULL is returned, a malloc error has occurred, and
- * you should not attempt to proceed with this connection.  If the status
+ * you should not attempt to proceed with this connection.	If the status
  * field of the connection returned is CONNECTION_BAD, an error has
  * occurred. In this case you should call PQfinish on the result, (perhaps
  * inspecting the error message first).  Other fields of the structure may not
@@ -258,7 +266,7 @@ PQconnectStart(const char *conninfo)
 	 * Allocate memory for the conn structure
 	 * ----------
 	 */
-	
+
 	conn = makeEmptyPGconn();
 	if (conn == NULL)
 		return (PGconn *) NULL;
@@ -324,7 +332,7 @@ PQconnectStart(const char *conninfo)
  * and their current default values.
  *
  * NOTE: as of PostgreSQL 7.0, the returned array is dynamically allocated
- * and should be freed when no longer needed via PQconninfoFree().  (In prior
+ * and should be freed when no longer needed via PQconninfoFree().	(In prior
  * versions, the returned array was static, but that's not thread-safe.)
  * Pre-7.0 applications that use this function will see a small memory leak
  * until they are updated to call PQconninfoFree.
@@ -333,7 +341,7 @@ PQconnectStart(const char *conninfo)
 PQconninfoOption *
 PQconndefaults(void)
 {
-	PQExpBufferData  errorBuf;
+	PQExpBufferData errorBuf;
 	PQconninfoOption *connOptions;
 
 	initPQExpBuffer(&errorBuf);
@@ -388,7 +396,8 @@ PQsetdbLogin(const char *pghost, const char *pgport, const char *pgoptions,
 			 const char *pwd)
 {
 	PGconn	   *conn;
-	char	   *tmp;	/* An error message from some service we call. */
+	char	   *tmp;			/* An error message from some service we
+								 * call. */
 	bool		error = FALSE;	/* We encountered an error. */
 
 	conn = makeEmptyPGconn();
@@ -466,15 +475,13 @@ PQsetdbLogin(const char *pghost, const char *pgport, const char *pgoptions,
 		conn->dbName = strdup(dbName);
 
 	if (error)
-	{
 		conn->status = CONNECTION_BAD;
-	}
 	else
 	{
 		if (connectDBStart(conn))
 			(void) connectDBComplete(conn);
 	}
-		
+
 	return conn;
 }
 
@@ -595,12 +602,13 @@ connectMakeNonblocking(PGconn *conn)
 #ifndef WIN32
 	if (fcntl(conn->sock, F_SETFL, O_NONBLOCK) < 0)
 #else
-	int on = 1;
+	int			on = 1;
+
 	if (ioctlsocket(conn->sock, FIONBIO, &on) != 0)
 #endif
 	{
 		printfPQExpBuffer(&conn->errorMessage,
-						  "connectMakeNonblocking -- fcntl() failed: errno=%d\n%s\n",
+			  "connectMakeNonblocking -- fcntl() failed: errno=%d\n%s\n",
 						  errno, strerror(errno));
 		return 0;
 	}
@@ -637,7 +645,7 @@ connectNoDelay(PGconn *conn)
 				   sizeof(on)) < 0)
 	{
 		printfPQExpBuffer(&conn->errorMessage,
-						  "connectNoDelay() -- setsockopt failed: errno=%d\n%s\n",
+				 "connectNoDelay() -- setsockopt failed: errno=%d\n%s\n",
 						  errno, strerror(errno));
 #ifdef WIN32
 		printf("Winsock error: %i\n", WSAGetLastError());
@@ -661,13 +669,16 @@ connectDBStart(PGconn *conn)
 {
 	int			portno,
 				family;
+
 #ifdef USE_SSL
-	StartupPacket           np; /* Used to negotiate SSL connection */
-	char                    SSLok;
+	StartupPacket np;			/* Used to negotiate SSL connection */
+	char		SSLok;
+
 #endif
 
 	if (!conn)
 		return 0;
+
 	/*
 	 * parse dbName to get all additional info in it, if any
 	 */
@@ -679,8 +690,8 @@ connectDBStart(PGconn *conn)
 	conn->outCount = 0;
 
 	/*
-	 * Set up the connection to postmaster/backend.
-	 * Note that this supports IPv4 and UDP only.
+	 * Set up the connection to postmaster/backend. Note that this
+	 * supports IPv4 and UDP only.
 	 */
 
 	MemSet((char *) &conn->raddr, 0, sizeof(conn->raddr));
@@ -691,11 +702,11 @@ connectDBStart(PGconn *conn)
 		/* Note that this supports IPv4 only */
 		struct in_addr addr;
 
-		if(!inet_aton(conn->pghostaddr, &addr))
+		if (!inet_aton(conn->pghostaddr, &addr))
 		{
 			printfPQExpBuffer(&conn->errorMessage,
 							  "connectDBStart() -- "
-							  "invalid host address: %s\n", conn->pghostaddr);
+						 "invalid host address: %s\n", conn->pghostaddr);
 			goto connect_errReturn;
 		}
 
@@ -713,7 +724,7 @@ connectDBStart(PGconn *conn)
 		if ((hp == NULL) || (hp->h_addrtype != AF_INET))
 		{
 			printfPQExpBuffer(&conn->errorMessage,
-							  "connectDBStart() --  unknown hostname: %s\n",
+						   "connectDBStart() --  unknown hostname: %s\n",
 							  conn->pghost);
 			goto connect_errReturn;
 		}
@@ -740,8 +751,8 @@ connectDBStart(PGconn *conn)
 		conn->raddr_len = sizeof(struct sockaddr_in);
 	}
 #if !defined(WIN32) && !defined(__CYGWIN32__)
-		else
-			conn->raddr_len = UNIXSOCK_PATH(conn->raddr.un, portno);
+	else
+		conn->raddr_len = UNIXSOCK_PATH(conn->raddr.un, portno);
 #endif
 
 
@@ -775,82 +786,91 @@ connectDBStart(PGconn *conn)
 	 * WIN32_NON_BLOCKING_CONNECTIONS before compilation.  If it works, then
 	 * this code can be cleaned up.
 	 *
-	 *   Ewan Mellor <eem21@cam.ac.uk>.
+	 *	 Ewan Mellor <eem21@cam.ac.uk>.
 	 * ---------- */
 #if (!defined(WIN32) || defined(WIN32_NON_BLOCKING_CONNECTIONS)) && !defined(USE_SSL)
 	if (connectMakeNonblocking(conn) == 0)
 		goto connect_errReturn;
-#endif	
+#endif
 
 #ifdef USE_SSL
-	/* This needs to be done before we set into nonblocking, since SSL
-	 * negotiation does not like that mode */
+
+	/*
+	 * This needs to be done before we set into nonblocking, since SSL
+	 * negotiation does not like that mode
+	 */
 
 	/* Attempt to negotiate SSL usage */
-	if (conn->allow_ssl_try) {
-	  memset((char *)&np, 0, sizeof(np));
-	  np.protoVersion = htonl(NEGOTIATE_SSL_CODE);
-	  if (pqPacketSend(conn, (char *) &np, sizeof(StartupPacket)) != STATUS_OK)
-	    {
-	      sprintf(conn->errorMessage,
-		      "connectDB() -- couldn't send SSL negotiation packet: errno=%d\n%s\n",
-		      errno, strerror(errno));
-	      goto connect_errReturn;
-	    }
-	  /* Now receive the postmasters response */
-	  if (recv(conn->sock, &SSLok, 1, 0) != 1) {
-	    sprintf(conn->errorMessage, "PQconnectDB() -- couldn't read postmaster response: errno=%d\n%s\n",
-		    errno, strerror(errno));
-	    goto connect_errReturn;
-	  }
-	  if (SSLok == 'S') {
-	    if (!SSL_context) 
-	      {
-		SSL_load_error_strings();
-		SSL_library_init();
-		SSL_context = SSL_CTX_new(SSLv23_method());
-		if (!SSL_context) {
-		  sprintf(conn->errorMessage,
-			  "connectDB() -- couldn't create SSL context: %s\n",
-			  ERR_reason_error_string(ERR_get_error()));
-		  goto connect_errReturn;
+	if (conn->allow_ssl_try)
+	{
+		memset((char *) &np, 0, sizeof(np));
+		np.protoVersion = htonl(NEGOTIATE_SSL_CODE);
+		if (pqPacketSend(conn, (char *) &np, sizeof(StartupPacket)) != STATUS_OK)
+		{
+			sprintf(conn->errorMessage,
+					"connectDB() -- couldn't send SSL negotiation packet: errno=%d\n%s\n",
+					errno, strerror(errno));
+			goto connect_errReturn;
+		}
+		/* Now receive the postmasters response */
+		if (recv(conn->sock, &SSLok, 1, 0) != 1)
+		{
+			sprintf(conn->errorMessage, "PQconnectDB() -- couldn't read postmaster response: errno=%d\n%s\n",
+					errno, strerror(errno));
+			goto connect_errReturn;
+		}
+		if (SSLok == 'S')
+		{
+			if (!SSL_context)
+			{
+				SSL_load_error_strings();
+				SSL_library_init();
+				SSL_context = SSL_CTX_new(SSLv23_method());
+				if (!SSL_context)
+				{
+					sprintf(conn->errorMessage,
+					  "connectDB() -- couldn't create SSL context: %s\n",
+							ERR_reason_error_string(ERR_get_error()));
+					goto connect_errReturn;
+				}
+			}
+			if (!(conn->ssl = SSL_new(SSL_context)) ||
+				!SSL_set_fd(conn->ssl, conn->sock) ||
+				SSL_connect(conn->ssl) <= 0)
+			{
+				sprintf(conn->errorMessage,
+				"connectDB() -- couldn't establish SSL connection: %s\n",
+						ERR_reason_error_string(ERR_get_error()));
+				goto connect_errReturn;
+			}
+			/* SSL connection finished. Continue to send startup packet */
+		}
+		else if (SSLok == 'E')
+		{
+			/* Received error - probably protocol mismatch */
+			if (conn->Pfdebug)
+				fprintf(conn->Pfdebug, "Postmaster reports error, attempting fallback to pre-6.6.\n");
+			close(conn->sock);
+			conn->allow_ssl_try = FALSE;
+			return connectDBStart(conn);
+		}
+		else if (SSLok != 'N')
+		{
+			strcpy(conn->errorMessage,
+				   "Received invalid negotiation response.\n");
+			goto connect_errReturn;
 		}
-	      }
-	    if (!(conn->ssl = SSL_new(SSL_context)) ||
-		!SSL_set_fd(conn->ssl, conn->sock) ||
-		SSL_connect(conn->ssl) <= 0) 
-	      {
-		sprintf(conn->errorMessage,
-			"connectDB() -- couldn't establish SSL connection: %s\n",
-			ERR_reason_error_string(ERR_get_error()));
-		goto connect_errReturn;
-	      }
-	    /* SSL connection finished. Continue to send startup packet */
-	  }
-	  else if (SSLok == 'E') {
-	    /* Received error - probably protocol mismatch */
-	    if (conn->Pfdebug)
-	      fprintf(conn->Pfdebug, "Postmaster reports error, attempting fallback to pre-6.6.\n");
-	    close(conn->sock);
-	    conn->allow_ssl_try = FALSE;
-	    return connectDBStart(conn);
-	  }
-	  else if (SSLok != 'N') {
-	    strcpy(conn->errorMessage,
-		   "Received invalid negotiation response.\n");
-	    goto connect_errReturn;
-	  }
 	}
 #endif
 
 	/* ----------
-     * Start / make connection.  We are hopefully in non-blocking mode
+	 * Start / make connection.  We are hopefully in non-blocking mode
 	 * now, but it is possible that:
-	 *   1. Older systems will still block on connect, despite the
-	 *      non-blocking flag. (Anyone know if this is true?)
-	 *   2. We are running under Windows, and aren't even trying
-	 *      to be non-blocking (see above).
-	 *   3. We are using SSL.
+	 *	 1. Older systems will still block on connect, despite the
+	 *		non-blocking flag. (Anyone know if this is true?)
+	 *	 2. We are running under Windows, and aren't even trying
+	 *		to be non-blocking (see above).
+	 *	 3. We are using SSL.
 	 * Thus, we have make arrangements for all eventualities.
 	 * ----------
 	 */
@@ -862,8 +882,11 @@ connectDBStart(PGconn *conn)
 		if (WSAGetLastError() == WSAEINPROGRESS)
 #endif
 		{
-			/* This is fine - we're in non-blocking mode, and the
-			 * connection is in progress. */
+
+			/*
+			 * This is fine - we're in non-blocking mode, and the
+			 * connection is in progress.
+			 */
 			conn->status = CONNECTION_STARTED;
 		}
 		else
@@ -888,12 +911,14 @@ connectDBStart(PGconn *conn)
 		conn->status = CONNECTION_MADE;
 	}
 
-	/* This makes the connection non-blocking, for all those cases which forced us
-	   not to do it above. */
+	/*
+	 * This makes the connection non-blocking, for all those cases which
+	 * forced us not to do it above.
+	 */
 #if (defined(WIN32) && !defined(WIN32_NON_BLOCKING_CONNECTIONS)) || defined(USE_SSL)
 	if (connectMakeNonblocking(conn) == 0)
 		goto connect_errReturn;
-#endif	
+#endif
 
 	return 1;
 
@@ -929,10 +954,13 @@ connectDBComplete(PGconn *conn)
 	if (conn == NULL || conn->status == CONNECTION_BAD)
 		return 0;
 
-	for (;;) {
+	for (;;)
+	{
+
 		/*
-		 * Wait, if necessary.  Note that the initial state (just after
-		 * PQconnectStart) is to wait for the socket to select for writing.
+		 * Wait, if necessary.	Note that the initial state (just after
+		 * PQconnectStart) is to wait for the socket to select for
+		 * writing.
 		 */
 		switch (flag)
 		{
@@ -941,7 +969,7 @@ connectDBComplete(PGconn *conn)
 
 			case PGRES_POLLING_OK:
 				return 1;		/* success! */
-				
+
 			case PGRES_POLLING_READING:
 				if (pqWait(1, 0, conn))
 				{
@@ -963,6 +991,7 @@ connectDBComplete(PGconn *conn)
 				conn->status = CONNECTION_BAD;
 				return 0;
 		}
+
 		/*
 		 * Now try to advance the state machine.
 		 */
@@ -977,23 +1006,23 @@ connectDBComplete(PGconn *conn)
  *
  * Returns a PostgresPollingStatusType.
  * Before calling this function, use select(2) to determine when data arrive.
- * 
+ *
  * You must call PQfinish whether or not this fails.
  *
  * This function and PQconnectStart are intended to allow connections to be
  * made without blocking the execution of your program on remote I/O. However,
  * there are a number of caveats:
  *
- *   o  If you call PQtrace, ensure that the stream object into which you trace
- *      will not block.
- *   o  If you do not supply an IP address for the remote host (i.e. you 
- *      supply a host name instead) then this function will block on
- *      gethostbyname.  You will be fine if using Unix sockets (i.e. by
- *      supplying neither a host name nor a host address).
- *   o  If your backend wants to use Kerberos authentication then you must
- *      supply both a host name and a host address, otherwise this function
- *      may block on gethostname.
- *   o  This function will block if compiled with USE_SSL.
+ *	 o	If you call PQtrace, ensure that the stream object into which you trace
+ *		will not block.
+ *	 o	If you do not supply an IP address for the remote host (i.e. you
+ *		supply a host name instead) then this function will block on
+ *		gethostbyname.	You will be fine if using Unix sockets (i.e. by
+ *		supplying neither a host name nor a host address).
+ *	 o	If your backend wants to use Kerberos authentication then you must
+ *		supply both a host name and a host address, otherwise this function
+ *		may block on gethostname.
+ *	 o	This function will block if compiled with USE_SSL.
  *
  * ----------------
  */
@@ -1008,32 +1037,35 @@ PQconnectPoll(PGconn *conn)
 	/* Get the new data */
 	switch (conn->status)
 	{
-		/* We really shouldn't have been polled in these two cases, but
-		   we can handle it. */
+
+			/*
+			 * We really shouldn't have been polled in these two cases,
+			 * but we can handle it.
+			 */
 		case CONNECTION_BAD:
 			return PGRES_POLLING_FAILED;
 		case CONNECTION_OK:
 			return PGRES_POLLING_OK;
 
-		/* These are reading states */
+			/* These are reading states */
 		case CONNECTION_AWAITING_RESPONSE:
 		case CONNECTION_AUTH_OK:
-		{
-			/* Load waiting data */
-			int n = pqReadData(conn);
-				
-			if (n < 0)
-				goto error_return;
-			if (n == 0)
-				return PGRES_POLLING_READING;
+			{
+				/* Load waiting data */
+				int			n = pqReadData(conn);
 
-			break;
-		}
+				if (n < 0)
+					goto error_return;
+				if (n == 0)
+					return PGRES_POLLING_READING;
+
+				break;
+			}
 
-		/* These are writing states, so we just proceed. */
+			/* These are writing states, so we just proceed. */
 		case CONNECTION_STARTED:
 		case CONNECTION_MADE:
-		   break;
+			break;
 
 		case CONNECTION_SETENV:
 			/* We allow PQsetenvPoll to decide whether to proceed */
@@ -1041,281 +1073,319 @@ PQconnectPoll(PGconn *conn)
 
 		default:
 			printfPQExpBuffer(&conn->errorMessage,
-							  "PQconnectPoll() -- unknown connection state - "
-							  "probably indicative of memory corruption!\n");
+						 "PQconnectPoll() -- unknown connection state - "
+						  "probably indicative of memory corruption!\n");
 			goto error_return;
 	}
 
 
- keep_going: /* We will come back to here until there is nothing left to
-				parse. */
-	switch(conn->status)
+keep_going:						/* We will come back to here until there
+								 * is nothing left to parse. */
+	switch (conn->status)
 	{
 		case CONNECTION_STARTED:
-		{
-			SOCKET_SIZE_TYPE laddrlen;
+			{
+				SOCKET_SIZE_TYPE laddrlen;
+
 #ifndef WIN32
-			int optval;
+				int			optval;
+
 #else
-			char optval;
-#endif
-			SOCKET_SIZE_TYPE optlen = sizeof(optval);
+				char		optval;
 
-			/* Write ready, since we've made it here, so the connection
-			 * has been made. */
+#endif
+				SOCKET_SIZE_TYPE optlen = sizeof(optval);
 
-			/* Now check (using getsockopt) that there is not an error
-			   state waiting for us on the socket. */
+				/*
+				 * Write ready, since we've made it here, so the
+				 * connection has been made.
+				 */
 
-			if (getsockopt(conn->sock, SOL_SOCKET, SO_ERROR,
-						   &optval, &optlen) == -1)
-			{
-				printfPQExpBuffer(&conn->errorMessage,
-								  "PQconnectPoll() -- getsockopt() failed: "
-								  "errno=%d\n%s\n",
-								  errno, strerror(errno));
-				goto error_return;
-			}
-			else if (optval != 0)
-			{
 				/*
-				 * When using a nonblocking connect, we will typically see
-				 * connect failures at this point, so provide a friendly
-				 * error message.
+				 * Now check (using getsockopt) that there is not an error
+				 * state waiting for us on the socket.
 				 */
-				printfPQExpBuffer(&conn->errorMessage,
-								  "PQconnectPoll() -- connect() failed: %s\n"
-								  "\tIs the postmaster running%s at '%s'\n"
-								  "\tand accepting connections on %s '%s'?\n",
-								  strerror(optval),
-								  (conn->raddr.sa.sa_family == AF_INET) ? " (with -i)" : "",
-								  conn->pghost ? conn->pghost : "localhost",
+
+				if (getsockopt(conn->sock, SOL_SOCKET, SO_ERROR,
+							   &optval, &optlen) == -1)
+				{
+					printfPQExpBuffer(&conn->errorMessage,
+							   "PQconnectPoll() -- getsockopt() failed: "
+									  "errno=%d\n%s\n",
+									  errno, strerror(errno));
+					goto error_return;
+				}
+				else if (optval != 0)
+				{
+
+					/*
+					 * When using a nonblocking connect, we will typically
+					 * see connect failures at this point, so provide a
+					 * friendly error message.
+					 */
+					printfPQExpBuffer(&conn->errorMessage,
+							  "PQconnectPoll() -- connect() failed: %s\n"
+								"\tIs the postmaster running%s at '%s'\n"
+							 "\tand accepting connections on %s '%s'?\n",
+									  strerror(optval),
+									  (conn->raddr.sa.sa_family == AF_INET) ? " (with -i)" : "",
+							   conn->pghost ? conn->pghost : "localhost",
 								  (conn->raddr.sa.sa_family == AF_INET) ?
-								  "TCP/IP port" : "Unix socket",
-								  conn->pgport);
-				goto error_return;
+									  "TCP/IP port" : "Unix socket",
+									  conn->pgport);
+					goto error_return;
+				}
+
+				/* Fill in the client address */
+				laddrlen = sizeof(conn->laddr);
+				if (getsockname(conn->sock, &conn->laddr.sa, &laddrlen) < 0)
+				{
+					printfPQExpBuffer(&conn->errorMessage,
+							  "PQconnectPoll() -- getsockname() failed: "
+									  "errno=%d\n%s\n",
+									  errno, strerror(errno));
+					goto error_return;
+				}
+
+				conn->status = CONNECTION_MADE;
+				return PGRES_POLLING_WRITING;
 			}
 
-			/* Fill in the client address */
-			laddrlen = sizeof(conn->laddr);
-			if (getsockname(conn->sock, &conn->laddr.sa, &laddrlen) < 0)
+		case CONNECTION_MADE:
 			{
-				printfPQExpBuffer(&conn->errorMessage,
-								  "PQconnectPoll() -- getsockname() failed: "
-								  "errno=%d\n%s\n",
-								  errno, strerror(errno));
-				goto error_return;
-			}
+				StartupPacket sp;
 
-			conn->status = CONNECTION_MADE;
-			return PGRES_POLLING_WRITING;
-		}
+				/*
+				 * Initialize the startup packet.
+				 */
 
-		case CONNECTION_MADE:
-		{
-			StartupPacket sp;
-			
-			/*
-			 * Initialize the startup packet.
-			 */
+				MemSet((char *) &sp, 0, sizeof(StartupPacket));
 
-			MemSet((char *) &sp, 0, sizeof(StartupPacket));
-	
-			sp.protoVersion = (ProtocolVersion) htonl(PG_PROTOCOL_LIBPQ);
-			
-			strncpy(sp.user, conn->pguser, SM_USER);
-			strncpy(sp.database, conn->dbName, SM_DATABASE);
-			strncpy(sp.tty, conn->pgtty, SM_TTY);
-
-			if (conn->pgoptions)
-				strncpy(sp.options, conn->pgoptions, SM_OPTIONS);
-
-			/* Send the startup packet.
-			 *
-			 * Theoretically, this could block, but it really shouldn't
-			 * since we only got here if the socket is write-ready.
-			 */
+				sp.protoVersion = (ProtocolVersion) htonl(PG_PROTOCOL_LIBPQ);
 
-			if (pqPacketSend(conn, (char *) &sp,
-							 sizeof(StartupPacket)) != STATUS_OK)
-			{
-				printfPQExpBuffer(&conn->errorMessage,
-								  "PQconnectPoll() --  "
-								  "couldn't send startup packet: "
-								  "errno=%d\n%s\n",
-								  errno, strerror(errno));
-				goto error_return;
-			}
+				strncpy(sp.user, conn->pguser, SM_USER);
+				strncpy(sp.database, conn->dbName, SM_DATABASE);
+				strncpy(sp.tty, conn->pgtty, SM_TTY);
 
-			conn->status = CONNECTION_AWAITING_RESPONSE;
-			return PGRES_POLLING_READING;
-		}
+				if (conn->pgoptions)
+					strncpy(sp.options, conn->pgoptions, SM_OPTIONS);
 
-		/*
-		 * Handle the authentication exchange: wait for postmaster messages
-		 * and respond as necessary.
-		 */
-		case CONNECTION_AWAITING_RESPONSE:
-		{
-			char		beresp;
-			AuthRequest areq;
+				/*
+				 * Send the startup packet.
+				 *
+				 * Theoretically, this could block, but it really shouldn't
+				 * since we only got here if the socket is write-ready.
+				 */
 
-			/* Scan the message from current point (note that if we find
-			 * the message is incomplete, we will return without advancing
-			 * inStart, and resume here next time).
-			 */
-			conn->inCursor = conn->inStart;
+				if (pqPacketSend(conn, (char *) &sp,
+								 sizeof(StartupPacket)) != STATUS_OK)
+				{
+					printfPQExpBuffer(&conn->errorMessage,
+									  "PQconnectPoll() --  "
+									  "couldn't send startup packet: "
+									  "errno=%d\n%s\n",
+									  errno, strerror(errno));
+					goto error_return;
+				}
 
-			if (pqGetc(&beresp, conn))
-			{
-				/* We'll come back when there are more data */
+				conn->status = CONNECTION_AWAITING_RESPONSE;
 				return PGRES_POLLING_READING;
 			}
 
-			/* Handle errors. */
-			if (beresp == 'E')
+			/*
+			 * Handle the authentication exchange: wait for postmaster
+			 * messages and respond as necessary.
+			 */
+		case CONNECTION_AWAITING_RESPONSE:
 			{
-				if (pqGets(&conn->errorMessage, conn))
+				char		beresp;
+				AuthRequest areq;
+
+				/*
+				 * Scan the message from current point (note that if we
+				 * find the message is incomplete, we will return without
+				 * advancing inStart, and resume here next time).
+				 */
+				conn->inCursor = conn->inStart;
+
+				if (pqGetc(&beresp, conn))
 				{
 					/* We'll come back when there are more data */
 					return PGRES_POLLING_READING;
 				}
-				/* OK, we read the message; mark data consumed */
-				conn->inStart = conn->inCursor;
-				/* The postmaster typically won't end its message with a
-				 * newline, so add one to conform to libpq conventions.
-				 */
-				appendPQExpBufferChar(&conn->errorMessage, '\n');
-				goto error_return;
-			}
 
-			/* Otherwise it should be an authentication request. */
-			if (beresp != 'R')
-			{
-				printfPQExpBuffer(&conn->errorMessage,
-								  "PQconnectPoll() -- expected "
-								  "authentication request\n");
-				goto error_return;
-			}
+				/* Handle errors. */
+				if (beresp == 'E')
+				{
+					if (pqGets(&conn->errorMessage, conn))
+					{
+						/* We'll come back when there are more data */
+						return PGRES_POLLING_READING;
+					}
+					/* OK, we read the message; mark data consumed */
+					conn->inStart = conn->inCursor;
+
+					/*
+					 * The postmaster typically won't end its message with
+					 * a newline, so add one to conform to libpq
+					 * conventions.
+					 */
+					appendPQExpBufferChar(&conn->errorMessage, '\n');
+					goto error_return;
+				}
 
-			/* Get the type of request. */
-			if (pqGetInt((int *) &areq, 4, conn))
-			{
-				/* We'll come back when there are more data */
-				return PGRES_POLLING_READING;
-			}
+				/* Otherwise it should be an authentication request. */
+				if (beresp != 'R')
+				{
+					printfPQExpBuffer(&conn->errorMessage,
+									  "PQconnectPoll() -- expected "
+									  "authentication request\n");
+					goto error_return;
+				}
 
-			/* Get the password salt if there is one. */
-			if (areq == AUTH_REQ_CRYPT)
-			{
-				if (pqGetnchar(conn->salt, sizeof(conn->salt), conn))
+				/* Get the type of request. */
+				if (pqGetInt((int *) &areq, 4, conn))
 				{
 					/* We'll come back when there are more data */
 					return PGRES_POLLING_READING;
 				}
-			}
 
-			/* OK, we successfully read the message; mark data consumed */
-			conn->inStart = conn->inCursor;
+				/* Get the password salt if there is one. */
+				if (areq == AUTH_REQ_CRYPT)
+				{
+					if (pqGetnchar(conn->salt, sizeof(conn->salt), conn))
+					{
+						/* We'll come back when there are more data */
+						return PGRES_POLLING_READING;
+					}
+				}
+
+				/*
+				 * OK, we successfully read the message; mark data
+				 * consumed
+				 */
+				conn->inStart = conn->inCursor;
 
-			/* Respond to the request if necessary. */
-			/* Note that conn->pghost must be non-NULL if we are going to
-			 * avoid the Kerberos code doing a hostname look-up. */
-			/* XXX fe-auth.c has not been fixed to support PQExpBuffers, so: */
-			if (fe_sendauth(areq, conn, conn->pghost, conn->pgpass,
-							conn->errorMessage.data) != STATUS_OK)
-			{
+				/* Respond to the request if necessary. */
+
+				/*
+				 * Note that conn->pghost must be non-NULL if we are going
+				 * to avoid the Kerberos code doing a hostname look-up.
+				 */
+
+				/*
+				 * XXX fe-auth.c has not been fixed to support
+				 * PQExpBuffers, so:
+				 */
+				if (fe_sendauth(areq, conn, conn->pghost, conn->pgpass,
+								conn->errorMessage.data) != STATUS_OK)
+				{
+					conn->errorMessage.len = strlen(conn->errorMessage.data);
+					goto error_return;
+				}
 				conn->errorMessage.len = strlen(conn->errorMessage.data);
-				goto error_return;
-			}
-			conn->errorMessage.len = strlen(conn->errorMessage.data);
 
-			/* Just make sure that any data sent by fe_sendauth is flushed
-			 * out.  Although this theoretically could block, it really
-			 * shouldn't since we don't send large auth responses.
-			 */
-			if (pqFlush(conn))
-				goto error_return;
+				/*
+				 * Just make sure that any data sent by fe_sendauth is
+				 * flushed out.  Although this theoretically could block,
+				 * it really shouldn't since we don't send large auth
+				 * responses.
+				 */
+				if (pqFlush(conn))
+					goto error_return;
 
-			if (areq == AUTH_REQ_OK)
-			{
-				/* We are done with authentication exchange */
-				conn->status = CONNECTION_AUTH_OK;
-				/* Set asyncStatus so that PQsetResult will think that what
-				 * comes back next is the result of a query.  See below.  */
-				conn->asyncStatus = PGASYNC_BUSY;
-			}
+				if (areq == AUTH_REQ_OK)
+				{
+					/* We are done with authentication exchange */
+					conn->status = CONNECTION_AUTH_OK;
+
+					/*
+					 * Set asyncStatus so that PQsetResult will think that
+					 * what comes back next is the result of a query.  See
+					 * below.
+					 */
+					conn->asyncStatus = PGASYNC_BUSY;
+				}
 
-			/* Look to see if we have more data yet. */
-			goto keep_going;
-		}
+				/* Look to see if we have more data yet. */
+				goto keep_going;
+			}
 
 		case CONNECTION_AUTH_OK:
-		{
-			/* ----------
-			 * Now we expect to hear from the backend. A ReadyForQuery
-			 * message indicates that startup is successful, but we might
-			 * also get an Error message indicating failure. (Notice
-			 * messages indicating nonfatal warnings are also allowed by
-			 * the protocol, as is a BackendKeyData message.) Easiest way
-			 * to handle this is to let PQgetResult() read the messages. We
-			 * just have to fake it out about the state of the connection,
-			 * by setting asyncStatus = PGASYNC_BUSY (done above).
-			 *----------
-			 */
-
-			if (PQisBusy(conn))
-				return PGRES_POLLING_READING;
-			
-			res = PQgetResult(conn);
-			/* NULL return indicating we have gone to
-			   IDLE state is expected */
-			if (res)
 			{
-				if (res->resultStatus != PGRES_FATAL_ERROR)
-					printfPQExpBuffer(&conn->errorMessage,
-									  "PQconnectPoll() -- unexpected message "
-									  "during startup\n");
-				/* if the resultStatus is FATAL, then conn->errorMessage
-				 * already has a copy of the error; needn't copy it back.
-				 * But add a newline if it's not there already, since
-				 * postmaster error messages may not have one.
+				/* ----------
+				 * Now we expect to hear from the backend. A ReadyForQuery
+				 * message indicates that startup is successful, but we might
+				 * also get an Error message indicating failure. (Notice
+				 * messages indicating nonfatal warnings are also allowed by
+				 * the protocol, as is a BackendKeyData message.) Easiest way
+				 * to handle this is to let PQgetResult() read the messages. We
+				 * just have to fake it out about the state of the connection,
+				 * by setting asyncStatus = PGASYNC_BUSY (done above).
+				 *----------
 				 */
-				if (conn->errorMessage.len <= 0 ||
-					conn->errorMessage.data[conn->errorMessage.len-1] != '\n')
-					appendPQExpBufferChar(&conn->errorMessage, '\n');
-				PQclear(res);
-				goto error_return;
-			}
 
-			/*
-			 * Post-connection housekeeping. Prepare to send environment
-			 * variables to server.
-			 */
-			if (! PQsetenvStart(conn))
-				goto error_return;
+				if (PQisBusy(conn))
+					return PGRES_POLLING_READING;
 
-			conn->status = CONNECTION_SETENV;
+				res = PQgetResult(conn);
 
-			goto keep_going;
-		}
+				/*
+				 * NULL return indicating we have gone to IDLE state is
+				 * expected
+				 */
+				if (res)
+				{
+					if (res->resultStatus != PGRES_FATAL_ERROR)
+						printfPQExpBuffer(&conn->errorMessage,
+								 "PQconnectPoll() -- unexpected message "
+										  "during startup\n");
+
+					/*
+					 * if the resultStatus is FATAL, then
+					 * conn->errorMessage already has a copy of the error;
+					 * needn't copy it back. But add a newline if it's not
+					 * there already, since postmaster error messages may
+					 * not have one.
+					 */
+					if (conn->errorMessage.len <= 0 ||
+						conn->errorMessage.data[conn->errorMessage.len - 1] != '\n')
+						appendPQExpBufferChar(&conn->errorMessage, '\n');
+					PQclear(res);
+					goto error_return;
+				}
+
+				/*
+				 * Post-connection housekeeping. Prepare to send
+				 * environment variables to server.
+				 */
+				if (!PQsetenvStart(conn))
+					goto error_return;
+
+				conn->status = CONNECTION_SETENV;
+
+				goto keep_going;
+			}
 
 		case CONNECTION_SETENV:
-			/* We pretend that the connection is OK for the duration of
-			   these queries. */
+
+			/*
+			 * We pretend that the connection is OK for the duration of
+			 * these queries.
+			 */
 			conn->status = CONNECTION_OK;
 
 			switch (PQsetenvPoll(conn))
 			{
-				case PGRES_POLLING_OK: /* Success */
+				case PGRES_POLLING_OK:	/* Success */
 					conn->status = CONNECTION_OK;
 					return PGRES_POLLING_OK;
 
-				case PGRES_POLLING_READING: /* Still going */
+				case PGRES_POLLING_READING:		/* Still going */
 					conn->status = CONNECTION_SETENV;
 					return PGRES_POLLING_READING;
 
-				case PGRES_POLLING_WRITING: /* Still going */
+				case PGRES_POLLING_WRITING:		/* Still going */
 					conn->status = CONNECTION_SETENV;
 					return PGRES_POLLING_WRITING;
 
@@ -1327,8 +1397,8 @@ PQconnectPoll(PGconn *conn)
 
 		default:
 			printfPQExpBuffer(&conn->errorMessage,
-							  "PQconnectPoll() -- unknown connection state - "
-							  "probably indicative of memory corruption!\n");
+						 "PQconnectPoll() -- unknown connection state - "
+						  "probably indicative of memory corruption!\n");
 			goto error_return;
 	}
 
@@ -1368,7 +1438,7 @@ PQsetenvStart(PGconn *conn)
 #else
 	conn->setenv_state = SETENV_STATE_OPTION_SEND;
 #endif
-	
+
 	conn->next_eo = EnvironmentOptions;
 
 	return true;
@@ -1386,8 +1456,10 @@ static PostgresPollingStatusType
 PQsetenvPoll(PGconn *conn)
 {
 	PGresult   *res;
+
 #ifdef MULTIBYTE
 	static const char envname[] = "PGCLIENTENCODING";
+
 #endif
 
 	if (conn == NULL || conn->status == CONNECTION_BAD)
@@ -1396,168 +1468,175 @@ PQsetenvPoll(PGconn *conn)
 	/* Check whether there are any data for us */
 	switch (conn->setenv_state)
 	{
-		/* These are reading states */
+			/* These are reading states */
 #ifdef MULTIBYTE
 		case SETENV_STATE_ENCODINGS_WAIT:
 #endif
 		case SETENV_STATE_OPTION_WAIT:
-		{
-			/* Load waiting data */
-			int n = pqReadData(conn);
-				
-			if (n < 0)
-				goto error_return;
-			if (n == 0)
-				return PGRES_POLLING_READING;
+			{
+				/* Load waiting data */
+				int			n = pqReadData(conn);
 
-			break;
-		}
+				if (n < 0)
+					goto error_return;
+				if (n == 0)
+					return PGRES_POLLING_READING;
 
-		/* These are writing states, so we just proceed. */
+				break;
+			}
+
+			/* These are writing states, so we just proceed. */
 #ifdef MULTIBYTE
 		case SETENV_STATE_ENCODINGS_SEND:
 #endif
 		case SETENV_STATE_OPTION_SEND:
 			break;
 
-		/* Should we raise an error if called when not active? */
+			/* Should we raise an error if called when not active? */
 		case SETENV_STATE_IDLE:
 			return PGRES_POLLING_OK;
 
 		default:
 			printfPQExpBuffer(&conn->errorMessage,
 							  "PQsetenvPoll() -- unknown state - "
-							  "probably indicative of memory corruption!\n");
+						  "probably indicative of memory corruption!\n");
 			goto error_return;
 	}
 
 
- keep_going: /* We will come back to here until there is nothing left to
-				parse. */
-	switch(conn->setenv_state)
+keep_going:						/* We will come back to here until there
+								 * is nothing left to parse. */
+	switch (conn->setenv_state)
 	{
 
 #ifdef MULTIBYTE
 		case SETENV_STATE_ENCODINGS_SEND:
-		{
-			const char *env;
-			
-			/* query server encoding */
-			env = getenv(envname);
-			if (!env || *env == '\0')
 			{
-				if (!PQsendQuery(conn,
-								 "select getdatabaseencoding()"))
-					goto error_return;
+				const char *env;
 
-				conn->setenv_state = SETENV_STATE_ENCODINGS_WAIT;
-				return PGRES_POLLING_READING;
+				/* query server encoding */
+				env = getenv(envname);
+				if (!env || *env == '\0')
+				{
+					if (!PQsendQuery(conn,
+									 "select getdatabaseencoding()"))
+						goto error_return;
+
+					conn->setenv_state = SETENV_STATE_ENCODINGS_WAIT;
+					return PGRES_POLLING_READING;
+				}
 			}
-		}
 
 		case SETENV_STATE_ENCODINGS_WAIT:
-		{
-			if (PQisBusy(conn))
-				return PGRES_POLLING_READING;
-			
-			res = PQgetResult(conn);
-
-			if (res)
 			{
-				char *encoding;
+				if (PQisBusy(conn))
+					return PGRES_POLLING_READING;
+
+				res = PQgetResult(conn);
 
-				if (PQresultStatus(res) != PGRES_TUPLES_OK)
+				if (res)
 				{
+					char	   *encoding;
+
+					if (PQresultStatus(res) != PGRES_TUPLES_OK)
+					{
+						PQclear(res);
+						goto error_return;
+					}
+
+					/* set client encoding in pg_conn struct */
+					encoding = PQgetvalue(res, 0, 0);
+					if (!encoding)		/* this should not happen */
+						conn->client_encoding = SQL_ASCII;
+					else
+						conn->client_encoding = pg_char_to_encoding(encoding);
 					PQclear(res);
-					goto error_return;
+
+					/*
+					 * We have to keep going in order to clear up the
+					 * query
+					 */
+					goto keep_going;
 				}
 
-				/* set client encoding in pg_conn struct */
-				encoding = PQgetvalue(res, 0, 0);
-				if (!encoding)			/* this should not happen */
-					conn->client_encoding = SQL_ASCII;
-				else
-					conn->client_encoding = pg_char_to_encoding(encoding);
-				PQclear(res);
-				/* We have to keep going in order to clear up the query */
+				/* NULL result indicates that the query is finished */
+
+				/* Move on to setting the environment options */
+				conn->setenv_state = SETENV_STATE_OPTION_SEND;
 				goto keep_going;
 			}
-
-			/* NULL result indicates that the query is finished */
-
-			/* Move on to setting the environment options */
-			conn->setenv_state = SETENV_STATE_OPTION_SEND;
-			goto keep_going;
-		}
 #endif
 
 		case SETENV_STATE_OPTION_SEND:
-		{
-			/* Send an Environment Option */
-			char		setQuery[100];	/* note length limits in sprintf's below */
-
-			if (conn->next_eo->envName)
 			{
-				const char *val;
+				/* Send an Environment Option */
+				char		setQuery[100];		/* note length limits in
+												 * sprintf's below */
 
-				if ((val = getenv(conn->next_eo->envName)))
+				if (conn->next_eo->envName)
 				{
-					if (strcasecmp(val, "default") == 0)
-						sprintf(setQuery, "SET %s = %.60s",
-								conn->next_eo->pgName, val);
-					else
-						sprintf(setQuery, "SET %s = '%.60s'",
-								conn->next_eo->pgName, val);
+					const char *val;
+
+					if ((val = getenv(conn->next_eo->envName)))
+					{
+						if (strcasecmp(val, "default") == 0)
+							sprintf(setQuery, "SET %s = %.60s",
+									conn->next_eo->pgName, val);
+						else
+							sprintf(setQuery, "SET %s = '%.60s'",
+									conn->next_eo->pgName, val);
 #ifdef CONNECTDEBUG
-					printf("Use environment variable %s to send %s\n",
-						   conn->next_eo->envName, setQuery);
+						printf("Use environment variable %s to send %s\n",
+							   conn->next_eo->envName, setQuery);
 #endif
-					if (!PQsendQuery(conn, setQuery))
-						goto error_return;
+						if (!PQsendQuery(conn, setQuery))
+							goto error_return;
 
-					conn->setenv_state = SETENV_STATE_OPTION_WAIT;
+						conn->setenv_state = SETENV_STATE_OPTION_WAIT;
+					}
+					else
+						conn->next_eo++;
 				}
 				else
 				{
-					conn->next_eo++;
+					/* No more options to send, so we are done. */
+					conn->setenv_state = SETENV_STATE_IDLE;
 				}
-			}
-			else
-			{
-				/* No more options to send, so we are done. */
-				conn->setenv_state = SETENV_STATE_IDLE;
-			}
 
-			goto keep_going;
-		}
+				goto keep_going;
+			}
 
 		case SETENV_STATE_OPTION_WAIT:
-		{
-			if (PQisBusy(conn))
-				return PGRES_POLLING_READING;
-			
-			res = PQgetResult(conn);
-
-			if (res)
 			{
-				if (PQresultStatus(res) != PGRES_COMMAND_OK)
+				if (PQisBusy(conn))
+					return PGRES_POLLING_READING;
+
+				res = PQgetResult(conn);
+
+				if (res)
 				{
+					if (PQresultStatus(res) != PGRES_COMMAND_OK)
+					{
+						PQclear(res);
+						goto error_return;
+					}
+					/* Don't need the result */
 					PQclear(res);
-					goto error_return;
+
+					/*
+					 * We have to keep going in order to clear up the
+					 * query
+					 */
+					goto keep_going;
 				}
-				/* Don't need the result */
-				PQclear(res);
-				/* We have to keep going in order to clear up the query */
-				goto keep_going;
-			}
 
-			/* NULL result indicates that the query is finished */
+				/* NULL result indicates that the query is finished */
 
-			/* Send the next option */
-			conn->next_eo++;
-			conn->setenv_state = SETENV_STATE_OPTION_SEND;
-			goto keep_going;
-		}
+				/* Send the next option */
+				conn->next_eo++;
+				conn->setenv_state = SETENV_STATE_OPTION_SEND;
+				goto keep_going;
+			}
 
 		case SETENV_STATE_IDLE:
 			return PGRES_POLLING_OK;
@@ -1565,13 +1644,13 @@ PQsetenvPoll(PGconn *conn)
 		default:
 			printfPQExpBuffer(&conn->errorMessage,
 							  "PQsetenvPoll() -- unknown state - "
-							  "probably indicative of memory corruption!\n");
+						  "probably indicative of memory corruption!\n");
 			goto error_return;
 	}
 
 	/* Unreachable */
 
- error_return:
+error_return:
 	conn->setenv_state = SETENV_STATE_IDLE;
 	return PGRES_POLLING_FAILED;
 }
@@ -1597,12 +1676,14 @@ PQsetenv(PGconn *conn)
 {
 	PostgresPollingStatusType flag = PGRES_POLLING_WRITING;
 
-	if (! PQsetenvStart(conn))
+	if (!PQsetenvStart(conn))
 		return false;
 
-	for (;;) {
+	for (;;)
+	{
+
 		/*
-		 * Wait, if necessary.  Note that the initial state (just after
+		 * Wait, if necessary.	Note that the initial state (just after
 		 * PQsetenvStart) is to wait for the socket to select for writing.
 		 */
 		switch (flag)
@@ -1612,7 +1693,7 @@ PQsetenv(PGconn *conn)
 
 			case PGRES_POLLING_OK:
 				return true;	/* success! */
-				
+
 			case PGRES_POLLING_READING:
 				if (pqWait(1, 0, conn))
 				{
@@ -1634,6 +1715,7 @@ PQsetenv(PGconn *conn)
 				conn->status = CONNECTION_BAD;
 				return false;
 		}
+
 		/*
 		 * Now try to advance the state machine.
 		 */
@@ -1641,7 +1723,7 @@ PQsetenv(PGconn *conn)
 	}
 }
 
-#endif /* NOT_USED */
+#endif	 /* NOT_USED */
 
 
 /*
@@ -1670,15 +1752,15 @@ makeEmptyPGconn(void)
 #endif
 
 	/*
-	 * The output buffer size is set to 8K, which is the usual size of pipe
-	 * buffers on Unix systems.  That way, when we are sending a large
-	 * amount of data, we avoid incurring extra kernel context swaps for
-	 * partial bufferloads.  Note that we currently don't ever enlarge
+	 * The output buffer size is set to 8K, which is the usual size of
+	 * pipe buffers on Unix systems.  That way, when we are sending a
+	 * large amount of data, we avoid incurring extra kernel context swaps
+	 * for partial bufferloads.  Note that we currently don't ever enlarge
 	 * the output buffer.
 	 *
 	 * With the same goal of minimizing context swaps, the input buffer will
-	 * be enlarged anytime it has less than 8K free, so we initially allocate
-	 * twice that.
+	 * be enlarged anytime it has less than 8K free, so we initially
+	 * allocate twice that.
 	 */
 	conn->inBufSize = 16 * 1024;
 	conn->inBuffer = (char *) malloc(conn->inBufSize);
@@ -1712,7 +1794,7 @@ freePGconn(PGconn *conn)
 	pqClearAsyncResult(conn);	/* deallocate result and curTuple */
 #ifdef USE_SSL
 	if (conn->ssl)
-	  SSL_free(conn->ssl);
+		SSL_free(conn->ssl);
 #endif
 	if (conn->sock >= 0)
 #ifdef WIN32
@@ -1770,7 +1852,7 @@ closePGconn(PGconn *conn)
 		(void) pqFlush(conn);
 	}
 
-	/* 
+	/*
 	 * must reset the blocking status so a possible reconnect will work
 	 * don't call PQsetnonblocking() because it will fail if it's unable
 	 * to flush the connection.
@@ -1861,9 +1943,7 @@ PostgresPollingStatusType
 PQresetPoll(PGconn *conn)
 {
 	if (conn)
-	{
 		return PQconnectPoll(conn);
-	}
 
 	return PGRES_POLLING_FAILED;
 }
@@ -2028,7 +2108,7 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage)
 	if (options == NULL)
 	{
 		printfPQExpBuffer(errorMessage,
-		  "FATAL: cannot allocate memory for copy of PQconninfoOptions\n");
+		"FATAL: cannot allocate memory for copy of PQconninfoOptions\n");
 		return NULL;
 	}
 	memcpy(options, PQconninfoOptions, sizeof(PQconninfoOptions));
@@ -2076,7 +2156,7 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage)
 		if (*cp != '=')
 		{
 			printfPQExpBuffer(errorMessage,
-							  "ERROR: Missing '=' after '%s' in conninfo\n",
+						   "ERROR: Missing '=' after '%s' in conninfo\n",
 							  pname);
 			PQconninfoFree(options);
 			free(buf);
@@ -2125,7 +2205,7 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage)
 				if (*cp == '\0')
 				{
 					printfPQExpBuffer(errorMessage,
-							"ERROR: PQconnectdb() - unterminated quoted string in conninfo\n");
+									  "ERROR: PQconnectdb() - unterminated quoted string in conninfo\n");
 					PQconninfoFree(options);
 					free(buf);
 					return NULL;
@@ -2375,10 +2455,10 @@ PQclientEncoding(const PGconn *conn)
 int
 PQsetClientEncoding(PGconn *conn, const char *encoding)
 {
-	char qbuf[128];
+	char		qbuf[128];
 	static char query[] = "set client_encoding to '%s'";
-	PGresult *res;
-	int status;
+	PGresult   *res;
+	int			status;
 
 	if (!conn || conn->status != CONNECTION_OK)
 		return -1;
@@ -2394,7 +2474,7 @@ PQsetClientEncoding(PGconn *conn, const char *encoding)
 	sprintf(qbuf, query, encoding);
 	res = PQexec(conn, qbuf);
 
-	if (res == (PGresult *)NULL)
+	if (res == (PGresult *) NULL)
 		return -1;
 	if (res->resultStatus != PGRES_COMMAND_OK)
 		status = -1;
@@ -2402,17 +2482,19 @@ PQsetClientEncoding(PGconn *conn, const char *encoding)
 	{
 		/* change libpq internal encoding */
 		conn->client_encoding = pg_char_to_encoding(encoding);
-		status = 0;	/* everything is ok */
+		status = 0;				/* everything is ok */
 	}
 	PQclear(res);
-	return(status);
+	return (status);
 }
+
 #else
 int
 PQsetClientEncoding(PGconn *conn, const char *encoding)
 {
 	return -1;
 }
+
 #endif
 
 void
@@ -2465,7 +2547,7 @@ PQsetNoticeProcessor(PGconn *conn, PQnoticeProcessor proc, void *arg)
 static void
 defaultNoticeProcessor(void *arg, const char *message)
 {
-    (void)arg; /*not used*/
+	(void) arg;					/* not used */
 	/* Note: we expect the supplied string to end with a newline already. */
 	fprintf(stderr, "%s", message);
 }
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
index 6b3999193d57046666fb52af65d8a3d526381d86..6617bb2bc30deaea61af4b4f44e3b37ca8f1800a 100644
--- a/src/interfaces/libpq/fe-exec.c
+++ b/src/interfaces/libpq/fe-exec.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.93 2000/03/14 23:59:23 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.94 2000/04/12 17:17:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -27,7 +27,7 @@
 #endif
 
 /* keep this in same order as ExecStatusType in libpq-fe.h */
-char * const pgresStatus[] = {
+char	   *const pgresStatus[] = {
 	"PGRES_EMPTY_QUERY",
 	"PGRES_COMMAND_OK",
 	"PGRES_TUPLES_OK",
@@ -47,7 +47,7 @@ char * const pgresStatus[] = {
 static void pqCatenateResultError(PGresult *res, const char *msg);
 static void saveErrorResult(PGconn *conn);
 static PGresult *prepareAsyncResult(PGconn *conn);
-static int	addTuple(PGresult *res, PGresAttValue *tup);
+static int	addTuple(PGresult *res, PGresAttValue * tup);
 static void parseInput(PGconn *conn);
 static void handleSendFailure(PGconn *conn);
 static int	getRowDescriptions(PGconn *conn);
@@ -178,7 +178,7 @@ PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status)
 		/* defaults... */
 		result->noticeHook = NULL;
 		result->noticeArg = NULL;
-		result->client_encoding = 0; /* should be SQL_ASCII */
+		result->client_encoding = 0;	/* should be SQL_ASCII */
 	}
 
 	return result;
@@ -324,7 +324,7 @@ pqSetResultError(PGresult *res, const char *msg)
 static void
 pqCatenateResultError(PGresult *res, const char *msg)
 {
-	PQExpBufferData  errorBuf;
+	PQExpBufferData errorBuf;
 
 	if (!res || !msg)
 		return;
@@ -391,7 +391,9 @@ pqClearAsyncResult(PGconn *conn)
 static void
 saveErrorResult(PGconn *conn)
 {
-	/* If no old async result, just let PQmakeEmptyPGresult make one.
+
+	/*
+	 * If no old async result, just let PQmakeEmptyPGresult make one.
 	 * Likewise if old result is not an error message.
 	 */
 	if (conn->result == NULL ||
@@ -421,9 +423,9 @@ prepareAsyncResult(PGconn *conn)
 	PGresult   *res;
 
 	/*
-	 * conn->result is the PGresult to return.	If it is NULL
-	 * (which probably shouldn't happen) we assume there is an
-	 * appropriate error message in conn->errorMessage.
+	 * conn->result is the PGresult to return.	If it is NULL (which
+	 * probably shouldn't happen) we assume there is an appropriate error
+	 * message in conn->errorMessage.
 	 */
 	res = conn->result;
 	conn->result = NULL;		/* handing over ownership to caller */
@@ -432,9 +434,10 @@ prepareAsyncResult(PGconn *conn)
 		res = PQmakeEmptyPGresult(conn, PGRES_FATAL_ERROR);
 	else
 	{
+
 		/*
-		 * Make sure PQerrorMessage agrees with result; it could
-		 * be different if we have concatenated messages.
+		 * Make sure PQerrorMessage agrees with result; it could be
+		 * different if we have concatenated messages.
 		 */
 		resetPQExpBuffer(&conn->errorMessage);
 		appendPQExpBufferStr(&conn->errorMessage,
@@ -449,7 +452,7 @@ prepareAsyncResult(PGconn *conn)
  *	  Returns TRUE if OK, FALSE if not enough memory to add the row
  */
 static int
-addTuple(PGresult *res, PGresAttValue *tup)
+addTuple(PGresult *res, PGresAttValue * tup)
 {
 	if (res->ntups >= res->tupArrSize)
 	{
@@ -521,7 +524,7 @@ PQsendQuery(PGconn *conn, const char *query)
 	if (conn->asyncStatus != PGASYNC_IDLE)
 	{
 		printfPQExpBuffer(&conn->errorMessage,
-						  "PQsendQuery() -- another query already in progress.\n");
+				"PQsendQuery() -- another query already in progress.\n");
 		return 0;
 	}
 
@@ -532,21 +535,21 @@ PQsendQuery(PGconn *conn, const char *query)
 	/* send the query to the backend; */
 
 	/*
-	 * in order to guarantee that we don't send a partial query 
-	 * where we would become out of sync with the backend and/or
-	 * block during a non-blocking connection we must first flush
-	 * the send buffer before sending more data
+	 * in order to guarantee that we don't send a partial query where we
+	 * would become out of sync with the backend and/or block during a
+	 * non-blocking connection we must first flush the send buffer before
+	 * sending more data
 	 *
-	 * an alternative is to implement 'queue reservations' where
-	 * we are able to roll up a transaction 
-	 * (the 'Q' along with our query) and make sure we have
-	 * enough space for it all in the send buffer.
+	 * an alternative is to implement 'queue reservations' where we are able
+	 * to roll up a transaction (the 'Q' along with our query) and make
+	 * sure we have enough space for it all in the send buffer.
 	 */
 	if (pqIsnonblocking(conn))
 	{
+
 		/*
-		 * the buffer must have emptied completely before we allow
-		 * a new query to be buffered
+		 * the buffer must have emptied completely before we allow a new
+		 * query to be buffered
 		 */
 		if (pqFlush(conn))
 			return 0;
@@ -555,20 +558,21 @@ PQsendQuery(PGconn *conn, const char *query)
 		if (pqPutnchar("Q", 1, conn) ||
 			pqPuts(query, conn))
 		{
-			handleSendFailure(conn);	
+			handleSendFailure(conn);
 			return 0;
 		}
+
 		/*
-		 * give the data a push, ignore the return value as
-		 * ConsumeInput() will do any aditional flushing if needed
+		 * give the data a push, ignore the return value as ConsumeInput()
+		 * will do any aditional flushing if needed
 		 */
-		(void) pqFlush(conn);	
+		(void) pqFlush(conn);
 	}
 	else
 	{
-		/* 
-		 * the frontend-backend protocol uses 'Q' to 
-		 * designate queries 
+
+		/*
+		 * the frontend-backend protocol uses 'Q' to designate queries
 		 */
 		if (pqPutnchar("Q", 1, conn) ||
 			pqPuts(query, conn) ||
@@ -596,16 +600,17 @@ PQsendQuery(PGconn *conn, const char *query)
 static void
 handleSendFailure(PGconn *conn)
 {
+
 	/*
 	 * Accept any available input data, ignoring errors.  Note that if
 	 * pqReadData decides the backend has closed the channel, it will
 	 * close our side of the socket --- that's just what we want here.
 	 */
 	while (pqReadData(conn) > 0)
-		/* loop until no more data readable */ ;
+		 /* loop until no more data readable */ ;
 
 	/*
-	 * Parse any available input messages.  Since we are in PGASYNC_IDLE
+	 * Parse any available input messages.	Since we are in PGASYNC_IDLE
 	 * state, only NOTICE and NOTIFY messages will be eaten.
 	 */
 	parseInput(conn);
@@ -631,11 +636,11 @@ PQconsumeInput(PGconn *conn)
 	 */
 	if (pqReadData(conn) < 0)
 	{
+
 		/*
-		 * for non-blocking connections
-		 * try to flush the send-queue otherwise we may never get a 
-		 * responce for something that may not have already been sent
-		 * because it's in our write buffer!
+		 * for non-blocking connections try to flush the send-queue
+		 * otherwise we may never get a responce for something that may
+		 * not have already been sent because it's in our write buffer!
 		 */
 		if (pqIsnonblocking(conn))
 			(void) pqFlush(conn);
@@ -686,11 +691,11 @@ parseInput(PGconn *conn)
 		 * OUT; always process them right away.
 		 *
 		 * Most other messages should only be processed while in BUSY state.
-		 * (In particular, in READY state we hold off further parsing until
-		 * the application collects the current PGresult.)
+		 * (In particular, in READY state we hold off further parsing
+		 * until the application collects the current PGresult.)
 		 *
-		 * However, if the state is IDLE then we got trouble; we need to
-		 * deal with the unexpected message somehow.
+		 * However, if the state is IDLE then we got trouble; we need to deal
+		 * with the unexpected message somehow.
 		 */
 		if (id == 'A')
 		{
@@ -707,6 +712,7 @@ parseInput(PGconn *conn)
 			/* If not IDLE state, just wait ... */
 			if (conn->asyncStatus != PGASYNC_IDLE)
 				return;
+
 			/*
 			 * Unexpected message in IDLE state; need to recover somehow.
 			 * ERROR messages are displayed using the notice processor;
@@ -723,7 +729,7 @@ parseInput(PGconn *conn)
 			else
 			{
 				sprintf(noticeWorkspace,
-						"Backend message type 0x%02x arrived while idle\n",
+					  "Backend message type 0x%02x arrived while idle\n",
 						id);
 				DONOTICE(conn, noticeWorkspace);
 				/* Discard the unexpected message; good idea?? */
@@ -733,6 +739,7 @@ parseInput(PGconn *conn)
 		}
 		else
 		{
+
 			/*
 			 * In BUSY state, we can process everything.
 			 */
@@ -743,13 +750,13 @@ parseInput(PGconn *conn)
 						return;
 					if (conn->result == NULL)
 						conn->result = PQmakeEmptyPGresult(conn,
-														   PGRES_COMMAND_OK);
+													   PGRES_COMMAND_OK);
 					strncpy(conn->result->cmdStatus, conn->workBuffer.data,
 							CMDSTATUS_LEN);
 					conn->asyncStatus = PGASYNC_READY;
 					break;
 				case 'E':		/* error return */
-					if (pqGets(& conn->errorMessage, conn))
+					if (pqGets(&conn->errorMessage, conn))
 						return;
 					/* build an error result holding the error message */
 					saveErrorResult(conn);
@@ -823,7 +830,7 @@ parseInput(PGconn *conn)
 					else
 					{
 						sprintf(noticeWorkspace,
-								"Backend sent D message without prior T\n");
+							 "Backend sent D message without prior T\n");
 						DONOTICE(conn, noticeWorkspace);
 						/* Discard the unexpected message; good idea?? */
 						conn->inStart = conn->inEnd;
@@ -840,7 +847,7 @@ parseInput(PGconn *conn)
 					else
 					{
 						sprintf(noticeWorkspace,
-								"Backend sent B message without prior T\n");
+							 "Backend sent B message without prior T\n");
 						DONOTICE(conn, noticeWorkspace);
 						/* Discard the unexpected message; good idea?? */
 						conn->inStart = conn->inEnd;
@@ -855,10 +862,10 @@ parseInput(PGconn *conn)
 					break;
 				default:
 					printfPQExpBuffer(&conn->errorMessage,
-						"Unknown protocol character '%c' read from backend.  "
-						"(The protocol character is the first character the "
-						"backend sends in response to a query it receives).\n",
-						id);
+					"Unknown protocol character '%c' read from backend.  "
+					"(The protocol character is the first character the "
+									  "backend sends in response to a query it receives).\n",
+									  id);
 					/* build an error result holding the error message */
 					saveErrorResult(conn);
 					/* Discard the unexpected message; good idea?? */
@@ -963,6 +970,7 @@ getAnotherTuple(PGconn *conn, int binary)
 	PGresult   *result = conn->result;
 	int			nfields = result->numAttributes;
 	PGresAttValue *tup;
+
 	/* the backend sends us a bitmap of which attributes are null */
 	char		std_bitmap[64]; /* used unless it doesn't fit */
 	char	   *bitmap = std_bitmap;
@@ -1055,7 +1063,9 @@ getAnotherTuple(PGconn *conn, int binary)
 
 outOfMemory:
 	/* Replace partially constructed result with an error result */
-	/* we do NOT use saveErrorResult() here, because of the likelihood
+
+	/*
+	 * we do NOT use saveErrorResult() here, because of the likelihood
 	 * that there's not enough memory to concatenate messages...
 	 */
 	pqClearAsyncResult(conn);
@@ -1116,8 +1126,10 @@ PQgetResult(PGconn *conn)
 		if (pqWait(TRUE, FALSE, conn) ||
 			pqReadData(conn) < 0)
 		{
-			/* conn->errorMessage has been set by pqWait or pqReadData.
-			 * We want to append it to any already-received error message.
+
+			/*
+			 * conn->errorMessage has been set by pqWait or pqReadData. We
+			 * want to append it to any already-received error message.
 			 */
 			saveErrorResult(conn);
 			conn->asyncStatus = PGASYNC_IDLE;
@@ -1173,12 +1185,12 @@ PQexec(PGconn *conn, const char *query)
 {
 	PGresult   *result;
 	PGresult   *lastResult;
-	bool	savedblocking;
+	bool		savedblocking;
 
 	/*
-	 * we assume anyone calling PQexec wants blocking behaviour,
-	 * we force the blocking status of the connection to blocking
-	 * for the duration of this function and restore it on return
+	 * we assume anyone calling PQexec wants blocking behaviour, we force
+	 * the blocking status of the connection to blocking for the duration
+	 * of this function and restore it on return
 	 */
 	savedblocking = pqIsnonblocking(conn);
 	if (PQsetnonblocking(conn, FALSE) == -1)
@@ -1205,15 +1217,15 @@ PQexec(PGconn *conn, const char *query)
 
 	/* OK to send the message */
 	if (!PQsendQuery(conn, query))
-		goto errout;	/* restore blocking status */
+		goto errout;			/* restore blocking status */
 
 	/*
 	 * For backwards compatibility, return the last result if there are
 	 * more than one --- but merge error messages if we get more than one
 	 * error result.
 	 *
-	 * We have to stop if we see copy in/out, however.
-	 * We will resume parsing when application calls PQendcopy.
+	 * We have to stop if we see copy in/out, however. We will resume parsing
+	 * when application calls PQendcopy.
 	 */
 	lastResult = NULL;
 	while ((result = PQgetResult(conn)) != NULL)
@@ -1260,11 +1272,13 @@ errout:
 static int
 getNotice(PGconn *conn)
 {
-	/* Since the Notice might be pretty long, we create a temporary
-	 * PQExpBuffer rather than using conn->workBuffer.  workBuffer is
+
+	/*
+	 * Since the Notice might be pretty long, we create a temporary
+	 * PQExpBuffer rather than using conn->workBuffer.	workBuffer is
 	 * intended for stuff that is expected to be short.
 	 */
-	PQExpBufferData  noticeBuf;
+	PQExpBufferData noticeBuf;
 
 	initPQExpBuffer(&noticeBuf);
 	if (pqGets(&noticeBuf, conn))
@@ -1532,13 +1546,13 @@ PQendcopy(PGconn *conn)
 		conn->asyncStatus != PGASYNC_COPY_OUT)
 	{
 		printfPQExpBuffer(&conn->errorMessage,
-			 "PQendcopy() -- I don't think there's a copy in progress.\n");
+		   "PQendcopy() -- I don't think there's a copy in progress.\n");
 		return 1;
 	}
 
 	/*
-	 * make sure no data is waiting to be sent, 
-	 * abort if we are non-blocking and the flush fails
+	 * make sure no data is waiting to be sent, abort if we are
+	 * non-blocking and the flush fails
 	 */
 	if (pqFlush(conn) && pqIsnonblocking(conn))
 		return (1);
@@ -1632,7 +1646,7 @@ PQfn(PGconn *conn,
 		return NULL;
 	}
 
-	if (pqPuts("F ", conn) ||			/* function */
+	if (pqPuts("F ", conn) ||	/* function */
 		pqPutInt(fnid, 4, conn) ||		/* function id */
 		pqPutInt(nargs, 4, conn))		/* # of args */
 	{
@@ -1730,7 +1744,7 @@ PQfn(PGconn *conn,
 				{
 					/* The backend violates the protocol. */
 					printfPQExpBuffer(&conn->errorMessage,
-									  "FATAL: PQfn: protocol error: id=0x%x\n",
+								"FATAL: PQfn: protocol error: id=0x%x\n",
 									  id);
 					saveErrorResult(conn);
 					conn->inStart = conn->inCursor;
@@ -1764,7 +1778,7 @@ PQfn(PGconn *conn,
 			default:
 				/* The backend violates the protocol. */
 				printfPQExpBuffer(&conn->errorMessage,
-								  "FATAL: PQfn: protocol error: id=0x%x\n",
+								"FATAL: PQfn: protocol error: id=0x%x\n",
 								  id);
 				saveErrorResult(conn);
 				conn->inStart = conn->inCursor;
@@ -1775,9 +1789,10 @@ PQfn(PGconn *conn,
 		needInput = false;
 	}
 
-	/* We fall out of the loop only upon failing to read data.
-	 * conn->errorMessage has been set by pqWait or pqReadData.
-	 * We want to append it to any already-received error message.
+	/*
+	 * We fall out of the loop only upon failing to read data.
+	 * conn->errorMessage has been set by pqWait or pqReadData. We want to
+	 * append it to any already-received error message.
 	 */
 	saveErrorResult(conn);
 	return prepareAsyncResult(conn);
@@ -1842,7 +1857,7 @@ PQbinaryTuples(const PGresult *res)
 static int
 check_field_number(const char *routineName, const PGresult *res, int field_num)
 {
-	char noticeBuf[128];
+	char		noticeBuf[128];
 
 	if (!res)
 		return FALSE;			/* no way to display error message... */
@@ -1864,7 +1879,7 @@ static int
 check_tuple_field_number(const char *routineName, const PGresult *res,
 						 int tup_num, int field_num)
 {
-	char noticeBuf[128];
+	char		noticeBuf[128];
 
 	if (!res)
 		return FALSE;			/* no way to display error message... */
@@ -1997,13 +2012,14 @@ PQcmdStatus(PGresult *res)
 char *
 PQoidStatus(const PGresult *res)
 {
-	/* 
-	 * This must be enough to hold the result. Don't laugh, this is
-	 * better than what this function used to do.
+
+	/*
+	 * This must be enough to hold the result. Don't laugh, this is better
+	 * than what this function used to do.
 	 */
 	static char buf[24];
 
-	size_t len;
+	size_t		len;
 
 	if (!res || !res->cmdStatus || strncmp(res->cmdStatus, "INSERT ", 7) != 0)
 		return "";
@@ -2019,25 +2035,25 @@ PQoidStatus(const PGresult *res)
 
 /*
   PQoidValue -
-        a perhaps preferable form of the above which just returns
+		a perhaps preferable form of the above which just returns
 	an Oid type
 */
 Oid
 PQoidValue(const PGresult *res)
 {
-    char * endptr = NULL;
-    long int result;
+	char	   *endptr = NULL;
+	long int	result;
 
-    if (!res || !res->cmdStatus || strncmp(res->cmdStatus, "INSERT ", 7) != 0)
-	return InvalidOid;
+	if (!res || !res->cmdStatus || strncmp(res->cmdStatus, "INSERT ", 7) != 0)
+		return InvalidOid;
 
-    errno = 0;
-    result = strtoul(res->cmdStatus + 7, &endptr, 10);
+	errno = 0;
+	result = strtoul(res->cmdStatus + 7, &endptr, 10);
 
-    if (!endptr || (*endptr != ' ' && *endptr != '\0') || errno == ERANGE)
-	return InvalidOid;
-    else
-	return (Oid)result;
+	if (!endptr || (*endptr != ' ' && *endptr != '\0') || errno == ERANGE)
+		return InvalidOid;
+	else
+		return (Oid) result;
 }
 
 /*
@@ -2048,7 +2064,7 @@ PQoidValue(const PGresult *res)
 char *
 PQcmdTuples(PGresult *res)
 {
-	char noticeBuf[128];
+	char		noticeBuf[128];
 
 	if (!res)
 		return "";
@@ -2160,9 +2176,9 @@ PQsetnonblocking(PGconn *conn, int arg)
 	/*
 	 * to guarantee constancy for flushing/query/result-polling behavior
 	 * we need to flush the send queue at this point in order to guarantee
-	 * proper behavior.
-	 * this is ok because either they are making a transition
-	 *  _from_ or _to_ blocking mode, either way we can block them.
+	 * proper behavior. this is ok because either they are making a
+	 * transition _from_ or _to_ blocking mode, either way we can block
+	 * them.
 	 */
 	/* if we are going from blocking to non-blocking flush here */
 	if (pqFlush(conn))
diff --git a/src/interfaces/libpq/fe-lobj.c b/src/interfaces/libpq/fe-lobj.c
index 6a7fd71f440cb8ba961e8bc3a1498668cb711280..23b9ffb09c0b8384fcd5cf6e47858337a658e9ad 100644
--- a/src/interfaces/libpq/fe-lobj.c
+++ b/src/interfaces/libpq/fe-lobj.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.28 2000/02/07 23:10:11 petere Exp $
+ *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.29 2000/04/12 17:17:15 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -523,7 +523,7 @@ lo_initialize(PGconn *conn)
 	PGresult   *res;
 	PGlobjfuncs *lobjfuncs;
 	int			n;
-	const char	   *fname;
+	const char *fname;
 	Oid			foid;
 
 	/* ----------------
@@ -563,7 +563,7 @@ lo_initialize(PGconn *conn)
 		free(lobjfuncs);
 		PQclear(res);
 		printfPQExpBuffer(&conn->errorMessage,
-						  "ERROR: SELECT didn't return data in lo_initialize()\n");
+				"ERROR: SELECT didn't return data in lo_initialize()\n");
 		return -1;
 	}
 
@@ -603,56 +603,56 @@ lo_initialize(PGconn *conn)
 	if (lobjfuncs->fn_lo_open == 0)
 	{
 		printfPQExpBuffer(&conn->errorMessage,
-						  "ERROR: Cannot determine OID for function lo_open\n");
+				   "ERROR: Cannot determine OID for function lo_open\n");
 		free(lobjfuncs);
 		return -1;
 	}
 	if (lobjfuncs->fn_lo_close == 0)
 	{
 		printfPQExpBuffer(&conn->errorMessage,
-						  "ERROR: Cannot determine OID for function lo_close\n");
+				  "ERROR: Cannot determine OID for function lo_close\n");
 		free(lobjfuncs);
 		return -1;
 	}
 	if (lobjfuncs->fn_lo_creat == 0)
 	{
 		printfPQExpBuffer(&conn->errorMessage,
-						  "ERROR: Cannot determine OID for function lo_creat\n");
+				  "ERROR: Cannot determine OID for function lo_creat\n");
 		free(lobjfuncs);
 		return -1;
 	}
 	if (lobjfuncs->fn_lo_unlink == 0)
 	{
 		printfPQExpBuffer(&conn->errorMessage,
-						  "ERROR: Cannot determine OID for function lo_unlink\n");
+				 "ERROR: Cannot determine OID for function lo_unlink\n");
 		free(lobjfuncs);
 		return -1;
 	}
 	if (lobjfuncs->fn_lo_lseek == 0)
 	{
 		printfPQExpBuffer(&conn->errorMessage,
-						  "ERROR: Cannot determine OID for function lo_lseek\n");
+				  "ERROR: Cannot determine OID for function lo_lseek\n");
 		free(lobjfuncs);
 		return -1;
 	}
 	if (lobjfuncs->fn_lo_tell == 0)
 	{
 		printfPQExpBuffer(&conn->errorMessage,
-						  "ERROR: Cannot determine OID for function lo_tell\n");
+				   "ERROR: Cannot determine OID for function lo_tell\n");
 		free(lobjfuncs);
 		return -1;
 	}
 	if (lobjfuncs->fn_lo_read == 0)
 	{
 		printfPQExpBuffer(&conn->errorMessage,
-						  "ERROR: Cannot determine OID for function loread\n");
+					"ERROR: Cannot determine OID for function loread\n");
 		free(lobjfuncs);
 		return -1;
 	}
 	if (lobjfuncs->fn_lo_write == 0)
 	{
 		printfPQExpBuffer(&conn->errorMessage,
-						  "ERROR: Cannot determine OID for function lowrite\n");
+				   "ERROR: Cannot determine OID for function lowrite\n");
 		free(lobjfuncs);
 		return -1;
 	}
diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c
index e6dd26d8fbb91eb2f61545d6b32998b3f6370ff9..d7f1b6e1549dac24e749047db7a10e0206dbf772 100644
--- a/src/interfaces/libpq/fe-misc.c
+++ b/src/interfaces/libpq/fe-misc.c
@@ -25,7 +25,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.40 2000/04/11 19:00:31 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.41 2000/04/12 17:17:15 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -91,40 +91,41 @@ pqGetc(char *result, PGconn *conn)
 static int
 pqPutBytes(const char *s, size_t nbytes, PGconn *conn)
 {
-	size_t avail = Max(conn->outBufSize - conn->outCount, 0);
+	size_t		avail = Max(conn->outBufSize - conn->outCount, 0);
 
 	/*
-	 * if we are non-blocking and the send queue is too full to buffer this
-	 * request then try to flush some and return an error 
+	 * if we are non-blocking and the send queue is too full to buffer
+	 * this request then try to flush some and return an error
 	 */
 	if (pqIsnonblocking(conn) && nbytes > avail && pqFlush(conn))
 	{
-		/* 
-		 * even if the flush failed we may still have written some
-		 * data, recalculate the size of the send-queue relative
-		 * to the amount we have to send, we may be able to queue it
-		 * afterall even though it's not sent to the database it's
-		 * ok, any routines that check the data coming from the
-		 * database better call pqFlush() anyway.
+
+		/*
+		 * even if the flush failed we may still have written some data,
+		 * recalculate the size of the send-queue relative to the amount
+		 * we have to send, we may be able to queue it afterall even
+		 * though it's not sent to the database it's ok, any routines that
+		 * check the data coming from the database better call pqFlush()
+		 * anyway.
 		 */
 		if (nbytes > Max(conn->outBufSize - conn->outCount, 0))
 		{
 			printfPQExpBuffer(&conn->errorMessage,
-				"pqPutBytes --  pqFlush couldn't flush enough"
-				" data: space available: %d, space needed %d\n",
-				Max(conn->outBufSize - conn->outCount, 0), nbytes);
+						   "pqPutBytes --  pqFlush couldn't flush enough"
+						 " data: space available: %d, space needed %d\n",
+					  Max(conn->outBufSize - conn->outCount, 0), nbytes);
 			return EOF;
 		}
 		/* fixup avail for while loop */
 		avail = Max(conn->outBufSize - conn->outCount, 0);
 	}
 
-	/* 
+	/*
 	 * is the amount of data to be sent is larger than the size of the
 	 * output buffer then we must flush it to make more room.
 	 *
-	 * the code above will make sure the loop conditional is never 
-	 * true for non-blocking connections
+	 * the code above will make sure the loop conditional is never true for
+	 * non-blocking connections
 	 */
 	while (nbytes > avail)
 	{
@@ -208,7 +209,7 @@ pqGetnchar(char *s, size_t len, PGconn *conn)
 	conn->inCursor += len;
 
 	if (conn->Pfdebug)
-		fprintf(conn->Pfdebug, "From backend (%d)> %.*s\n", len, (int)len, s);
+		fprintf(conn->Pfdebug, "From backend (%d)> %.*s\n", len, (int) len, s);
 
 	return 0;
 }
@@ -224,7 +225,7 @@ pqPutnchar(const char *s, size_t len, PGconn *conn)
 		return EOF;
 
 	if (conn->Pfdebug)
-		fprintf(conn->Pfdebug, "To backend> %.*s\n", (int)len, s);
+		fprintf(conn->Pfdebug, "To backend> %.*s\n", (int) len, s);
 
 	return 0;
 }
@@ -324,7 +325,7 @@ pqReadReady(PGconn *conn)
 	FD_SET(conn->sock, &input_mask);
 	timeout.tv_sec = 0;
 	timeout.tv_usec = 0;
- retry:
+retry:
 	if (select(conn->sock + 1, &input_mask, (fd_set *) NULL, (fd_set *) NULL,
 			   &timeout) < 0)
 	{
@@ -333,7 +334,7 @@ pqReadReady(PGconn *conn)
 			goto retry;
 
 		printfPQExpBuffer(&conn->errorMessage,
-						  "pqReadReady() -- select() failed: errno=%d\n%s\n",
+					  "pqReadReady() -- select() failed: errno=%d\n%s\n",
 						  errno, strerror(errno));
 		return -1;
 	}
@@ -358,7 +359,7 @@ pqWriteReady(PGconn *conn)
 	FD_SET(conn->sock, &input_mask);
 	timeout.tv_sec = 0;
 	timeout.tv_usec = 0;
- retry:
+retry:
 	if (select(conn->sock + 1, (fd_set *) NULL, &input_mask, (fd_set *) NULL,
 			   &timeout) < 0)
 	{
@@ -367,7 +368,7 @@ pqWriteReady(PGconn *conn)
 			goto retry;
 
 		printfPQExpBuffer(&conn->errorMessage,
-						  "pqWriteReady() -- select() failed: errno=%d\n%s\n",
+					 "pqWriteReady() -- select() failed: errno=%d\n%s\n",
 						  errno, strerror(errno));
 		return -1;
 	}
@@ -415,7 +416,7 @@ pqReadData(PGconn *conn)
 	 * buffer size.  We enlarge before filling the buffer entirely so as
 	 * to avoid asking the kernel for a partial packet. The magic constant
 	 * here should be large enough for a TCP packet or Unix pipe
-	 * bufferload.  8K is the usual pipe buffer size, so...
+	 * bufferload.	8K is the usual pipe buffer size, so...
 	 */
 	if (conn->inBufSize - conn->inEnd < 8192)
 	{
@@ -432,13 +433,13 @@ pqReadData(PGconn *conn)
 	/* OK, try to read some data */
 tryAgain:
 #ifdef USE_SSL
-	if (conn->ssl) 
-	  nread = SSL_read(conn->ssl, conn->inBuffer + conn->inEnd,
-			   conn->inBufSize - conn->inEnd);
+	if (conn->ssl)
+		nread = SSL_read(conn->ssl, conn->inBuffer + conn->inEnd,
+						 conn->inBufSize - conn->inEnd);
 	else
 #endif
-	  nread = recv(conn->sock, conn->inBuffer + conn->inEnd,
-				 conn->inBufSize - conn->inEnd, 0);
+		nread = recv(conn->sock, conn->inBuffer + conn->inEnd,
+					 conn->inBufSize - conn->inEnd, 0);
 	if (nread < 0)
 	{
 		if (errno == EINTR)
@@ -458,24 +459,26 @@ tryAgain:
 			goto definitelyFailed;
 #endif
 		printfPQExpBuffer(&conn->errorMessage,
-						  "pqReadData() --  read() failed: errno=%d\n%s\n",
+						"pqReadData() --  read() failed: errno=%d\n%s\n",
 						  errno, strerror(errno));
 		return -1;
 	}
 	if (nread > 0)
 	{
 		conn->inEnd += nread;
+
 		/*
 		 * Hack to deal with the fact that some kernels will only give us
-		 * back 1 packet per recv() call, even if we asked for more and there
-		 * is more available.  If it looks like we are reading a long message,
-		 * loop back to recv() again immediately, until we run out of data
-		 * or buffer space.  Without this, the block-and-restart behavior of
-		 * libpq's higher levels leads to O(N^2) performance on long messages.
+		 * back 1 packet per recv() call, even if we asked for more and
+		 * there is more available.  If it looks like we are reading a
+		 * long message, loop back to recv() again immediately, until we
+		 * run out of data or buffer space.  Without this, the
+		 * block-and-restart behavior of libpq's higher levels leads to
+		 * O(N^2) performance on long messages.
 		 *
 		 * Since we left-justified the data above, conn->inEnd gives the
-		 * amount of data already read in the current message.  We consider
-		 * the message "long" once we have acquired 32k ...
+		 * amount of data already read in the current message.	We
+		 * consider the message "long" once we have acquired 32k ...
 		 */
 		if (conn->inEnd > 32768 &&
 			(conn->inBufSize - conn->inEnd) >= 8192)
@@ -516,13 +519,13 @@ tryAgain:
 	 */
 tryAgain2:
 #ifdef USE_SSL
-	if (conn->ssl) 
-	  nread = SSL_read(conn->ssl, conn->inBuffer + conn->inEnd,
-			   conn->inBufSize - conn->inEnd);
+	if (conn->ssl)
+		nread = SSL_read(conn->ssl, conn->inBuffer + conn->inEnd,
+						 conn->inBufSize - conn->inEnd);
 	else
 #endif
-	  nread = recv(conn->sock, conn->inBuffer + conn->inEnd,
-				 conn->inBufSize - conn->inEnd, 0);
+		nread = recv(conn->sock, conn->inBuffer + conn->inEnd,
+					 conn->inBufSize - conn->inEnd, 0);
 	if (nread < 0)
 	{
 		if (errno == EINTR)
@@ -542,7 +545,7 @@ tryAgain2:
 			goto definitelyFailed;
 #endif
 		printfPQExpBuffer(&conn->errorMessage,
-						  "pqReadData() --  read() failed: errno=%d\n%s\n",
+						"pqReadData() --  read() failed: errno=%d\n%s\n",
 						  errno, strerror(errno));
 		return -1;
 	}
@@ -558,9 +561,9 @@ tryAgain2:
 	 */
 definitelyFailed:
 	printfPQExpBuffer(&conn->errorMessage,
-			"pqReadData() -- backend closed the channel unexpectedly.\n"
-			"\tThis probably means the backend terminated abnormally\n"
-			"\tbefore or while processing the request.\n");
+			 "pqReadData() -- backend closed the channel unexpectedly.\n"
+			  "\tThis probably means the backend terminated abnormally\n"
+					  "\tbefore or while processing the request.\n");
 	conn->status = CONNECTION_BAD;		/* No more connection to backend */
 #ifdef WIN32
 	closesocket(conn->sock);
@@ -588,9 +591,9 @@ pqFlush(PGconn *conn)
 		return EOF;
 	}
 
-	/* 
-	 * don't try to send zero data, allows us to use this function
-	 * without too much worry about overhead
+	/*
+	 * don't try to send zero data, allows us to use this function without
+	 * too much worry about overhead
 	 */
 	if (len == 0)
 		return (0);
@@ -601,16 +604,17 @@ pqFlush(PGconn *conn)
 		/* Prevent being SIGPIPEd if backend has closed the connection. */
 #ifndef WIN32
 		pqsigfunc	oldsighandler = pqsignal(SIGPIPE, SIG_IGN);
+
 #endif
 
-		int sent;
+		int			sent;
 
 #ifdef USE_SSL
-		if (conn->ssl) 
-		  sent = SSL_write(conn->ssl, ptr, len);
+		if (conn->ssl)
+			sent = SSL_write(conn->ssl, ptr, len);
 		else
 #endif
-		  sent = send(conn->sock, ptr, len, 0);
+			sent = send(conn->sock, ptr, len, 0);
 
 #ifndef WIN32
 		pqsignal(SIGPIPE, oldsighandler);
@@ -642,22 +646,24 @@ pqFlush(PGconn *conn)
 				case ECONNRESET:
 #endif
 					printfPQExpBuffer(&conn->errorMessage,
-							"pqFlush() -- backend closed the channel unexpectedly.\n"
-							"\tThis probably means the backend terminated abnormally"
-							" before or while processing the request.\n");
+									  "pqFlush() -- backend closed the channel unexpectedly.\n"
+									  "\tThis probably means the backend terminated abnormally"
+						   " before or while processing the request.\n");
+
 					/*
 					 * We used to close the socket here, but that's a bad
 					 * idea since there might be unread data waiting
-					 * (typically, a NOTICE message from the backend telling
-					 * us it's committing hara-kiri...).  Leave the socket
-					 * open until pqReadData finds no more data can be read.
+					 * (typically, a NOTICE message from the backend
+					 * telling us it's committing hara-kiri...).  Leave
+					 * the socket open until pqReadData finds no more data
+					 * can be read.
 					 */
 					return EOF;
 
 				default:
 					printfPQExpBuffer(&conn->errorMessage,
-							"pqFlush() --  couldn't send data: errno=%d\n%s\n",
-							errno, strerror(errno));
+					  "pqFlush() --  couldn't send data: errno=%d\n%s\n",
+									  errno, strerror(errno));
 					/* We don't assume it's a fatal error... */
 					return EOF;
 			}
@@ -672,9 +678,9 @@ pqFlush(PGconn *conn)
 		{
 			/* We didn't send it all, wait till we can send more */
 
-			/* 
-			 * if the socket is in non-blocking mode we may need
-			 * to abort here 
+			/*
+			 * if the socket is in non-blocking mode we may need to abort
+			 * here
 			 */
 #ifdef USE_SSL
 			/* can't do anything for our SSL users yet */
@@ -723,7 +729,7 @@ pqWait(int forRead, int forWrite, PGconn *conn)
 
 	if (forRead || forWrite)
 	{
-	retry:
+retry:
 		FD_ZERO(&input_mask);
 		FD_ZERO(&output_mask);
 		if (forRead)
@@ -736,7 +742,7 @@ pqWait(int forRead, int forWrite, PGconn *conn)
 			if (errno == EINTR)
 				goto retry;
 			printfPQExpBuffer(&conn->errorMessage,
-							  "pqWait() -- select() failed: errno=%d\n%s\n",
+						   "pqWait() -- select() failed: errno=%d\n%s\n",
 							  errno, strerror(errno));
 			return EOF;
 		}
@@ -775,7 +781,7 @@ PQenv2encoding(void)
 	str = getenv("PGCLIENTENCODING");
 	if (str && *str != '\0')
 		encoding = pg_char_to_encoding(str);
-	return(encoding);
+	return (encoding);
 }
 
 #else
@@ -784,8 +790,8 @@ PQenv2encoding(void)
 int
 PQmblen(const unsigned char *s, int encoding)
 {
-    (void)s;
-    (void)encoding;
+	(void) s;
+	(void) encoding;
 	return 1;
 }
 int
diff --git a/src/interfaces/libpq/fe-print.c b/src/interfaces/libpq/fe-print.c
index 840f47e579631ad4b48fff2a174fc5d7c72168bb..fac3494054339d55b0586e76a66dc1959c470277 100644
--- a/src/interfaces/libpq/fe-print.c
+++ b/src/interfaces/libpq/fe-print.c
@@ -10,7 +10,7 @@
  * didn't really belong there.
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.36 2000/03/14 23:59:23 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.37 2000/04/12 17:17:15 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -38,12 +38,14 @@
 
 #ifdef TIOCGWINSZ
 static struct winsize screen_size;
+
 #else
 static struct winsize
 {
 	int			ws_row;
 	int			ws_col;
 }			screen_size;
+
 #endif
 
 
@@ -54,7 +56,7 @@ static void do_field(const PQprintOpt *po, const PGresult *res,
 		 unsigned char *fieldNotNum, int *fieldMax,
 		 const int fieldMaxLen, FILE *fout);
 static char *do_header(FILE *fout, const PQprintOpt *po, const int nFields,
-		  int *fieldMax, const char **fieldNames, unsigned char *fieldNotNum,
+	  int *fieldMax, const char **fieldNames, unsigned char *fieldNotNum,
 		  const int fs_len, const PGresult *res);
 static void output_row(FILE *fout, const PQprintOpt *po, const int nFields, char **fields,
 		   unsigned char *fieldNotNum, int *fieldMax, char *border,
@@ -77,8 +79,8 @@ static void fill(int length, int max, char filler, FILE *fp);
 
 void
 PQprint(FILE *fout,
-	const PGresult *res,
-	const PQprintOpt *po)
+		const PGresult *res,
+		const PQprintOpt *po)
 {
 	int			nFields;
 
@@ -93,7 +95,7 @@ PQprint(FILE *fout,
 		unsigned char *fieldNotNum = NULL;
 		char	   *border = NULL;
 		char	  **fields = NULL;
-		const char	  **fieldNames;
+		const char **fieldNames;
 		int			fieldMaxLen = 0;
 		int			numFieldName;
 		int			fs_len = strlen(po->fieldSep);
@@ -125,7 +127,7 @@ PQprint(FILE *fout,
 		for (j = 0; j < nFields; j++)
 		{
 			int			len;
-			const char	   *s = (j < numFieldName && po->fieldName[j][0]) ?
+			const char *s = (j < numFieldName && po->fieldName[j][0]) ?
 			po->fieldName[j] : PQfname(res, j);
 
 			fieldNames[j] = s;
@@ -216,7 +218,7 @@ PQprint(FILE *fout,
 
 				for (j = 0; j < nFields; j++)
 				{
-					const char	   *s = fieldNames[j];
+					const char *s = fieldNames[j];
 
 					fputs(s, fout);
 					len += strlen(s) + fs_len;
@@ -313,12 +315,12 @@ static void
 do_field(const PQprintOpt *po, const PGresult *res,
 		 const int i, const int j, const int fs_len,
 		 char **fields,
-		 const int nFields, char const **fieldNames,
+		 const int nFields, char const ** fieldNames,
 		 unsigned char *fieldNotNum, int *fieldMax,
 		 const int fieldMaxLen, FILE *fout)
 {
 
-	const char	   *pval,
+	const char *pval,
 			   *p;
 	int			plen;
 	bool		skipit;
@@ -341,7 +343,7 @@ do_field(const PQprintOpt *po, const PGresult *res,
 
 	if (!skipit)
 	{
-		if (po->align && ! fieldNotNum[j])
+		if (po->align && !fieldNotNum[j])
 		{
 			/* Detect whether field contains non-numeric data */
 			char		ch = '0';
@@ -353,21 +355,22 @@ do_field(const PQprintOpt *po, const PGresult *res,
 #endif
 			{
 				ch = *p;
-				if (! ((ch >= '0' && ch <= '9') ||
-					   ch == '.' ||
-					   ch == 'E' ||
-					   ch == 'e' ||
-					   ch == ' ' ||
-					   ch == '-'))
+				if (!((ch >= '0' && ch <= '9') ||
+					  ch == '.' ||
+					  ch == 'E' ||
+					  ch == 'e' ||
+					  ch == ' ' ||
+					  ch == '-'))
 				{
 					fieldNotNum[j] = 1;
 					break;
 				}
 			}
+
 			/*
-			 * Above loop will believe E in first column is numeric; also, we
-			 * insist on a digit in the last column for a numeric.	This test
-			 * is still not bulletproof but it handles most cases.
+			 * Above loop will believe E in first column is numeric; also,
+			 * we insist on a digit in the last column for a numeric. This
+			 * test is still not bulletproof but it handles most cases.
 			 */
 			if (*pval == 'E' || *pval == 'e' ||
 				!(ch >= '0' && ch <= '9'))
@@ -483,7 +486,7 @@ do_header(FILE *fout, const PQprintOpt *po, const int nFields, int *fieldMax,
 		fputs(po->fieldSep, fout);
 	for (j = 0; j < nFields; j++)
 	{
-		const char	   *s = PQfname(res, j);
+		const char *s = PQfname(res, j);
 
 		if (po->html3)
 		{
@@ -562,11 +565,11 @@ output_row(FILE *fout, const PQprintOpt *po, const int nFields, char **fields,
 
 void
 PQdisplayTuples(const PGresult *res,
-		FILE *fp,		/* where to send the output */
-		int fillAlign,	/* pad the fields with spaces */
-		const char *fieldSep,	/* field separator */
-		int printHeader,/* display headers? */
-		int quiet
+				FILE *fp,		/* where to send the output */
+				int fillAlign,	/* pad the fields with spaces */
+				const char *fieldSep,	/* field separator */
+				int printHeader,/* display headers? */
+				int quiet
 )
 {
 #define DEFAULT_FIELD_SEP " "
@@ -597,7 +600,8 @@ PQdisplayTuples(const PGresult *res,
 			fLength[j] = strlen(PQfname(res, j));
 			for (i = 0; i < nTuples; i++)
 			{
-				int flen = PQgetlength(res, i, j);
+				int			flen = PQgetlength(res, i, j);
+
 				if (flen > fLength[j])
 					fLength[j] = flen;
 			}
@@ -653,11 +657,11 @@ PQdisplayTuples(const PGresult *res,
 
 void
 PQprintTuples(const PGresult *res,
-	      FILE *fout,		/* output stream */
-	      int PrintAttNames,/* print attribute names or not */
-	      int TerseOutput,	/* delimiter bars or not? */
-	      int colWidth		/* width of column, if 0, use variable
-					 * width */
+			  FILE *fout,		/* output stream */
+			  int PrintAttNames,/* print attribute names or not */
+			  int TerseOutput,	/* delimiter bars or not? */
+			  int colWidth		/* width of column, if 0, use variable
+								 * width */
 )
 {
 	int			nFields;
@@ -713,7 +717,7 @@ PQprintTuples(const PGresult *res,
 		{
 			for (j = 0; j < nFields; j++)
 			{
-				const char	   *pval = PQgetvalue(res, i, j);
+				const char *pval = PQgetvalue(res, i, j);
 
 				fprintf(fout, formatString,
 						TerseOutput ? "" : "|",
@@ -730,13 +734,13 @@ PQprintTuples(const PGresult *res,
 
 
 /* simply send out max-length number of filler characters to fp */
- 
+
 static void
 fill(int length, int max, char filler, FILE *fp)
 {
-        int                     count;
- 
-        count = max - length;
-        while (count-- >= 0)
-                putc(filler, fp);
+	int			count;
+
+	count = max - length;
+	while (count-- >= 0)
+		putc(filler, fp);
 }
diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h
index 2aba91a6905a6d78988114c847caf8474bfb139d..f82ae6ce17b8a44cb0b0229032ac69aa3426fc7b 100644
--- a/src/interfaces/libpq/libpq-fe.h
+++ b/src/interfaces/libpq/libpq-fe.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: libpq-fe.h,v 1.64 2000/03/30 02:59:14 tgl Exp $
+ * $Id: libpq-fe.h,v 1.65 2000/04/12 17:17:15 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -30,31 +30,37 @@ extern		"C"
 
 	typedef enum
 	{
-		/* Although you may decide to change this list in some way,
-		   values which become unused should never be removed, nor
-           should constants be redefined - that would break 
-           compatibility with existing code.                           */
+
+		/*
+		 * Although you may decide to change this list in some way, values
+		 * which become unused should never be removed, nor should
+		 * constants be redefined - that would break compatibility with
+		 * existing code.
+		 */
 		CONNECTION_OK,
 		CONNECTION_BAD,
 		/* Non-blocking mode only below here */
-		/* The existence of these should never be relied upon - they
-		   should only be used for user feedback or similar purposes.  */
-		CONNECTION_STARTED,     /* Waiting for connection to be made.  */
-		CONNECTION_MADE,        /* Connection OK; waiting to send.     */
-		CONNECTION_AWAITING_RESPONSE,   /* Waiting for a response
-										   from the postmaster.        */
-		CONNECTION_AUTH_OK,             /* Received authentication;
-										   waiting for backend startup. */
-		CONNECTION_SETENV               /* Negotiating environment.    */
+
+		/*
+		 * The existence of these should never be relied upon - they
+		 * should only be used for user feedback or similar purposes.
+		 */
+		CONNECTION_STARTED,		/* Waiting for connection to be made.  */
+		CONNECTION_MADE,		/* Connection OK; waiting to send.	   */
+		CONNECTION_AWAITING_RESPONSE,	/* Waiting for a response from the
+										 * postmaster.		  */
+		CONNECTION_AUTH_OK,		/* Received authentication; waiting for
+								 * backend startup. */
+		CONNECTION_SETENV		/* Negotiating environment.    */
 	} ConnStatusType;
 
 	typedef enum
 	{
 		PGRES_POLLING_FAILED = 0,
-		PGRES_POLLING_READING,     /* These two indicate that one may    */
-		PGRES_POLLING_WRITING,     /* use select before polling again.   */
+		PGRES_POLLING_READING,	/* These two indicate that one may	  */
+		PGRES_POLLING_WRITING,	/* use select before polling again.   */
 		PGRES_POLLING_OK,
-		PGRES_POLLING_ACTIVE       /* Can call poll function immediately.*/
+		PGRES_POLLING_ACTIVE	/* Can call poll function immediately. */
 	} PostgresPollingStatusType;
 
 	typedef enum
@@ -104,17 +110,17 @@ extern		"C"
 	typedef void (*PQnoticeProcessor) (void *arg, const char *message);
 
 /* Print options for PQprint() */
-    typedef char pqbool;
+	typedef char pqbool;
 
 	typedef struct _PQprintOpt
 	{
-		pqbool      header;		/* print output field headings and row
+		pqbool		header;		/* print output field headings and row
 								 * count */
-		pqbool      align;		/* fill align the fields */
-		pqbool      standard;	/* old brain dead format */
-		pqbool      html3;		/* output html tables */
-		pqbool      expanded;	/* expand tables */
-		pqbool      pager;		/* use pager for output if needed */
+		pqbool		align;		/* fill align the fields */
+		pqbool		standard;	/* old brain dead format */
+		pqbool		html3;		/* output html tables */
+		pqbool		expanded;	/* expand tables */
+		pqbool		pager;		/* use pager for output if needed */
 		char	   *fieldSep;	/* field separator */
 		char	   *tableOpt;	/* insert to HTML <table ...> */
 		char	   *caption;	/* HTML <caption> */
@@ -135,14 +141,13 @@ extern		"C"
 		char	   *keyword;	/* The keyword of the option			*/
 		char	   *envvar;		/* Fallback environment variable name	*/
 		char	   *compiled;	/* Fallback compiled in default value	*/
-		char	   *val;		/* Option's current value, or NULL		*/
+		char	   *val;		/* Option's current value, or NULL		 */
 		char	   *label;		/* Label for field in connect dialog	*/
-		char	   *dispchar;	/* Character to display for this field
-								 * in a connect dialog. Values are:
-								 * ""	Display entered value as is
-								 * "*"	Password field - hide value
-								 * "D"	Debug option - don't show by default
-								 */
+		char	   *dispchar;	/* Character to display for this field in
+								 * a connect dialog. Values are: ""
+								 * Display entered value as is "*"
+								 * Password field - hide value "D"	Debug
+								 * option - don't show by default */
 		int			dispsize;	/* Field size in characters for dialog	*/
 	} PQconninfoOption;
 
@@ -176,8 +181,8 @@ extern		"C"
 	extern PGconn *PQconnectdb(const char *conninfo);
 	extern PGconn *PQsetdbLogin(const char *pghost, const char *pgport,
 								const char *pgoptions, const char *pgtty,
-								const char *dbName,
-								const char *login, const char *pwd);
+											const char *dbName,
+									 const char *login, const char *pwd);
 #define PQsetdb(M_PGHOST,M_PGPORT,M_PGOPT,M_PGTTY,M_DBNAME)  \
 	PQsetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, NULL, NULL)
 
@@ -195,7 +200,7 @@ extern		"C"
 	 * parameters
 	 */
 	/* Asynchronous (non-blocking) */
-	extern int PQresetStart(PGconn *conn);
+	extern int	PQresetStart(PGconn *conn);
 	extern PostgresPollingStatusType PQresetPoll(PGconn *conn);
 	/* Synchronous (blocking) */
 	extern void PQreset(PGconn *conn);
@@ -258,12 +263,12 @@ extern		"C"
 	 * use
 	 */
 	extern PGresult *PQfn(PGconn *conn,
-			      int fnid,
-			      int *result_buf,
-			      int *result_len,
-			      int result_is_int,
-			      const PQArgBlock *args,
-			      int nargs);
+									  int fnid,
+									  int *result_buf,
+									  int *result_len,
+									  int result_is_int,
+									  const PQArgBlock *args,
+									  int nargs);
 
 	/* Accessor functions for PGresult objects */
 	extern ExecStatusType PQresultStatus(const PGresult *res);
@@ -278,8 +283,8 @@ extern		"C"
 	extern int	PQfsize(const PGresult *res, int field_num);
 	extern int	PQfmod(const PGresult *res, int field_num);
 	extern char *PQcmdStatus(PGresult *res);
-    extern char *PQoidStatus(const PGresult *res); /* old and ugly */
-    extern Oid PQoidValue(const PGresult *res); /* new and improved */
+	extern char *PQoidStatus(const PGresult *res);		/* old and ugly */
+	extern Oid	PQoidValue(const PGresult *res);		/* new and improved */
 	extern char *PQcmdTuples(PGresult *res);
 	extern char *PQgetvalue(const PGresult *res, int tup_num, int field_num);
 	extern int	PQgetlength(const PGresult *res, int tup_num, int field_num);
@@ -298,25 +303,27 @@ extern		"C"
 /* === in fe-print.c === */
 
 	extern void PQprint(FILE *fout,		/* output stream */
-			    const PGresult *res,
-			    const PQprintOpt *ps);	/* option structure */
-
-    /*
-     * really old printing routines
-     */
-    extern void PQdisplayTuples(const PGresult *res,
-                                FILE *fp,   /* where to send the output */
-                                int fillAlign,      /* pad the fields with spaces */
-                                const char *fieldSep,   /* field separator */
-                                int printHeader,    /* display headers? */
-                                int quiet);
- 
-    extern void PQprintTuples(const PGresult *res,
-                              FILE *fout,   /* output stream */
-                              int printAttName,     /* print attribute names */
-                              int terseOutput,      /* delimiter bars */
-                              int width);   /* width of column, if
-                                             * 0, use variable width */
+									const PGresult *res,
+									const PQprintOpt *ps);		/* option structure */
+
+	/*
+	 * really old printing routines
+	 */
+	extern void PQdisplayTuples(const PGresult *res,
+											FILE *fp,	/* where to send the
+														 * output */
+											int fillAlign,		/* pad the fields with
+																 * spaces */
+											const char *fieldSep,		/* field separator */
+											int printHeader,	/* display headers? */
+											int quiet);
+
+	extern void PQprintTuples(const PGresult *res,
+										  FILE *fout,	/* output stream */
+										  int printAttName,		/* print attribute names */
+										  int terseOutput,		/* delimiter bars */
+										  int width);	/* width of column, if
+														 * 0, use variable width */
 
 
 /* === in fe-lobj.c === */
@@ -339,10 +346,11 @@ extern		"C"
 	extern int	PQmblen(const unsigned char *s, int encoding);
 
 	/* Get encoding id from environment variable PGCLIENTENCODING */
-	extern int PQenv2encoding(void);
+	extern int	PQenv2encoding(void);
 
 #ifdef __cplusplus
 }
+
 #endif
 
 #endif	 /* LIBPQ_FE_H */
diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h
index 823abf20a335d89f50b9f4ecbdd5be5464d863a2..fbad5fc7a81d780ea3bda8378ab4ed6f58f6dfef 100644
--- a/src/interfaces/libpq/libpq-int.h
+++ b/src/interfaces/libpq/libpq-int.h
@@ -12,7 +12,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: libpq-int.h,v 1.22 2000/03/24 01:39:55 tgl Exp $
+ * $Id: libpq-int.h,v 1.23 2000/04/12 17:17:15 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -81,7 +81,7 @@ typedef struct pgresAttDesc
 	Oid			typid;			/* type id */
 	int			typlen;			/* type size */
 	int			atttypmod;		/* type-specific modifier info */
-} PGresAttDesc;
+}			PGresAttDesc;
 
 /* Data for a single attribute of a single tuple */
 
@@ -106,7 +106,7 @@ typedef struct pgresAttValue
 	int			len;			/* length in bytes of the value */
 	char	   *value;			/* actual value, plus terminating zero
 								 * byte */
-} PGresAttValue;
+}			PGresAttValue;
 
 struct pg_result
 {
@@ -121,12 +121,13 @@ struct pg_result
 												 * last query */
 	int			binary;			/* binary tuple values if binary == 1,
 								 * otherwise ASCII */
+
 	/*
-	 * The conn link in PGresult is no longer used by any libpq code.
-	 * It should be removed entirely, because it could be a dangling link
-	 * (the application could keep the PGresult around longer than it keeps
-	 * the PGconn!)  But there may be apps out there that depend on it,
-	 * so we will leave it here at least for a release or so.
+	 * The conn link in PGresult is no longer used by any libpq code. It
+	 * should be removed entirely, because it could be a dangling link
+	 * (the application could keep the PGresult around longer than it
+	 * keeps the PGconn!)  But there may be apps out there that depend on
+	 * it, so we will leave it here at least for a release or so.
 	 */
 	PGconn	   *xconn;			/* connection we did the query on, if any */
 
@@ -134,9 +135,9 @@ struct pg_result
 	 * These fields are copied from the originating PGconn, so that
 	 * operations on the PGresult don't have to reference the PGconn.
 	 */
-	PQnoticeProcessor noticeHook; /* notice/error message processor */
+	PQnoticeProcessor noticeHook;		/* notice/error message processor */
 	void	   *noticeArg;
-	int			client_encoding; /* encoding id */
+	int			client_encoding;/* encoding id */
 
 
 	char	   *errMsg;			/* error message, or NULL if no error */
@@ -162,7 +163,7 @@ typedef enum
 	PGASYNC_READY,				/* result ready for PQgetResult */
 	PGASYNC_COPY_IN,			/* Copy In data transfer in progress */
 	PGASYNC_COPY_OUT			/* Copy Out data transfer in progress */
-} PGAsyncStatusType;
+}			PGAsyncStatusType;
 
 /* PGSetenvStatusType defines the state of the PQSetenv state machine */
 typedef enum
@@ -170,10 +171,10 @@ typedef enum
 	SETENV_STATE_OPTION_SEND,	/* About to send an Environment Option */
 	SETENV_STATE_OPTION_WAIT,	/* Waiting for above send to complete  */
 	/* these next two are only used in MULTIBYTE mode */
-	SETENV_STATE_ENCODINGS_SEND, /* About to send an "encodings" query */
-	SETENV_STATE_ENCODINGS_WAIT, /* Waiting for query to complete      */
+	SETENV_STATE_ENCODINGS_SEND,/* About to send an "encodings" query */
+	SETENV_STATE_ENCODINGS_WAIT,/* Waiting for query to complete	  */
 	SETENV_STATE_IDLE
-} PGSetenvStatusType;
+}			PGSetenvStatusType;
 
 /* large-object-access data ... allocated only if large-object code is used. */
 typedef struct pgLobjfuncs
@@ -186,7 +187,7 @@ typedef struct pgLobjfuncs
 	Oid			fn_lo_tell;		/* OID of backend function lo_tell		*/
 	Oid			fn_lo_read;		/* OID of backend function LOread		*/
 	Oid			fn_lo_write;	/* OID of backend function LOwrite		*/
-} PGlobjfuncs;
+}			PGlobjfuncs;
 
 /* PGconn stores all the state data associated with a single connection
  * to a backend.
@@ -197,8 +198,8 @@ struct pg_conn
 	char	   *pghost;			/* the machine on which the server is
 								 * running */
 	char	   *pghostaddr;		/* the IPv4 address of the machine on
-								 * which the server is running, in
-								 * IPv4 numbers-and-dots notation. Takes
+								 * which the server is running, in IPv4
+								 * numbers-and-dots notation. Takes
 								 * precedence over above. */
 	char	   *pgport;			/* the server's communication port */
 	char	   *pgtty;			/* tty on which the backend messages is
@@ -243,8 +244,8 @@ struct pg_conn
 	int			inEnd;			/* offset to first position after avail
 								 * data */
 
-	int			nonblocking;	/* whether this connection is using a blocking
-								 * socket to the backend or not */
+	int			nonblocking;	/* whether this connection is using a
+								 * blocking socket to the backend or not */
 
 	/* Buffer for data not yet sent to backend */
 	char	   *outBuffer;		/* currently allocated buffer */
@@ -256,21 +257,21 @@ struct pg_conn
 	PGresAttValue *curTuple;	/* tuple currently being read */
 
 	/* Status for sending environment info.  Used during PQSetenv only. */
-	PGSetenvStatusType	setenv_state;
+	PGSetenvStatusType setenv_state;
 	const struct EnvironmentOptions *next_eo;
 
 #ifdef USE_SSL
-	bool allow_ssl_try;			/* Allowed to try SSL negotiation */
-	SSL *ssl;					/* SSL status, if have SSL connection */
+	bool		allow_ssl_try;	/* Allowed to try SSL negotiation */
+	SSL		   *ssl;			/* SSL status, if have SSL connection */
 #endif
 
 	/* Buffer for current error message */
-	PQExpBufferData	errorMessage;	/* expansible string */
+	PQExpBufferData errorMessage;		/* expansible string */
 
 	/* Buffer for receiving various parts of messages */
-	PQExpBufferData	workBuffer;	/* expansible string */
+	PQExpBufferData workBuffer; /* expansible string */
 
-	int client_encoding;		/* encoding id */
+	int			client_encoding;/* encoding id */
 };
 
 /* String descriptions of the ExecStatusTypes.
@@ -338,7 +339,7 @@ extern char *sys_errlist[];
 #endif	 /* sunos4 */
 #endif	 /* !strerror */
 
-/* 
+/*
  * this is so that we can check is a connection is non-blocking internally
  * without the overhead of a function call
  */
diff --git a/src/interfaces/libpq/pqexpbuffer.c b/src/interfaces/libpq/pqexpbuffer.c
index f70d9139c2ed7add9f5600492130a820f2f70a0a..623ec8306e565e4cc9fcd5940a85778fc930909a 100644
--- a/src/interfaces/libpq/pqexpbuffer.c
+++ b/src/interfaces/libpq/pqexpbuffer.c
@@ -17,7 +17,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.5 2000/02/07 23:10:11 petere Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.6 2000/04/12 17:17:15 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -39,7 +39,7 @@
 PQExpBuffer
 createPQExpBuffer(void)
 {
-	PQExpBuffer	res;
+	PQExpBuffer res;
 
 	res = (PQExpBuffer) malloc(sizeof(PQExpBufferData));
 	if (res != NULL)
@@ -156,7 +156,7 @@ enlargePQExpBuffer(PQExpBuffer str, size_t needed)
 /*------------------------
  * printfPQExpBuffer
  * Format text data under the control of fmt (an sprintf-like format string)
- * and insert it into str.  More space is allocated to str if necessary.
+ * and insert it into str.	More space is allocated to str if necessary.
  * This is a convenience routine that does the same thing as
  * resetPQExpBuffer() followed by appendPQExpBuffer().
  */
@@ -165,7 +165,7 @@ printfPQExpBuffer(PQExpBuffer str, const char *fmt,...)
 {
 	va_list		args;
 	size_t		avail;
-    int         nprinted;
+	int			nprinted;
 
 	resetPQExpBuffer(str);
 
@@ -184,12 +184,13 @@ printfPQExpBuffer(PQExpBuffer str, const char *fmt,...)
 			nprinted = vsnprintf(str->data + str->len, avail,
 								 fmt, args);
 			va_end(args);
+
 			/*
 			 * Note: some versions of vsnprintf return the number of chars
-			 * actually stored, but at least one returns -1 on failure.
-			 * Be conservative about believing whether the print worked.
+			 * actually stored, but at least one returns -1 on failure. Be
+			 * conservative about believing whether the print worked.
 			 */
-			if (nprinted >= 0 && nprinted < avail-1)
+			if (nprinted >= 0 && nprinted < avail - 1)
 			{
 				/* Success.  Note nprinted does not include trailing null. */
 				str->len += nprinted;
@@ -197,7 +198,7 @@ printfPQExpBuffer(PQExpBuffer str, const char *fmt,...)
 			}
 		}
 		/* Double the buffer size and try again. */
-		if (! enlargePQExpBuffer(str, str->maxlen))
+		if (!enlargePQExpBuffer(str, str->maxlen))
 			return;				/* oops, out of memory */
 	}
 }
@@ -215,7 +216,7 @@ appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
 {
 	va_list		args;
 	size_t		avail;
-    int			nprinted;
+	int			nprinted;
 
 	for (;;)
 	{
@@ -232,12 +233,13 @@ appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
 			nprinted = vsnprintf(str->data + str->len, avail,
 								 fmt, args);
 			va_end(args);
+
 			/*
 			 * Note: some versions of vsnprintf return the number of chars
-			 * actually stored, but at least one returns -1 on failure.
-			 * Be conservative about believing whether the print worked.
+			 * actually stored, but at least one returns -1 on failure. Be
+			 * conservative about believing whether the print worked.
 			 */
-			if (nprinted >= 0 && nprinted < avail-1)
+			if (nprinted >= 0 && nprinted < avail - 1)
 			{
 				/* Success.  Note nprinted does not include trailing null. */
 				str->len += nprinted;
@@ -245,7 +247,7 @@ appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
 			}
 		}
 		/* Double the buffer size and try again. */
-		if (! enlargePQExpBuffer(str, str->maxlen))
+		if (!enlargePQExpBuffer(str, str->maxlen))
 			return;				/* oops, out of memory */
 	}
 }
@@ -270,7 +272,7 @@ void
 appendPQExpBufferChar(PQExpBuffer str, char ch)
 {
 	/* Make more room if needed */
-	if (! enlargePQExpBuffer(str, 1))
+	if (!enlargePQExpBuffer(str, 1))
 		return;
 
 	/* OK, append the character */
@@ -289,7 +291,7 @@ void
 appendBinaryPQExpBuffer(PQExpBuffer str, const char *data, size_t datalen)
 {
 	/* Make more room if needed */
-	if (! enlargePQExpBuffer(str, datalen))
+	if (!enlargePQExpBuffer(str, datalen))
 		return;
 
 	/* OK, append the data */
diff --git a/src/interfaces/libpq/pqexpbuffer.h b/src/interfaces/libpq/pqexpbuffer.h
index 014254465aa78496850b96db5dd4a8d3fae74c1c..ac50f8ea9a666499d97138d5f2c818270d17288d 100644
--- a/src/interfaces/libpq/pqexpbuffer.h
+++ b/src/interfaces/libpq/pqexpbuffer.h
@@ -18,7 +18,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pqexpbuffer.h,v 1.4 2000/02/07 23:10:11 petere Exp $
+ * $Id: pqexpbuffer.h,v 1.5 2000/04/12 17:17:15 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -52,7 +52,7 @@ typedef PQExpBufferData *PQExpBuffer;
  * be returned by PQrequestCancel() or any routine in fe-auth.c.
  *------------------------
  */
-#define INITIAL_EXPBUFFER_SIZE  256
+#define INITIAL_EXPBUFFER_SIZE	256
 
 /*------------------------
  * There are two ways to create a PQExpBuffer object initially:
@@ -113,12 +113,12 @@ extern void resetPQExpBuffer(PQExpBuffer str);
  *
  * Returns 1 if OK, 0 if failed to enlarge buffer.
  */
-extern int enlargePQExpBuffer(PQExpBuffer str, size_t needed);
+extern int	enlargePQExpBuffer(PQExpBuffer str, size_t needed);
 
 /*------------------------
  * printfPQExpBuffer
  * Format text data under the control of fmt (an sprintf-like format string)
- * and insert it into str.  More space is allocated to str if necessary.
+ * and insert it into str.	More space is allocated to str if necessary.
  * This is a convenience routine that does the same thing as
  * resetPQExpBuffer() followed by appendPQExpBuffer().
  */
@@ -153,6 +153,6 @@ extern void appendPQExpBufferChar(PQExpBuffer str, char ch);
  * if necessary.
  */
 extern void appendBinaryPQExpBuffer(PQExpBuffer str,
-					   const char *data, size_t datalen);
+						const char *data, size_t datalen);
 
 #endif	 /* PQEXPBUFFER_H */
diff --git a/src/interfaces/libpq/win32.h b/src/interfaces/libpq/win32.h
index 3b57134f02d38f65bb4812d310c06a0ac291c94d..126dd152c0603e447b8425a14d38e1a3a8d66940 100644
--- a/src/interfaces/libpq/win32.h
+++ b/src/interfaces/libpq/win32.h
@@ -32,4 +32,3 @@
 
 #define DEF_PGPORT "5432"
 #define MAXIMUM_ALIGNOF 4
-
diff --git a/src/pl/plperl/eloglvl.c b/src/pl/plperl/eloglvl.c
index 0427da439f342732817176763ba5407fad2eaedc..f84232b9fe88ef9caac04fd2e19235636ca33214 100644
--- a/src/pl/plperl/eloglvl.c
+++ b/src/pl/plperl/eloglvl.c
@@ -8,18 +8,26 @@
 
 #include "eloglvl.h"
 
-int elog_DEBUG(void) {
+int
+elog_DEBUG(void)
+{
 	return DEBUG;
 }
 
-int elog_ERROR(void) {
+int
+elog_ERROR(void)
+{
 	return ERROR;
 }
 
-int elog_NOIND(void) {
+int
+elog_NOIND(void)
+{
 	return NOIND;
 }
 
-int elog_NOTICE(void) {
+int
+elog_NOTICE(void)
+{
 	return NOTICE;
 }
diff --git a/src/pl/plperl/eloglvl.h b/src/pl/plperl/eloglvl.h
index 42272920785ca11a8091f7af0a7ffc88c9459e47..e79f5530c12bf1aad325372fb98f0211f0d30c1e 100644
--- a/src/pl/plperl/eloglvl.h
+++ b/src/pl/plperl/eloglvl.h
@@ -1,8 +1,11 @@
 
-int elog_DEBUG(void) ;
+int
+			elog_DEBUG(void);
 
-int elog_ERROR(void) ;
+int
+			elog_ERROR(void);
 
-int elog_NOIND(void) ;
+int
+			elog_NOIND(void);
 
-int elog_NOTICE(void);
+int			elog_NOTICE(void);
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index 49b5a9f1d6593e5e0d112b877a25df5b5e1b4f29..c66c4dd3779ae83c7ba9326360e2ce3823bca3f8 100644
--- a/src/pl/plperl/plperl.c
+++ b/src/pl/plperl/plperl.c
@@ -4,7 +4,7 @@
  * IDENTIFICATION
  *
  *	  This software is copyrighted by Mark Hollomon
- *   but is shameless cribbed from pltcl.c by Jan Weick.
+ *	 but is shameless cribbed from pltcl.c by Jan Weick.
  *
  *	  The author hereby grants permission  to  use,  copy,	modify,
  *	  distribute,  and	license this software and its documentation
@@ -90,7 +90,7 @@ typedef struct plperl_proc_desc
 	Oid			arg_out_elem[FUNC_MAX_ARGS];
 	int			arg_out_len[FUNC_MAX_ARGS];
 	int			arg_is_rel[FUNC_MAX_ARGS];
-	SV*			reference;
+	SV		   *reference;
 }			plperl_proc_desc;
 
 
@@ -117,9 +117,11 @@ static int	plperl_firstcall = 1;
 static int	plperl_call_level = 0;
 static int	plperl_restart_in_progress = 0;
 static PerlInterpreter *plperl_safe_interp = NULL;
-static HV *plperl_proc_hash = NULL;
+static HV  *plperl_proc_hash = NULL;
+
 #if REALLYHAVEITONTHEBALL
 static Tcl_HashTable *plperl_query_hash = NULL;
+
 #endif
 
 /**********************************************************************
@@ -129,31 +131,32 @@ static void plperl_init_all(void);
 static void plperl_init_safe_interp(void);
 
 Datum plperl_call_handler(FmgrInfo *proinfo,
-						 FmgrValues *proargs, bool *isNull);
+					FmgrValues *proargs, bool *isNull);
 
 static Datum plperl_func_handler(FmgrInfo *proinfo,
-				   FmgrValues *proargs, bool *isNull);
+					FmgrValues *proargs, bool *isNull);
 
-static SV* plperl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc);
+static SV  *plperl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc);
 static void plperl_init_shared_libs(void);
 
 #ifdef REALLYHAVEITONTHEBALL
 static HeapTuple plperl_trigger_handler(FmgrInfo *proinfo);
 
 static int plperl_elog(ClientData cdata, Tcl_Interp *interp,
-		   int argc, char *argv[]);
-static int plperl_quote(ClientData cdata, Tcl_Interp *interp,
 			int argc, char *argv[]);
+static int plperl_quote(ClientData cdata, Tcl_Interp *interp,
+			 int argc, char *argv[]);
 
 static int plperl_SPI_exec(ClientData cdata, Tcl_Interp *interp,
-			   int argc, char *argv[]);
+				int argc, char *argv[]);
 static int plperl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
-				  int argc, char *argv[]);
+				   int argc, char *argv[]);
 static int plperl_SPI_execp(ClientData cdata, Tcl_Interp *interp,
-				int argc, char *argv[]);
+				 int argc, char *argv[]);
 
 static void plperl_set_tuple_values(Tcl_Interp *interp, char *arrayname,
-					   int tupno, HeapTuple tuple, TupleDesc tupdesc);
+						int tupno, HeapTuple tuple, TupleDesc tupdesc);
+
 #endif
 
 
@@ -187,18 +190,17 @@ plperl_init_all(void)
 	if (plperl_proc_hash != NULL)
 	{
 		hv_undef(plperl_proc_hash);
-		SvREFCNT_dec((SV*) plperl_proc_hash);
+		SvREFCNT_dec((SV *) plperl_proc_hash);
 		plperl_proc_hash = NULL;
 	}
 
 	/************************************************************
 	 * Free the prepared query hash table
 	 ************************************************************/
+
 	/*
-	if (plperl_query_hash != NULL)
-	{
-	}
-	*/
+	 * if (plperl_query_hash != NULL) { }
+	 */
 
 	/************************************************************
 	 * Now recreate a new safe interpreter
@@ -217,7 +219,7 @@ static void
 plperl_init_safe_interp(void)
 {
 
-	char *embedding[] = { "", "-e", "use DynaLoader; require Safe; SPI::bootstrap()", "0" };
+	char	   *embedding[] = {"", "-e", "use DynaLoader; require Safe; SPI::bootstrap()", "0"};
 
 	plperl_safe_interp = perl_alloc();
 	if (!plperl_safe_interp)
@@ -227,12 +229,12 @@ plperl_init_safe_interp(void)
 	perl_parse(plperl_safe_interp, plperl_init_shared_libs, 3, embedding, NULL);
 	perl_run(plperl_safe_interp);
 
-	
+
 
 	/************************************************************
 	 * Initialize the proc and query hash tables
 	 ************************* ***********************************/
-	 plperl_proc_hash = newHV();
+	plperl_proc_hash = newHV();
 
 }
 
@@ -249,8 +251,8 @@ plperl_init_safe_interp(void)
 /* keep non-static */
 Datum
 plperl_call_handler(FmgrInfo *proinfo,
-				   FmgrValues *proargs,
-				   bool *isNull)
+					FmgrValues *proargs,
+					bool *isNull)
 {
 	Datum		retval;
 
@@ -276,11 +278,13 @@ plperl_call_handler(FmgrInfo *proinfo,
 	 ************************************************************/
 	if (CurrentTriggerData == NULL)
 		retval = plperl_func_handler(proinfo, proargs, isNull);
-	else {
+	else
+	{
 		elog(ERROR, "plperl: can't use perl in triggers yet.");
+
 		/*
-		retval = (Datum) plperl_trigger_handler(proinfo);
-		*/
+		 * retval = (Datum) plperl_trigger_handler(proinfo);
+		 */
 		/* make the compiler happy */
 		retval = (Datum) 0;
 	}
@@ -293,15 +297,16 @@ plperl_call_handler(FmgrInfo *proinfo,
 
 /**********************************************************************
  * plperl_create_sub()		- calls the perl interpreter to
- * 		create the anonymous subroutine whose text is in the SV.
- * 		Returns the SV containing the RV to the closure.
+ *		create the anonymous subroutine whose text is in the SV.
+ *		Returns the SV containing the RV to the closure.
  **********************************************************************/
 static
 SV *
-plperl_create_sub(SV *s) {
+plperl_create_sub(SV * s)
+{
 	dSP;
 
-	SV* subref = NULL;
+	SV		   *subref = NULL;
 
 	ENTER;
 	SAVETMPS;
@@ -309,7 +314,8 @@ plperl_create_sub(SV *s) {
 	perl_eval_sv(s, G_SCALAR | G_EVAL | G_KEEPERR);
 	SPAGAIN;
 
-	if (SvTRUE(GvSV(errgv))) {
+	if (SvTRUE(GvSV(errgv)))
+	{
 		POPs;
 		PUTBACK;
 		FREETMPS;
@@ -318,15 +324,17 @@ plperl_create_sub(SV *s) {
 	}
 
 	/*
-	 * need to make a deep copy of the return.
-	 * it comes off the stack as a temporary.
+	 * need to make a deep copy of the return. it comes off the stack as a
+	 * temporary.
 	 */
 	subref = newSVsv(POPs);
 
-	if (!SvROK(subref)) {
+	if (!SvROK(subref))
+	{
 		PUTBACK;
 		FREETMPS;
 		LEAVE;
+
 		/*
 		 * subref is our responsibility because it is not mortal
 		 */
@@ -341,22 +349,23 @@ plperl_create_sub(SV *s) {
 }
 
 /**********************************************************************
- * plperl_init_shared_libs()		- 
+ * plperl_init_shared_libs()		-
  *
  * We cannot use the DynaLoader directly to get at the Opcode
  * module (used by Safe.pm). So, we link Opcode into ourselves
  * and do the initialization behind perl's back.
- *			
+ *
  **********************************************************************/
 
-extern void boot_DynaLoader _((CV* cv));
-extern void boot_Opcode _((CV* cv));
-extern void boot_SPI _((CV* cv));
+extern void boot_DynaLoader _((CV * cv));
+extern void boot_Opcode _((CV * cv));
+extern void boot_SPI _((CV * cv));
 
 static void
 plperl_init_shared_libs(void)
 {
-	char *file = __FILE__;
+	char	   *file = __FILE__;
+
 	newXS("DynaLoader::bootstrap", boot_DynaLoader, file);
 	newXS("Opcode::bootstrap", boot_Opcode, file);
 	newXS("SPI::bootstrap", boot_SPI, file);
@@ -367,35 +376,40 @@ plperl_init_shared_libs(void)
  *			stored in the prodesc structure. massages the input parms properly
  **********************************************************************/
 static
-SV*
-plperl_call_perl_func (plperl_proc_desc * desc, FmgrValues *pargs)
+SV *
+plperl_call_perl_func(plperl_proc_desc * desc, FmgrValues *pargs)
 {
 	dSP;
 
-	SV* retval;
-	int i;
-	int count;
+	SV		   *retval;
+	int			i;
+	int			count;
 
 
 	ENTER;
 	SAVETMPS;
 
 	PUSHMARK(sp);
-	for (i = 0; i < desc->nargs; i++) {
-		if (desc->arg_is_rel[i]) {
+	for (i = 0; i < desc->nargs; i++)
+	{
+		if (desc->arg_is_rel[i])
+		{
+
 			/*
-			 * plperl_build_tuple_argument better return a
-			 * mortal SV.
-			*/
-			SV* hashref =  plperl_build_tuple_argument(
-				 ((TupleTableSlot *) (pargs->data[i]))->val,
-				 ((TupleTableSlot *) (pargs->data[i]))->ttc_tupleDescriptor);
+			 * plperl_build_tuple_argument better return a mortal SV.
+			 */
+			SV		   *hashref = plperl_build_tuple_argument(
+							  ((TupleTableSlot *) (pargs->data[i]))->val,
+			 ((TupleTableSlot *) (pargs->data[i]))->ttc_tupleDescriptor);
+
 			XPUSHs(hashref);
-		} else {
-			char *tmp = (*fmgr_faddr(&(desc->arg_out_func[i])))
-							(pargs->data[i],
-							 desc->arg_out_elem[i],
-							 desc->arg_out_len[i]);
+		}
+		else
+		{
+			char	   *tmp = (*fmgr_faddr(&(desc->arg_out_func[i])))
+			(pargs->data[i],
+			 desc->arg_out_elem[i],
+			 desc->arg_out_len[i]);
 
 			XPUSHs(sv_2mortal(newSVpv(tmp, 0)));
 			pfree(tmp);
@@ -406,17 +420,19 @@ plperl_call_perl_func (plperl_proc_desc * desc, FmgrValues *pargs)
 
 	SPAGAIN;
 
-	if (count !=1) {
-		PUTBACK ;
-		FREETMPS ;
+	if (count != 1)
+	{
+		PUTBACK;
+		FREETMPS;
 		LEAVE;
 		elog(ERROR, "plperl : didn't get a return item from function");
 	}
 
-	if (SvTRUE(GvSV(errgv))) {
+	if (SvTRUE(GvSV(errgv)))
+	{
 		POPs;
-		PUTBACK ;
-		FREETMPS ;
+		PUTBACK;
+		FREETMPS;
 		LEAVE;
 		elog(ERROR, "plperl : error from function : %s", SvPV(GvSV(errgv), na));
 	}
@@ -424,9 +440,9 @@ plperl_call_perl_func (plperl_proc_desc * desc, FmgrValues *pargs)
 	retval = newSVsv(POPs);
 
 
-	PUTBACK ;
-	FREETMPS ;
-	LEAVE ;
+	PUTBACK;
+	FREETMPS;
+	LEAVE;
 
 	return retval;
 
@@ -438,16 +454,16 @@ plperl_call_perl_func (plperl_proc_desc * desc, FmgrValues *pargs)
  **********************************************************************/
 static Datum
 plperl_func_handler(FmgrInfo *proinfo,
-				   FmgrValues *proargs,
-				   bool *isNull)
+					FmgrValues *proargs,
+					bool *isNull)
 {
 	int			i;
 	char		internal_proname[512];
-	int		proname_len;
+	int			proname_len;
 	char	   *stroid;
 	plperl_proc_desc *prodesc;
-	SV*		perlret;
-	Datum    retval;
+	SV		   *perlret;
+	Datum		retval;
 	sigjmp_buf	save_restart;
 
 	/************************************************************
@@ -462,7 +478,7 @@ plperl_func_handler(FmgrInfo *proinfo,
 	/************************************************************
 	 * Lookup the internal proc name in the hashtable
 	 ************************************************************/
-	if (! hv_exists(plperl_proc_hash, internal_proname, proname_len))
+	if (!hv_exists(plperl_proc_hash, internal_proname, proname_len))
 	{
 		/************************************************************
 		 * If we haven't found it in the hashtable, we analyze
@@ -476,7 +492,7 @@ plperl_func_handler(FmgrInfo *proinfo,
 		HeapTuple	typeTup;
 		Form_pg_proc procStruct;
 		Form_pg_type typeStruct;
-		SV * proc_internal_def;
+		SV		   *proc_internal_def;
 		char		proc_internal_args[4096];
 		char	   *proc_source;
 
@@ -564,16 +580,17 @@ plperl_func_handler(FmgrInfo *proinfo,
 		 *
 		 ************************************************************/
 		proc_source = textout(&(procStruct->prosrc));
+
 		/*
-		 * the string has been split for readbility.
-		 * please don't put commas between them. Hope everyone is ANSI
+		 * the string has been split for readbility. please don't put
+		 * commas between them. Hope everyone is ANSI
 		 */
 		proc_internal_def = newSVpvf(
-			"$::x = new Safe;" 
-			"$::x->permit_only(':default');"
-			"$::x->share(qw[&elog &DEBUG &NOTICE &NOIND &ERROR]);"
-			"use strict;"
-			"return $::x->reval( q[ sub { %s } ]);", proc_source);
+									 "$::x = new Safe;"
+									 "$::x->permit_only(':default');"
+				   "$::x->share(qw[&elog &DEBUG &NOTICE &NOIND &ERROR]);"
+									 "use strict;"
+				   "return $::x->reval( q[ sub { %s } ]);", proc_source);
 
 		pfree(proc_source);
 
@@ -592,8 +609,8 @@ plperl_func_handler(FmgrInfo *proinfo,
 		/************************************************************
 		 * Add the proc description block to the hashtable
 		 ************************************************************/
-		 hv_store(plperl_proc_hash, internal_proname, proname_len, 
-			newSViv((IV)prodesc), 0);
+		hv_store(plperl_proc_hash, internal_proname, proname_len,
+				 newSViv((IV) prodesc), 0);
 	}
 	else
 	{
@@ -601,7 +618,7 @@ plperl_func_handler(FmgrInfo *proinfo,
 		 * Found the proc description block in the hashtable
 		 ************************************************************/
 		prodesc = (plperl_proc_desc *) SvIV(*hv_fetch(plperl_proc_hash,
-					internal_proname, proname_len, 0));
+									  internal_proname, proname_len, 0));
 	}
 
 
@@ -632,17 +649,18 @@ plperl_func_handler(FmgrInfo *proinfo,
 		elog(ERROR, "plperl: SPI_finish() failed");
 
 	retval = (Datum) (*fmgr_faddr(&prodesc->result_in_func))
-			(SvPV(perlret, na),
-			 prodesc->result_in_elem,
-		    prodesc->result_in_len);
+		(SvPV(perlret, na),
+		 prodesc->result_in_elem,
+		 prodesc->result_in_len);
 
 	SvREFCNT_dec(perlret);
 
 	memcpy(&Warn_restart, &save_restart, sizeof(Warn_restart));
-	if (plperl_restart_in_progress) {
-		if (--plperl_call_level == 0 )
+	if (plperl_restart_in_progress)
+	{
+		if (--plperl_call_level == 0)
 			plperl_restart_in_progress = 0;
-		siglongjmp(Warn_restart,1);
+		siglongjmp(Warn_restart, 1);
 	}
 
 	return retval;
@@ -651,7 +669,7 @@ plperl_func_handler(FmgrInfo *proinfo,
 
 #ifdef REALLYHAVEITONTHEBALL
 /**********************************************************************
- * plperl_trigger_handler()	- Handler for trigger calls
+ * plperl_trigger_handler() - Handler for trigger calls
  **********************************************************************/
 static HeapTuple
 plperl_trigger_handler(FmgrInfo *proinfo)
@@ -865,7 +883,7 @@ plperl_trigger_handler(FmgrInfo *proinfo)
 
 	/* Build the data list for the trigtuple */
 	plperl_build_tuple_argument(trigdata->tg_trigtuple,
-							   tupdesc, &tcl_trigtup);
+								tupdesc, &tcl_trigtup);
 
 	/*
 	 * Now the command part of the event for TG_op and data for NEW and
@@ -894,7 +912,7 @@ plperl_trigger_handler(FmgrInfo *proinfo)
 		Tcl_DStringAppendElement(&tcl_cmd, "UPDATE");
 
 		plperl_build_tuple_argument(trigdata->tg_newtuple,
-								   tupdesc, &tcl_newtup);
+									tupdesc, &tcl_newtup);
 
 		Tcl_DStringAppendElement(&tcl_cmd, Tcl_DStringValue(&tcl_newtup));
 		Tcl_DStringAppendElement(&tcl_cmd, Tcl_DStringValue(&tcl_trigtup));
@@ -1090,7 +1108,7 @@ plperl_trigger_handler(FmgrInfo *proinfo)
  **********************************************************************/
 static int
 plperl_elog(ClientData cdata, Tcl_Interp *interp,
-		   int argc, char *argv[])
+			int argc, char *argv[])
 {
 	int			level;
 	sigjmp_buf	save_restart;
@@ -1156,7 +1174,7 @@ plperl_elog(ClientData cdata, Tcl_Interp *interp,
  **********************************************************************/
 static int
 plperl_quote(ClientData cdata, Tcl_Interp *interp,
-			int argc, char *argv[])
+			 int argc, char *argv[])
 {
 	char	   *tmp;
 	char	   *cp1;
@@ -1210,7 +1228,7 @@ plperl_quote(ClientData cdata, Tcl_Interp *interp,
  **********************************************************************/
 static int
 plperl_SPI_exec(ClientData cdata, Tcl_Interp *interp,
-			   int argc, char *argv[])
+				int argc, char *argv[])
 {
 	int			spi_rc;
 	char		buf[64];
@@ -1317,13 +1335,13 @@ plperl_SPI_exec(ClientData cdata, Tcl_Interp *interp,
 
 		case SPI_ERROR_ARGUMENT:
 			Tcl_SetResult(interp,
-						  "plperl: SPI_exec() failed - SPI_ERROR_ARGUMENT",
+						"plperl: SPI_exec() failed - SPI_ERROR_ARGUMENT",
 						  TCL_VOLATILE);
 			return TCL_ERROR;
 
 		case SPI_ERROR_UNCONNECTED:
 			Tcl_SetResult(interp,
-					  "plperl: SPI_exec() failed - SPI_ERROR_UNCONNECTED",
+					 "plperl: SPI_exec() failed - SPI_ERROR_UNCONNECTED",
 						  TCL_VOLATILE);
 			return TCL_ERROR;
 
@@ -1341,13 +1359,13 @@ plperl_SPI_exec(ClientData cdata, Tcl_Interp *interp,
 
 		case SPI_ERROR_TRANSACTION:
 			Tcl_SetResult(interp,
-					  "plperl: SPI_exec() failed - SPI_ERROR_TRANSACTION",
+					 "plperl: SPI_exec() failed - SPI_ERROR_TRANSACTION",
 						  TCL_VOLATILE);
 			return TCL_ERROR;
 
 		case SPI_ERROR_OPUNKNOWN:
 			Tcl_SetResult(interp,
-						"plperl: SPI_exec() failed - SPI_ERROR_OPUNKNOWN",
+					   "plperl: SPI_exec() failed - SPI_ERROR_OPUNKNOWN",
 						  TCL_VOLATILE);
 			return TCL_ERROR;
 
@@ -1442,7 +1460,7 @@ plperl_SPI_exec(ClientData cdata, Tcl_Interp *interp,
  **********************************************************************/
 static int
 plperl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
-				  int argc, char *argv[])
+				   int argc, char *argv[])
 {
 	int			nargs;
 	char	  **args;
@@ -1623,7 +1641,7 @@ plperl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
  **********************************************************************/
 static int
 plperl_SPI_execp(ClientData cdata, Tcl_Interp *interp,
-				int argc, char *argv[])
+				 int argc, char *argv[])
 {
 	int			spi_rc;
 	char		buf[64];
@@ -1885,13 +1903,13 @@ plperl_SPI_execp(ClientData cdata, Tcl_Interp *interp,
 
 		case SPI_ERROR_ARGUMENT:
 			Tcl_SetResult(interp,
-						  "plperl: SPI_exec() failed - SPI_ERROR_ARGUMENT",
+						"plperl: SPI_exec() failed - SPI_ERROR_ARGUMENT",
 						  TCL_VOLATILE);
 			return TCL_ERROR;
 
 		case SPI_ERROR_UNCONNECTED:
 			Tcl_SetResult(interp,
-					  "plperl: SPI_exec() failed - SPI_ERROR_UNCONNECTED",
+					 "plperl: SPI_exec() failed - SPI_ERROR_UNCONNECTED",
 						  TCL_VOLATILE);
 			return TCL_ERROR;
 
@@ -1909,13 +1927,13 @@ plperl_SPI_execp(ClientData cdata, Tcl_Interp *interp,
 
 		case SPI_ERROR_TRANSACTION:
 			Tcl_SetResult(interp,
-					  "plperl: SPI_exec() failed - SPI_ERROR_TRANSACTION",
+					 "plperl: SPI_exec() failed - SPI_ERROR_TRANSACTION",
 						  TCL_VOLATILE);
 			return TCL_ERROR;
 
 		case SPI_ERROR_OPUNKNOWN:
 			Tcl_SetResult(interp,
-						"plperl: SPI_exec() failed - SPI_ERROR_OPUNKNOWN",
+					   "plperl: SPI_exec() failed - SPI_ERROR_OPUNKNOWN",
 						  TCL_VOLATILE);
 			return TCL_ERROR;
 
@@ -2008,7 +2026,7 @@ plperl_SPI_execp(ClientData cdata, Tcl_Interp *interp,
  **********************************************************************/
 static void
 plperl_set_tuple_values(Tcl_Interp *interp, char *arrayname,
-					   int tupno, HeapTuple tuple, TupleDesc tupdesc)
+						int tupno, HeapTuple tuple, TupleDesc tupdesc)
 {
 	int			i;
 	char	   *outputstr;
@@ -2102,16 +2120,16 @@ plperl_set_tuple_values(Tcl_Interp *interp, char *arrayname,
  * plperl_build_tuple_argument() - Build a string for a ref to a hash
  *				  from all attributes of a given tuple
  **********************************************************************/
-static SV*
+static SV  *
 plperl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc)
 {
 	int			i;
-	SV*     output;
+	SV		   *output;
 	Datum		attr;
 	bool		isnull;
 
 	char	   *attname;
-	char*     outputstr;
+	char	   *outputstr;
 	HeapTuple	typeTup;
 	Oid			typoutput;
 	Oid			typelem;
@@ -2163,9 +2181,9 @@ plperl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc)
 
 			sv_catpvf(output, "'%s' => '%s',", attname, outputstr);
 			pfree(outputstr);
-		} else {
-			sv_catpvf(output, "'%s' => undef,", attname);
 		}
+		else
+			sv_catpvf(output, "'%s' => undef,", attname);
 	}
 	sv_catpv(output, "}");
 	output = perl_eval_pv(SvPV(output, na), TRUE);
diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c
index 55fc537412ffc74b0c869c12e7f1495e02f81b20..fc8f8ab1fcbf0399e8b46c1dd64e6d7284be5833 100644
--- a/src/pl/plpgsql/src/pl_comp.c
+++ b/src/pl/plpgsql/src/pl_comp.c
@@ -3,7 +3,7 @@
  *			  procedural language
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.17 2000/01/20 05:44:34 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.18 2000/04/12 17:17:19 momjian Exp $
  *
  *	  This software is copyrighted by Jan Wieck - Hamburg.
  *
@@ -67,8 +67,8 @@
  * ----------
  */
 extern PLPGSQL_YYSTYPE plpgsql_yylval;
-extern char 		plpgsql_yytext[];
-extern int			plpgsql_yylineno;
+extern char plpgsql_yytext[];
+extern int	plpgsql_yylineno;
 
 /* ----------
  * Our own local and global variables
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index dfb4d252306feb4a44f6d2daa531c09dbf49481c..d9acac49474288e991bbfe23fb1cb149fb46e68b 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -3,7 +3,7 @@
  *			  procedural language
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.19 2000/03/11 06:19:00 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.20 2000/04/12 17:17:19 momjian Exp $
  *
  *	  This software is copyrighted by Jan Wieck - Hamburg.
  *
@@ -2510,7 +2510,7 @@ exec_simple_check_plan(PLpgSQL_expr * expr)
 	if (plan == NULL)			/* utility statement produces this */
 		return;
 
-	if (! IsA(plan, Result))
+	if (!IsA(plan, Result))
 		return;
 
 	/* ----------
diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c
index fcb2a8e6c1f34a4a4316884ffe5619ef3a69ef28..5a1115193f20921655a24a0f085b6a0b1a742af1 100644
--- a/src/pl/tcl/pltcl.c
+++ b/src/pl/tcl/pltcl.c
@@ -3,7 +3,7 @@
  *			  procedural language (PL)
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.19 2000/02/27 07:18:29 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.20 2000/04/12 17:17:20 momjian Exp $
  *
  *	  This software is copyrighted by Jan Wieck - Hamburg.
  *
@@ -112,7 +112,7 @@ static void pltcl_init_load_unknown(void);
 #endif	 /* PLTCL_UNKNOWN_SUPPORT */
 
 Datum pltcl_call_handler(FmgrInfo *proinfo,
-						 FmgrValues *proargs, bool *isNull);
+				   FmgrValues *proargs, bool *isNull);
 
 static Datum pltcl_func_handler(FmgrInfo *proinfo,
 				   FmgrValues *proargs, bool *isNull);
@@ -417,7 +417,7 @@ pltcl_func_handler(FmgrInfo *proinfo,
 	char	   *stroid;
 	Tcl_HashEntry *hashent;
 	int			hashnew;
-	pltcl_proc_desc * volatile prodesc;
+	pltcl_proc_desc *volatile prodesc;
 	Tcl_DString tcl_cmd;
 	Tcl_DString list_tmp;
 	int			tcl_rc;
@@ -739,7 +739,7 @@ pltcl_trigger_handler(FmgrInfo *proinfo)
 	int			hashnew;
 	pltcl_proc_desc *prodesc;
 	TupleDesc	tupdesc;
-	volatile HeapTuple	rettup;
+	volatile HeapTuple rettup;
 	Tcl_DString tcl_cmd;
 	Tcl_DString tcl_trigtup;
 	Tcl_DString tcl_newtup;
@@ -919,7 +919,7 @@ pltcl_trigger_handler(FmgrInfo *proinfo)
 	Tcl_DStringAppendElement(&tcl_trigtup, "");
 	for (i = 0; i < tupdesc->natts; i++)
 		Tcl_DStringAppendElement(&tcl_trigtup,
-			NameStr(tupdesc->attrs[i]->attname));
+								 NameStr(tupdesc->attrs[i]->attname));
 	Tcl_DStringAppendElement(&tcl_cmd, Tcl_DStringValue(&tcl_trigtup));
 	Tcl_DStringFree(&tcl_trigtup);
 	Tcl_DStringInit(&tcl_trigtup);
@@ -1289,13 +1289,13 @@ pltcl_SPI_exec(ClientData cdata, Tcl_Interp *interp,
 	int			spi_rc;
 	char		buf[64];
 	int			count = 0;
-	char	   * volatile arrayname = NULL;
-	volatile int		query_idx;
+	char	   *volatile arrayname = NULL;
+	volatile int query_idx;
 	int			i;
 	int			loop_rc;
 	int			ntuples;
-	HeapTuple * volatile tuples;
-	volatile TupleDesc	tupdesc = NULL;
+	HeapTuple  *volatile tuples;
+	volatile TupleDesc tupdesc = NULL;
 	sigjmp_buf	save_restart;
 
 	char	   *usage = "syntax error - 'SPI_exec "
@@ -1706,15 +1706,15 @@ pltcl_SPI_execp(ClientData cdata, Tcl_Interp *interp,
 	int			loop_body;
 	Tcl_HashEntry *hashent;
 	pltcl_query_desc *qdesc;
-	char * volatile nulls = NULL;
-	char * volatile arrayname = NULL;
+	char	   *volatile nulls = NULL;
+	char	   *volatile arrayname = NULL;
 	int			count = 0;
 	int			callnargs;
 	static char **callargs = NULL;
 	int			loop_rc;
 	int			ntuples;
-	HeapTuple * volatile tuples = NULL;
-	volatile TupleDesc	tupdesc = NULL;
+	HeapTuple  *volatile tuples = NULL;
+	volatile TupleDesc tupdesc = NULL;
 	sigjmp_buf	save_restart;
 
 	char	   *usage = "syntax error - 'SPI_execp "
diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c
index 44172452d6c35f3fa2938957c749ab9823230c97..b388f2f977b9d58d48ef25c5fad1c1830dcc81e4 100644
--- a/src/test/regress/regress.c
+++ b/src/test/regress/regress.c
@@ -1,5 +1,5 @@
 /*
- * $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.35 1999/12/16 22:20:03 wieck Exp $
+ * $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.36 2000/04/12 17:17:21 momjian Exp $
  */
 
 #include <float.h>				/* faked on sunos */
@@ -368,7 +368,7 @@ funny_dup17()
 	fieldval = SPI_getvalue(tuple, tupdesc, 1);
 	fieldtype = SPI_gettype(tupdesc, 1);
 
-	query = (char *) palloc(100 + NAMEDATALEN*3 +
+	query = (char *) palloc(100 + NAMEDATALEN * 3 +
 							strlen(fieldval) + strlen(fieldtype));
 
 	sprintf(query, "insert into %s select * from %s where %s = '%s'::%s",
diff --git a/src/utils/version.c b/src/utils/version.c
index 974100d5ff930a56387dc2c5d822baf20b52b924..0797280caf6a0e263268e10e94099e65b92d528f 100644
--- a/src/utils/version.c
+++ b/src/utils/version.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/utils/Attic/version.c,v 1.14 2000/01/26 05:58:53 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/utils/Attic/version.c,v 1.15 2000/04/12 17:17:22 momjian Exp $
  *
  *	STANDALONE CODE - do not use error routines as this code is not linked
  *	with any...
@@ -78,10 +78,10 @@ ValidatePgVersion(const char *path, char **reason_p)
 	}
 	else
 	{
-		nread = read(fd, version, sizeof(version)-1);
+		nread = read(fd, version, sizeof(version) - 1);
 		if (nread < 4 ||
 			!isdigit(version[0]) ||
-			version[nread-1] != '\n')
+			version[nread - 1] != '\n')
 		{
 			*reason_p = malloc(100 + strlen(full_path));
 			sprintf(*reason_p, "File '%s' does not have a valid format "
diff --git a/src/win32/endian.h b/src/win32/endian.h
index 534933f01c827367bf4aaf4412eaacf8e8d0cb98..44007a104315700f84ad3df0917aa63937cbf545 100644
--- a/src/win32/endian.h
+++ b/src/win32/endian.h
@@ -5,4 +5,4 @@
 
 #include <sys/param.h>
 
-#endif /* _ENDIAN_H_ */
+#endif	 /* _ENDIAN_H_ */
diff --git a/src/win32/un.h b/src/win32/un.h
index 55f9b06d7c205bbfc3a26b649b2afc5ac6d58a91..971a6fb2f54e5bfd1adef64c200d68ed554ea48a 100644
--- a/src/win32/un.h
+++ b/src/win32/un.h
@@ -9,4 +9,4 @@ struct sockaddr_un
 	char		sun_path[108];	/* path name (gag) */
 };
 
-#endif /* _SYS_UN_H */
+#endif	 /* _SYS_UN_H */