From 9a0dd4fb183958f59f68d8a5f096dd8df18d9b59 Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Mon, 30 Mar 1998 16:47:35 +0000
Subject: [PATCH] There's a patch attached to fix gcc 2.8.x warnings, except
 for the yyerror ones from bison. It also includes a few 'enhancements' to the
 C programming style (which are, of course, personal).

The other patch removes the compilation of backend/lib/qsort.c, as
qsort() is a standard function in stdlib.h and can be used any
where else (and it is). It was only used in
backend/optimizer/geqo/geqo_pool.c, backend/optimizer/path/predmig.c,
and backend/storage/page/bufpage.c

> > Some or all of these changes might not be appropriate for v6.3,
since we > > are in beta testing and since they do not affect the
current functionality.  > > For those cases, how about submitting
patches based on the final v6.3 > > release?

There's more to come. Please review these patches. I ran the
regression tests and they only failed where this was expected
(random, geo, etc).

Cheers,

Jeroen
---
 src/backend/commands/copy.c            |   4 +-
 src/backend/commands/sequence.c        |   6 +
 src/backend/commands/variable.c        |   6 +-
 src/backend/executor/nodeIndexscan.c   |  88 +++----
 src/backend/executor/nodeSeqscan.c     |   8 +-
 src/backend/lib/Makefile               |   4 +-
 src/backend/lib/qsort.c                | 312 -------------------------
 src/backend/libpq/be-dumpdata.c        |   4 +-
 src/backend/optimizer/geqo/geqo_pool.c |   7 +-
 src/backend/optimizer/path/joinrels.c  |   4 +-
 src/backend/optimizer/path/predmig.c   |   5 +-
 src/backend/parser/analyze.c           |   4 +-
 src/backend/postmaster/postmaster.c    |   7 +-
 src/backend/storage/page/bufpage.c     |   6 +-
 src/backend/utils/adt/arrayfuncs.c     |   8 +-
 src/bin/pg_dump/pg_dump.c              |   6 +-
 src/bin/pg_version/pg_version.c        |   4 +-
 17 files changed, 86 insertions(+), 397 deletions(-)
 delete mode 100644 src/backend/lib/qsort.c

diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index bf8a974401e..b2ca946b80b 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -6,7 +6,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.44 1998/02/26 04:30:52 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.45 1998/03/30 16:45:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1160,6 +1160,7 @@ CopyAttributeOut(FILE *fp, char *string, char *delim)
 			(c == '\\' && !is_array))
 			fputc('\\', fp);
 		else if (c == '\\' && is_array)
+		{
 			if (*(string + 1) == '\\')
 			{
 				/* translate \\ to \\\\ */
@@ -1174,6 +1175,7 @@ CopyAttributeOut(FILE *fp, char *string, char *delim)
 				fputc('\\', fp);
 				fputc('\\', fp);
 			}
+		}
 		fputc(*string, fp);
 	}
 }
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index 9f3b27ba6d5..8313d15c651 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -499,18 +499,22 @@ init_params(CreateSeqStmt *seq, SequenceTupleForm new)
 		elog(ERROR, "DefineSequence: can't INCREMENT by 0");
 
 	if (max_value == (DefElem *) NULL)	/* MAXVALUE */
+	{
 		if (new->increment_by > 0)
 			new->max_value = SEQ_MAXVALUE;		/* ascending seq */
 		else
 			new->max_value = -1;/* descending seq */
+	}
 	else
 		new->max_value = get_param(max_value);
 
 	if (min_value == (DefElem *) NULL)	/* MINVALUE */
+	{
 		if (new->increment_by > 0)
 			new->min_value = 1; /* ascending seq */
 		else
 			new->min_value = SEQ_MINVALUE;		/* descending seq */
+	}
 	else
 		new->min_value = get_param(min_value);
 
@@ -519,10 +523,12 @@ init_params(CreateSeqStmt *seq, SequenceTupleForm new)
 			 new->min_value, new->max_value);
 
 	if (last_value == (DefElem *) NULL) /* START WITH */
+	{
 		if (new->increment_by > 0)
 			new->last_value = new->min_value;	/* ascending seq */
 		else
 			new->last_value = new->max_value;	/* descending seq */
+	}
 	else
 		new->last_value = get_param(last_value);
 
diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c
index 364eed343b7..621854f200f 100644
--- a/src/backend/commands/variable.c
+++ b/src/backend/commands/variable.c
@@ -2,7 +2,7 @@
  * Routines for handling of 'SET var TO',
  *	'SHOW var' and 'RESET var' statements.
  *
- * $Id: variable.c,v 1.4 1998/02/26 04:31:05 momjian Exp $
+ * $Id: variable.c,v 1.5 1998/03/30 16:45:59 momjian Exp $
  *
  */
 
@@ -444,13 +444,15 @@ parse_timezone(const char *value)
 	{
 		/* Not yet tried to save original value from environment? */
 		if (defaultTZ == NULL)
+		{
 			/* found something? then save it for later */
 			if ((defaultTZ = getenv("TZ")) != NULL)
 				strcpy(TZvalue, defaultTZ);
 
-		/* found nothing so mark with an invalid pointer */
+			/* found nothing so mark with an invalid pointer */
 			else
 				defaultTZ = (char *) -1;
+		}
 
 		strcpy(tzbuf, "TZ=");
 		strcat(tzbuf, tok);
diff --git a/src/backend/executor/nodeIndexscan.c b/src/backend/executor/nodeIndexscan.c
index 8bce5762b26..74a36e45efa 100644
--- a/src/backend/executor/nodeIndexscan.c
+++ b/src/backend/executor/nodeIndexscan.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.16 1998/02/26 12:13:11 vadim Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.17 1998/03/30 16:46:08 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -91,7 +91,6 @@ IndexNext(IndexScan *node)
 	IndexScanDesc scandesc;
 	Relation	heapRelation;
 	RetrieveIndexResult result;
-	ItemPointer iptr;
 	HeapTuple	tuple;
 	TupleTableSlot *slot;
 	Buffer		buffer = InvalidBuffer;
@@ -116,58 +115,47 @@ IndexNext(IndexScan *node)
 	 * ----------------
 	 */
 
-	for (;;)
+	/* ----------------
+	 *	if scanning this index succeeded then return the
+	 *	appropriate heap tuple.. else return NULL.
+	 * ----------------
+	 */
+	while ((result = index_getnext(scandesc, direction)) != NULL)
 	{
-		result = index_getnext(scandesc, direction);
-		/* ----------------
-		 *	if scanning this index succeeded then return the
-		 *	appropriate heap tuple.. else return NULL.
-		 * ----------------
-		 */
-		if (result)
-		{
-			iptr = &result->heap_iptr;
-			tuple = heap_fetch(heapRelation,
-							   false,
-							   iptr,
-							   &buffer);
-			/* be tidy */
-			pfree(result);
-
-			if (tuple == NULL)
-			{
-				/* ----------------
-				 *	 we found a deleted tuple, so keep on scanning..
-				 * ----------------
-				 */
-				if (BufferIsValid(buffer))
-					ReleaseBuffer(buffer);
-				continue;
-			}
+		tuple = heap_fetch(heapRelation, false, &result->heap_iptr, &buffer);
+		/* be tidy */
+		pfree(result);
 
+		if (tuple != NULL)
+		{
 			/* ----------------
-			 *	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
-			 *	were not created with palloc() and so should 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
+		 	 *	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 */
-
+							slot,		/* slot to store in */
+							buffer,		/* buffer associated with tuple  */
+							false);		/* don't pfree */
+	
 			return slot;
 		}
-
-		/* ----------------
-		 *	if we get here it means the index scan failed so we
-		 *	are at the end of the scan..
-		 * ----------------
-		 */
-		return ExecClearTuple(slot);
+		else
+		{
+			if (BufferIsValid(buffer))
+				ReleaseBuffer(buffer);
+		}
 	}
+
+	/* ----------------
+	 *	if we get here it means the index scan failed so we
+	 *	are at the end of the scan..
+	 * ----------------
+	 */
+	return ExecClearTuple(slot);
 }
 
 /* ----------------------------------------------------------------
@@ -194,14 +182,11 @@ IndexNext(IndexScan *node)
 TupleTableSlot *
 ExecIndexScan(IndexScan *node)
 {
-	TupleTableSlot *returnTuple;
-
 	/* ----------------
 	 *	use IndexNext as access method
 	 * ----------------
 	 */
-	returnTuple = ExecScan(&node->scan, IndexNext);
-	return returnTuple;
+	return ExecScan(&node->scan, IndexNext);
 }
 
 /* ----------------------------------------------------------------
@@ -377,7 +362,6 @@ ExecEndIndexScan(IndexScan *node)
 	{
 		if (scanKeys[i] != NULL)
 			pfree(scanKeys[i]);
-
 	}
 
 	/* ----------------
diff --git a/src/backend/executor/nodeSeqscan.c b/src/backend/executor/nodeSeqscan.c
index fd8485daa38..a351ea4a298 100644
--- a/src/backend/executor/nodeSeqscan.c
+++ b/src/backend/executor/nodeSeqscan.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.8 1997/11/20 23:21:34 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.9 1998/03/30 16:46:15 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -128,8 +128,7 @@ ExecSeqScan(SeqScan *node)
 	 * else, scan the relation
 	 * ----------------
 	 */
-	outerPlan = outerPlan((Plan *) node);
-	if (outerPlan)
+	if ((outerPlan = outerPlan((Plan *) node)) != NULL)
 	{
 		slot = ExecProcNode(outerPlan, (Plan *) node);
 	}
@@ -375,8 +374,7 @@ ExecSeqReScan(SeqScan *node, ExprContext *exprCtxt, Plan *parent)
 	scanstate = node->scanstate;
 	estate = node->plan.state;
 
-	outerPlan = outerPlan((Plan *) node);
-	if (outerPlan)
+	if ((outerPlan = outerPlan((Plan *) node)) != NULL)
 	{
 		/* we are scanning a subplan */
 		outerPlan = outerPlan((Plan *) node);
diff --git a/src/backend/lib/Makefile b/src/backend/lib/Makefile
index 527e540ab37..2dcd4eeb647 100644
--- a/src/backend/lib/Makefile
+++ b/src/backend/lib/Makefile
@@ -4,7 +4,7 @@
 #    Makefile for lib (miscellaneous stuff)
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/lib/Makefile,v 1.9 1997/12/20 00:23:48 scrappy Exp $
+#    $Header: /cvsroot/pgsql/src/backend/lib/Makefile,v 1.10 1998/03/30 16:46:24 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -15,7 +15,7 @@ INCLUDE_OPT = -I..
 
 CFLAGS+=$(INCLUDE_OPT)
 
-OBJS = bit.o fstack.o hasht.o lispsort.o qsort.o stringinfo.o dllist.o
+OBJS = bit.o fstack.o hasht.o lispsort.o stringinfo.o dllist.o
 
 all: SUBSYS.o
 
diff --git a/src/backend/lib/qsort.c b/src/backend/lib/qsort.c
deleted file mode 100644
index 264b9417945..00000000000
--- a/src/backend/lib/qsort.c
+++ /dev/null
@@ -1,312 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * qsort.c--
- *
- *
- * Copyright (c) 1994, Regents of the University of California
- *
- *
- * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/lib/Attic/qsort.c,v 1.6 1998/02/26 04:31:40 momjian Exp $
- *
- *-------------------------------------------------------------------------
- */
-/*-
- * Copyright (c) 1980, 1983, 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *	  notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *	  notice, this list of conditions and the following disclaimer in the
- *	  documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *	  must display the following acknowledgement:
- *		This product includes software developed by the University of
- *		California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *	  may be used to endorse or promote products derived from this software
- *	  without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.	IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)qsort.c	5.9 (Berkeley) 2/23/91";
-
-#endif							/* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-
-#include <postgres.h>
-
-#include <lib/qsort.h>
-
-/*
- * MTHRESH is the smallest partition for which we compare for a median
- * value instead of using the middle value.
- */
-#define MTHRESH 6
-
-/*
- * THRESH is the minimum number of entries in a partition for continued
- * partitioning.
- */
-#define THRESH	4
-
-static void insertion_sort(char *bot, int nmemb, int size, int (*compar) ());
-static void quick_sort(char *bot, int nmemb, int size, int (*compar) ());
-
-void
-pg_qsort(void *bot,
-		 size_t nmemb,
-		 size_t size,
-		 int (*compar) (void *, void *))
-{
-
-	if (nmemb <= 1)
-		return;
-
-	if (nmemb >= THRESH)
-		quick_sort(bot, nmemb, size, compar);
-	else
-		insertion_sort(bot, nmemb, size, compar);
-}
-
-/*
- * Swap two areas of size number of bytes.	Although qsort(3) permits random
- * blocks of memory to be sorted, sorting pointers is almost certainly the
- * common case (and, were it not, could easily be made so).  Regardless, it
- * isn't worth optimizing; the SWAP's get sped up by the cache, and pointer
- * arithmetic gets lost in the time required for comparison function calls.
- */
-#define SWAP(a, b) { \
-		cnt = size; \
-		do { \
-				ch = *a; \
-				*a++ = *b; \
-				*b++ = ch; \
-		} while (--cnt); \
-}
-
-/*
- * Knuth, Vol. 3, page 116, Algorithm Q, step b, argues that a single pass
- * of straight insertion sort after partitioning is complete is better than
- * sorting each small partition as it is created.  This isn't correct in this
- * implementation because comparisons require at least one (and often two)
- * function calls and are likely to be the dominating expense of the sort.
- * Doing a final insertion sort does more comparisons than are necessary
- * because it compares the "edges" and medians of the partitions which are
- * known to be already sorted.
- *
- * This is also the reasoning behind selecting a small THRESH value (see
- * Knuth, page 122, equation 26), since the quicksort algorithm does less
- * comparisons than the insertion sort.
- */
-#define SORT(bot, n) { \
-		if (n > 1) \
-				if (n == 2) { \
-						t1 = bot + size; \
-						if (compar(t1, bot) < 0) \
-								SWAP(t1, bot); \
-				} else \
-						insertion_sort(bot, n, size, compar); \
-}
-
-static void
-quick_sort(char *bot, int nmemb, int size, int (*compar) ())
-{
-	int			cnt;
-	u_char		ch;
-	char	   *top,
-			   *mid,
-			   *t1,
-			   *t2;
-	int			n1,
-				n2;
-	char	   *bsv;
-
-	/* bot and nmemb must already be set. */
-partition:
-
-	/* find mid and top elements */
-	mid = bot + size * (nmemb >> 1);
-	top = bot + (nmemb - 1) * size;
-
-	/*
-	 * Find the median of the first, last and middle element (see Knuth,
-	 * Vol. 3, page 123, Eq. 28).  This test order gets the equalities
-	 * right.
-	 */
-	if (nmemb >= MTHRESH)
-	{
-		n1 = compar(bot, mid);
-		n2 = compar(mid, top);
-		if (n1 < 0 && n2 > 0)
-			t1 = compar(bot, top) < 0 ? top : bot;
-		else if (n1 > 0 && n2 < 0)
-			t1 = compar(bot, top) > 0 ? top : bot;
-		else
-			t1 = mid;
-
-		/* if mid element not selected, swap selection there */
-		if (t1 != mid)
-		{
-			SWAP(t1, mid);
-			mid -= size;
-		}
-	}
-
-	/* Standard quicksort, Knuth, Vol. 3, page 116, Algorithm Q. */
-#define didswap n1
-#define newbot	t1
-#define replace t2
-	didswap = 0;
-	for (bsv = bot;;)
-	{
-		for (; bot < mid && compar(bot, mid) <= 0; bot += size);
-		while (top > mid)
-		{
-			if (compar(mid, top) <= 0)
-			{
-				top -= size;
-				continue;
-			}
-			newbot = bot + size;/* value of bot after swap */
-			if (bot == mid)		/* top <-> mid, mid == top */
-				replace = mid = top;
-			else
-			{					/* bot <-> top */
-				replace = top;
-				top -= size;
-			}
-			goto swap;
-		}
-		if (bot == mid)
-			break;
-
-		/* bot <-> mid, mid == bot */
-		replace = mid;
-		newbot = mid = bot;		/* value of bot after swap */
-		top -= size;
-
-swap:	SWAP(bot, replace);
-		bot = newbot;
-		didswap = 1;
-	}
-
-	/*
-	 * Quicksort behaves badly in the presence of data which is already
-	 * sorted (see Knuth, Vol. 3, page 119) going from O N lg N to O N^2.
-	 * To avoid this worst case behavior, if a re-partitioning occurs
-	 * without swapping any elements, it is not further partitioned and is
-	 * insert sorted.  This wins big with almost sorted data sets and only
-	 * loses if the data set is very strangely partitioned.  A fix for
-	 * those data sets would be to return prematurely if the insertion
-	 * sort routine is forced to make an excessive number of swaps, and
-	 * continue the partitioning.
-	 */
-	if (!didswap)
-	{
-		insertion_sort(bsv, nmemb, size, compar);
-		return;
-	}
-
-	/*
-	 * Re-partition or sort as necessary.  Note that the mid element
-	 * itself is correctly positioned and can be ignored.
-	 */
-#define nlower	n1
-#define nupper	n2
-	bot = bsv;
-	nlower = (mid - bot) / size;/* size of lower partition */
-	mid += size;
-	nupper = nmemb - nlower - 1;/* size of upper partition */
-
-	/*
-	 * If must call recursively, do it on the smaller partition; this
-	 * bounds the stack to lg N entries.
-	 */
-	if (nlower > nupper)
-	{
-		if (nupper >= THRESH)
-			quick_sort(mid, nupper, size, compar);
-		else
-		{
-			SORT(mid, nupper);
-			if (nlower < THRESH)
-			{
-				SORT(bot, nlower);
-				return;
-			}
-		}
-		nmemb = nlower;
-	}
-	else
-	{
-		if (nlower >= THRESH)
-			quick_sort(bot, nlower, size, compar);
-		else
-		{
-			SORT(bot, nlower);
-			if (nupper < THRESH)
-			{
-				SORT(mid, nupper);
-				return;
-			}
-		}
-		bot = mid;
-		nmemb = nupper;
-	}
-	goto partition;
-}
-
-static void
-insertion_sort(char *bot, int nmemb, int size, int (*compar) ())
-{
-	int			cnt;
-	u_char		ch;
-	char	   *s1,
-			   *s2,
-			   *t1,
-			   *t2,
-			   *top;
-
-	/*
-	 * A simple insertion sort (see Knuth, Vol. 3, page 81, Algorithm S).
-	 * Insertion sort has the same worst case as most simple sorts (O
-	 * N^2).  It gets used here because it is (O N) in the case of sorted
-	 * data.
-	 */
-	top = bot + nmemb * size;
-	for (t1 = bot + size; t1 < top;)
-	{
-		for (t2 = t1; (t2 -= size) >= bot && compar(t1, t2) < 0;);
-		if (t1 != (t2 += size))
-		{
-			/* Bubble bytes up through each element. */
-			for (cnt = size; cnt--; ++t1)
-			{
-				ch = *t1;
-				for (s1 = s2 = t1; (s2 -= size) >= t2; s1 = s2)
-					*s1 = *s2;
-				*s1 = ch;
-			}
-		}
-		else
-			t1 += size;
-	}
-}
diff --git a/src/backend/libpq/be-dumpdata.c b/src/backend/libpq/be-dumpdata.c
index 9ac6af1d1f0..2a7df53ee6b 100644
--- a/src/backend/libpq/be-dumpdata.c
+++ b/src/backend/libpq/be-dumpdata.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-dumpdata.c,v 1.14 1998/02/26 04:31:44 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-dumpdata.c,v 1.15 1998/03/30 16:46:29 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -305,10 +305,12 @@ be_printtup(HeapTuple tuple, TupleDesc typeinfo)
 		lengths[i] = typeinfo->attrs[i]->attlen;
 
 		if (lengths[i] == -1)	/* variable length attribute */
+		{
 			if (!isnull)
 				lengths[i] = VARSIZE(attr) - VARHDRSZ;
 			else
 				lengths[i] = 0;
+		}
 
 		if (!isnull && OidIsValid(typoutput))
 		{
diff --git a/src/backend/optimizer/geqo/geqo_pool.c b/src/backend/optimizer/geqo/geqo_pool.c
index 085a649796a..bd797045215 100644
--- a/src/backend/optimizer/geqo/geqo_pool.c
+++ b/src/backend/optimizer/geqo/geqo_pool.c
@@ -5,7 +5,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: geqo_pool.c,v 1.5 1998/02/26 04:32:23 momjian Exp $
+ * $Id: geqo_pool.c,v 1.6 1998/03/30 16:46:35 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -35,8 +35,6 @@
 #include "optimizer/clauses.h"
 #include "optimizer/cost.h"
 
-#include "lib/qsort.h"
-
 #include "optimizer/geqo_gene.h"
 #include "optimizer/geqo.h"
 #include "optimizer/geqo_pool.h"
@@ -127,8 +125,7 @@ random_init_pool(Query *root, Pool *pool, int strt, int stp)
 void
 sort_pool(Pool *pool)
 {
-	pg_qsort(pool->data, pool->size, sizeof(Chromosome), compare);
-
+	qsort(pool->data, pool->size, sizeof(Chromosome), compare);
 }
 
 /*
diff --git a/src/backend/optimizer/path/joinrels.c b/src/backend/optimizer/path/joinrels.c
index 7917baed097..00277253468 100644
--- a/src/backend/optimizer/path/joinrels.c
+++ b/src/backend/optimizer/path/joinrels.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.8 1998/02/26 04:32:38 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.9 1998/03/30 16:46:45 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -70,10 +70,12 @@ find_join_rels(Query *root, List *outer_rels)
 		Rel		   *outer_rel = (Rel *) lfirst(r);
 
 		if (!(joins = find_clause_joins(root, outer_rel, outer_rel->joininfo)))
+		{
 			if (BushyPlanFlag)
 				joins = find_clauseless_joins(outer_rel, outer_rels);
 			else
 				joins = find_clauseless_joins(outer_rel, root->base_relation_list_);
+		}
 
 		join_list = nconc(join_list, joins);
 	}
diff --git a/src/backend/optimizer/path/predmig.c b/src/backend/optimizer/path/predmig.c
index 544a3c1c8e7..0a73ea8b33e 100644
--- a/src/backend/optimizer/path/predmig.c
+++ b/src/backend/optimizer/path/predmig.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/predmig.c,v 1.9 1998/02/26 04:32:42 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/predmig.c,v 1.10 1998/03/30 16:46:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -47,7 +47,6 @@
 #include "optimizer/cost.h"
 #include "optimizer/keys.h"
 #include "optimizer/tlist.h"
-#include "lib/qsort.h"
 
 #define is_clause(node) (get_cinfo(node))		/* a stream node
 												 * represents a clause
@@ -698,7 +697,7 @@ xfunc_stream_qsort(Stream root, Stream bottom)
 		nodearray[i] = tmp;
 
 	/* sort the array */
-	pg_qsort(nodearray, num, sizeof(LispValue), xfunc_stream_compare);
+	qsort(nodearray, num, sizeof(LispValue), xfunc_stream_compare);
 
 	/* paste together the array elements */
 	output = nodearray[num - 1];
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index 6dfdd8c26fe..4ec2f1853a1 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.72 1998/03/30 16:36:23 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.73 1998/03/30 16:47:02 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -583,11 +583,13 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
 			elog(ERROR, "parser: internal error; unrecognized deferred node", NULL);
 
 		if (constraint->contype == CONSTR_PRIMARY)
+		{
 			if (have_pkey)
 				elog(ERROR, "CREATE TABLE/PRIMARY KEY multiple primary keys"
 					 " for table %s are not legal", stmt->relname);
 			else
 				have_pkey = TRUE;
+		}
 		else if (constraint->contype != CONSTR_UNIQUE)
 			elog(ERROR, "parser: internal error; unrecognized deferred constraint", NULL);
 
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 7ed1808f65a..6f1c28b50ab 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.75 1998/02/26 04:34:43 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.76 1998/03/30 16:47:11 momjian Exp $
  *
  * NOTES
  *
@@ -60,7 +60,6 @@
 #include <sys/socket.h>
 #ifdef HAVE_LIMITS_H
 #include <limits.h>
-#define MAXINT		   INT_MAX
 #else
 #include <values.h>
 #endif
@@ -102,6 +101,10 @@
 #endif
 #endif
 
+#if !defined(MAXINT)
+#define MAXINT		   INT_MAX
+#endif
+
 #define INVALID_SOCK	(-1)
 #define ARGV_SIZE	64
 
diff --git a/src/backend/storage/page/bufpage.c b/src/backend/storage/page/bufpage.c
index 2675616e898..9be7d8c64bf 100644
--- a/src/backend/storage/page/bufpage.c
+++ b/src/backend/storage/page/bufpage.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.14 1998/02/11 19:11:59 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.15 1998/03/30 16:47:18 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -24,8 +24,6 @@
 #include "utils/memutils.h"
 #include "storage/bufpage.h"
 
-#include "lib/qsort.h"
-
 static void
 PageIndexTupleDeleteAdjustLinePointers(PageHeader phdr,
 									   char *location, Size size);
@@ -330,7 +328,7 @@ PageRepairFragmentation(Page page)
 		}
 
 		/* sort itemIdSortData array... */
-		pg_qsort((char *) itemidbase, nused, sizeof(struct itemIdSortData),
+		qsort((char *) itemidbase, nused, sizeof(struct itemIdSortData),
 				 itemidcompare);
 
 		/* compactify page */
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c
index 6844c584124..7cfc425c181 100644
--- a/src/backend/utils/adt/arrayfuncs.c
+++ b/src/backend/utils/adt/arrayfuncs.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.28 1998/03/20 03:44:19 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.29 1998/03/30 16:47:23 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -78,8 +78,8 @@ _LOArrayRange(int st[], int endp[], int bsize, int srcfd,
 static void
 _ReadArray(int st[], int endp[], int bsize, int srcfd, int destfd,
 		   ArrayType *array, int isDestLO, bool *isNull);
-static ArrayCastAndSet(char *src, bool typbyval, int typlen, char *dest);
-static SanityCheckInput(int ndim, int n, int dim[], int lb[], int indx[]);
+static int  ArrayCastAndSet(char *src, bool typbyval, int typlen, char *dest);
+static int  SanityCheckInput(int ndim, int n, int dim[], int lb[], int indx[]);
 static int	array_read(char *destptr, int eltsize, int nitems, char *srcptr);
 static char *array_seek(char *ptr, int eltsize, int nitems);
 
@@ -1033,6 +1033,7 @@ array_clip(ArrayType *array,
 			pfree(buff);
 		}
 		if (isDestLO)
+		{
 			if (ARR_IS_CHUNKED(array))
 			{
 				_ReadChunkArray(lowerIndx, upperIndx, len, fd, (char *) newfd, array,
@@ -1042,6 +1043,7 @@ array_clip(ArrayType *array,
 			{
 				_ReadArray(lowerIndx, upperIndx, len, fd, newfd, array, 1, isNull);
 			}
+		}
 #ifdef LOARRAY
 		LOclose(fd);
 		LOclose(newfd);
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index f95d6829640..85ac97b78f0 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -21,7 +21,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.66 1998/03/16 05:41:39 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.67 1998/03/30 16:47:32 momjian Exp $
  *
  * Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
  *
@@ -1591,10 +1591,12 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
 					findx++;
 				}
 				if (TRIGGER_FOR_UPDATE(tgtype))
+				{
 					if (findx > 0)
 						strcat(query, " OR UPDATE");
 					else
 						strcat(query, " UPDATE");
+				}
 				sprintf(query, "%s ON %s FOR EACH ROW EXECUTE PROCEDURE %s (",
 						query, tblinfo[i].relname, tgfunc);
 				for (findx = 0; findx < tgnargs; findx++)
@@ -2508,6 +2510,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
 			{
 				ACLlist = ParseACL(tblinfo[i].relacl, &l);
 				if (ACLlist == (ACL *) NULL)
+				{
 					if (l == 0)
 						continue;
 					else
@@ -2516,6 +2519,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
 								tblinfo[i].relname);
 						exit_nicely(g_conn);
 					}
+				}
 
 				/* Revoke Default permissions for PUBLIC */
 				fprintf(fout,
diff --git a/src/bin/pg_version/pg_version.c b/src/bin/pg_version/pg_version.c
index 3c7de9387f0..541995ffcad 100644
--- a/src/bin/pg_version/pg_version.c
+++ b/src/bin/pg_version/pg_version.c
@@ -7,14 +7,14 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/bin/pg_version/Attic/pg_version.c,v 1.8 1997/09/08 02:33:10 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/bin/pg_version/Attic/pg_version.c,v 1.9 1998/03/30 16:47:35 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include <stdlib.h>
 #include <stdio.h>
 
-#include <version.h>			/* interface to SetPgVersion */
+#include "version.h"			/* interface to SetPgVersion */
 
 
 
-- 
GitLab