diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c
index 0219ee6875c733ffc8daf6a2a80ff184174f0934..664c884a71219f59a861d265da324dc7a6e2ae67 100644
--- a/src/backend/access/common/printtup.c
+++ b/src/backend/access/common/printtup.c
@@ -9,7 +9,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/access/common/printtup.c,v 1.79 2003/11/29 19:51:39 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/access/common/printtup.c,v 1.80 2004/01/07 18:56:23 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -509,7 +509,7 @@ debugStartup(DestReceiver *self, int operation, TupleDesc typeinfo)
 	 * show the return type of the tuples
 	 */
 	for (i = 0; i < natts; ++i)
-		printatt((unsigned) i + 1, attinfo[i], (char *) NULL);
+		printatt((unsigned) i + 1, attinfo[i], NULL);
 	printf("\t----\n");
 }
 
diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c
index 9923240287a59019f31c6cea5a4ce6a223a44df1..65a10490d1e763fcced351e57fc6f3fdea3f3ebf 100644
--- a/src/backend/access/gist/gist.c
+++ b/src/backend/access/gist/gist.c
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.106 2003/11/29 19:51:39 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.107 2004/01/07 18:56:23 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -45,10 +45,10 @@
  */
 #define FILLITEM(evp, isnullkey, okey, okeyb, rkey, rkeyb)	 do { \
 		if ( isnullkey ) {										  \
-				gistentryinit((evp), rkey, r, (Page) NULL ,		  \
+				gistentryinit((evp), rkey, r, NULL,				  \
 						(OffsetNumber) 0, rkeyb, FALSE);		  \
 		} else {												  \
-				gistentryinit((evp), okey, r, (Page) NULL,		  \
+				gistentryinit((evp), okey, r, NULL,				  \
 						(OffsetNumber) 0, okeyb, FALSE);		  \
 		}														  \
 } while(0)
@@ -248,7 +248,7 @@ gistbuildCallback(Relation index,
 		else
 		{
 			gistcentryinit(&buildstate->giststate, i, &tmpcentry, attdata[i],
-						   (Relation) NULL, (Page) NULL, (OffsetNumber) 0,
+						   NULL, NULL, (OffsetNumber) 0,
 						 -1 /* size is currently bogus */ , TRUE, FALSE);
 			if (attdata[i] != tmpcentry.key &&
 				!(isAttByVal(&buildstate->giststate, i)))
@@ -332,7 +332,7 @@ gistinsert(PG_FUNCTION_ARGS)
 		else
 		{
 			gistcentryinit(&giststate, i, &tmpentry, datum[i],
-						   (Relation) NULL, (Page) NULL, (OffsetNumber) 0,
+						   NULL, NULL, (OffsetNumber) 0,
 						 -1 /* size is currently bogus */ , TRUE, FALSE);
 			if (datum[i] != tmpentry.key && !(isAttByVal(&giststate, i)))
 				compvec[i] = TRUE;
@@ -695,7 +695,7 @@ gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate)
 			gistdentryinit(giststate, j,
 						   &((GISTENTRY *) VARDATA(evec))[reallen],
 						   datum,
-					   (Relation) NULL, (Page) NULL, (OffsetNumber) NULL,
+						   NULL, NULL, (OffsetNumber) 0,
 						   ATTSIZE(datum, giststate->tupdesc, j + 1, IsNull), FALSE, IsNull);
 			if ((!isAttByVal(giststate, j)) &&
 				((GISTENTRY *) VARDATA(evec))[reallen].key != datum)
@@ -717,7 +717,7 @@ gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate)
 			{
 				VARATT_SIZEP(evec) = 2 * sizeof(GISTENTRY) + VARHDRSZ;
 				gistentryinit(((GISTENTRY *) VARDATA(evec))[1],
-					((GISTENTRY *) VARDATA(evec))[0].key, r, (Page) NULL,
+					((GISTENTRY *) VARDATA(evec))[0].key, r, NULL,
 							  (OffsetNumber) 0, ((GISTENTRY *) VARDATA(evec))[0].bytes, FALSE);
 
 			}
@@ -732,7 +732,7 @@ gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate)
 					pfree(DatumGetPointer(((GISTENTRY *) VARDATA(evec))[i].key));
 
 			gistcentryinit(giststate, j, &centry[j], datum,
-					   (Relation) NULL, (Page) NULL, (OffsetNumber) NULL,
+						   NULL, NULL, (OffsetNumber) 0,
 						   datumsize, FALSE, FALSE);
 			isnull[j] = ' ';
 			attr[j] = centry[j].key;
@@ -793,10 +793,10 @@ gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *gis
 	ev0p = &((GISTENTRY *) VARDATA(evec))[0];
 	ev1p = &((GISTENTRY *) VARDATA(evec))[1];
 
-	gistDeCompressAtt(giststate, r, oldtup, (Page) NULL,
+	gistDeCompressAtt(giststate, r, oldtup, NULL,
 					  (OffsetNumber) 0, oldatt, olddec, oldisnull);
 
-	gistDeCompressAtt(giststate, r, addtup, (Page) NULL,
+	gistDeCompressAtt(giststate, r, addtup, NULL,
 					  (OffsetNumber) 0, addatt, adddec, addisnull);
 
 
@@ -841,7 +841,7 @@ gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *gis
 				pfree(DatumGetPointer(addatt[j].key));
 
 			gistcentryinit(giststate, j, &centry[j], datum,
-					   (Relation) NULL, (Page) NULL, (OffsetNumber) NULL,
+						   NULL, NULL, (OffsetNumber) 0,
 						   datumsize, FALSE, FALSE);
 
 			isnull[j] = ' ';
@@ -929,8 +929,7 @@ gistunionsubkey(Relation r, GISTSTATE *giststate, IndexTuple *itvec, GIST_SPLITV
 				gistdentryinit(giststate, j,
 							   &((GISTENTRY *) VARDATA(evec))[reallen],
 							   datum,
-							   (Relation) NULL, (Page) NULL,
-							   (OffsetNumber) NULL,
+							   NULL, NULL, (OffsetNumber) 0,
 							   ATTSIZE(datum, giststate->tupdesc, j + 1, IsNull), FALSE, IsNull);
 				if ((!isAttByVal(giststate, j)) &&
 					((GISTENTRY *) VARDATA(evec))[reallen].key != datum)
@@ -1110,7 +1109,7 @@ gistadjsubkey(Relation r,
 	{
 		if (v->spl_idgrp[i + 1] == 0)	/* already inserted */
 			continue;
-		gistDeCompressAtt(giststate, r, itup[i], (Page) NULL, (OffsetNumber) 0,
+		gistDeCompressAtt(giststate, r, itup[i], NULL, (OffsetNumber) 0,
 						  identry, decfree, isnull);
 
 		v->spl_ngrp[v->spl_idgrp[i + 1]]--;
@@ -1127,12 +1126,12 @@ gistadjsubkey(Relation r,
 			/* where? */
 			for (j = 1; j < r->rd_att->natts; j++)
 			{
-				gistentryinit(entry, v->spl_lattr[j], r, (Page) NULL,
+				gistentryinit(entry, v->spl_lattr[j], r, NULL,
 						   (OffsetNumber) 0, v->spl_lattrsize[j], FALSE);
 				gistpenalty(giststate, j, &entry, v->spl_lisnull[j],
 							&identry[j], isnull[j], &lpenalty);
 
-				gistentryinit(entry, v->spl_rattr[j], r, (Page) NULL,
+				gistentryinit(entry, v->spl_rattr[j], r, NULL,
 						   (OffsetNumber) 0, v->spl_rattrsize[j], FALSE);
 				gistpenalty(giststate, j, &entry, v->spl_risnull[j],
 							&identry[j], isnull[j], &rpenalty);
@@ -1486,7 +1485,7 @@ gistchoose(Relation r, Page p, IndexTuple it,	/* it has compressed entry */
 	which = -1;
 	sum_grow = 1;
 	gistDeCompressAtt(giststate, r,
-					  it, (Page) NULL, (OffsetNumber) 0,
+					  it, NULL, (OffsetNumber) 0,
 					  identry, decompvec, isnull);
 
 	for (i = FirstOffsetNumber; i <= maxoff && sum_grow; i = OffsetNumberNext(i))
@@ -1530,7 +1529,7 @@ gistfreestack(GISTSTACK *s)
 {
 	GISTSTACK  *p;
 
-	while (s != (GISTSTACK *) NULL)
+	while (s != NULL)
 	{
 		p = s->gs_parent;
 		pfree(s);
@@ -1609,7 +1608,7 @@ gistbulkdelete(PG_FUNCTION_ARGS)
 	 */
 
 	/* walk through the entire index */
-	iscan = index_beginscan(NULL, rel, SnapshotAny, 0, (ScanKey) NULL);
+	iscan = index_beginscan(NULL, rel, SnapshotAny, 0, NULL);
 	/* including killed tuples */
 	iscan->ignore_killed_tuples = false;
 
@@ -1829,7 +1828,7 @@ gistFormTuple(GISTSTATE *giststate, Relation r,
 		else
 		{
 			gistcentryinit(giststate, j, &centry[j], attdata[j],
-					   (Relation) NULL, (Page) NULL, (OffsetNumber) NULL,
+						   NULL, NULL, (OffsetNumber) 0,
 						   datumsize[j], FALSE, FALSE);
 			isnullchar[j] = ' ';
 			compatt[j] = centry[j].key;
diff --git a/src/backend/access/gist/gistget.c b/src/backend/access/gist/gistget.c
index d78f923bd13eb36bf4ea448bc4974d41d4a1716e..faf2f8429b80f13ea3fec2ee3741660efe3c40f9 100644
--- a/src/backend/access/gist/gistget.c
+++ b/src/backend/access/gist/gistget.c
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.39 2003/11/29 19:51:39 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.40 2004/01/07 18:56:23 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -76,7 +76,7 @@ gistfirst(IndexScanDesc s, ScanDirection dir)
 		while (n < FirstOffsetNumber || n > maxoff)
 		{
 			ReleaseBuffer(b);
-			if (so->s_stack == (GISTSTACK *) NULL)
+			if (so->s_stack == NULL)
 				return false;
 
 			stk = so->s_stack;
@@ -158,7 +158,7 @@ gistnext(IndexScanDesc s, ScanDirection dir)
 		while (n < FirstOffsetNumber || n > maxoff)
 		{
 			ReleaseBuffer(b);
-			if (so->s_stack == (GISTSTACK *) NULL)
+			if (so->s_stack == NULL)
 				return false;
 
 			stk = so->s_stack;
diff --git a/src/backend/access/gist/gistscan.c b/src/backend/access/gist/gistscan.c
index 469c01945ab50c1bcc44f03f16c49e0315762b93..30bb9b810afe0837e0e23e15470ff4e0f0ee7dda 100644
--- a/src/backend/access/gist/gistscan.c
+++ b/src/backend/access/gist/gistscan.c
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.50 2003/11/29 19:51:39 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.51 2004/01/07 18:56:23 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -47,7 +47,7 @@ typedef struct GISTScanListData
 typedef GISTScanListData *GISTScanList;
 
 /* pointer to list of local scans on GiSTs */
-static GISTScanList GISTScans = (GISTScanList) NULL;
+static GISTScanList GISTScans = NULL;
 
 Datum
 gistbeginscan(PG_FUNCTION_ARGS)
@@ -79,19 +79,19 @@ gistrescan(PG_FUNCTION_ARGS)
 	ItemPointerSetInvalid(&s->currentMarkData);
 
 	p = (GISTScanOpaque) s->opaque;
-	if (p != (GISTScanOpaque) NULL)
+	if (p != NULL)
 	{
 		/* rescan an existing indexscan --- reset state */
 		gistfreestack(p->s_stack);
 		gistfreestack(p->s_markstk);
-		p->s_stack = p->s_markstk = (GISTSTACK *) NULL;
+		p->s_stack = p->s_markstk = NULL;
 		p->s_flags = 0x0;
 	}
 	else
 	{
 		/* initialize opaque data */
 		p = (GISTScanOpaque) palloc(sizeof(GISTScanOpaqueData));
-		p->s_stack = p->s_markstk = (GISTSTACK *) NULL;
+		p->s_stack = p->s_markstk = NULL;
 		p->s_flags = 0x0;
 		s->opaque = p;
 		p->giststate = (GISTSTATE *) palloc(sizeof(GISTSTATE));
@@ -137,11 +137,11 @@ gistmarkpos(PG_FUNCTION_ARGS)
 	else
 		p->s_flags &= ~GS_MRKBEFORE;
 
-	o = (GISTSTACK *) NULL;
+	o = NULL;
 	n = p->s_stack;
 
 	/* copy the parent stack from the current item data */
-	while (n != (GISTSTACK *) NULL)
+	while (n != NULL)
 	{
 		tmp = (GISTSTACK *) palloc(sizeof(GISTSTACK));
 		tmp->gs_child = n->gs_child;
@@ -173,11 +173,11 @@ gistrestrpos(PG_FUNCTION_ARGS)
 	else
 		p->s_flags &= ~GS_CURBEFORE;
 
-	o = (GISTSTACK *) NULL;
+	o = NULL;
 	n = p->s_markstk;
 
 	/* copy the parent stack from the current item data */
-	while (n != (GISTSTACK *) NULL)
+	while (n != NULL)
 	{
 		tmp = (GISTSTACK *) palloc(sizeof(GISTSTACK));
 		tmp->gs_child = n->gs_child;
@@ -201,7 +201,7 @@ gistendscan(PG_FUNCTION_ARGS)
 
 	p = (GISTScanOpaque) s->opaque;
 
-	if (p != (GISTScanOpaque) NULL)
+	if (p != NULL)
 	{
 		gistfreestack(p->s_stack);
 		gistfreestack(p->s_markstk);
@@ -233,18 +233,16 @@ gistdropscan(IndexScanDesc s)
 	GISTScanList l;
 	GISTScanList prev;
 
-	prev = (GISTScanList) NULL;
+	prev = NULL;
 
-	for (l = GISTScans;
-		 l != (GISTScanList) NULL && l->gsl_scan != s;
-		 l = l->gsl_next)
+	for (l = GISTScans; l != NULL && l->gsl_scan != s; l = l->gsl_next)
 		prev = l;
 
-	if (l == (GISTScanList) NULL)
+	if (l == NULL)
 		elog(ERROR, "GiST scan list corrupted -- could not find 0x%p",
 			 (void *) s);
 
-	if (prev == (GISTScanList) NULL)
+	if (prev == NULL)
 		GISTScans = l->gsl_next;
 	else
 		prev->gsl_next = l->gsl_next;
@@ -280,7 +278,7 @@ gistadjscans(Relation rel, int op, BlockNumber blkno, OffsetNumber offnum)
 	Oid			relid;
 
 	relid = RelationGetRelid(rel);
-	for (l = GISTScans; l != (GISTScanList) NULL; l = l->gsl_next)
+	for (l = GISTScans; l != NULL; l = l->gsl_next)
 	{
 		if (l->gsl_scan->indexRelation->rd_id == relid)
 			gistadjone(l->gsl_scan, op, blkno, offnum);
@@ -397,12 +395,10 @@ adjustiptr(IndexScanDesc s,
  *		are looking at already in this transaction, we ignore the update
  *		request.
  */
-/*ARGSUSED*/
 static void
-adjuststack(GISTSTACK *stk,
-			BlockNumber blkno)
+adjuststack(GISTSTACK *stk, BlockNumber blkno)
 {
-	while (stk != (GISTSTACK *) NULL)
+	while (stk != NULL)
 	{
 		if (stk->gs_blk == blkno)
 			stk->gs_child = FirstOffsetNumber;
diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c
index 2623a41f083402a811bc2400db79fd79230c4530..5ada6b34d87b6f8e2ca27d4a332d7e4f6d0d0d47 100644
--- a/src/backend/access/hash/hash.c
+++ b/src/backend/access/hash/hash.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.69 2003/11/29 19:51:40 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.70 2004/01/07 18:56:23 neilc Exp $
  *
  * NOTES
  *	  This file contains only the public interface routines.
@@ -180,7 +180,7 @@ hashinsert(PG_FUNCTION_ARGS)
 	if (IndexTupleHasNulls(itup))
 	{
 		pfree(itup);
-		PG_RETURN_POINTER((InsertIndexResult) NULL);
+		PG_RETURN_POINTER(NULL);
 	}
 
 	hitem = _hash_formitem(itup);
diff --git a/src/backend/access/hash/hashscan.c b/src/backend/access/hash/hashscan.c
index 656e67c7cdbf5ad7fa7ced2db113ae6404b85bd7..fcf2a01cddb4f0a150ba73d3ebe426f1c410f659 100644
--- a/src/backend/access/hash/hashscan.c
+++ b/src/backend/access/hash/hashscan.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/access/hash/hashscan.c,v 1.32 2003/11/29 19:51:40 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/access/hash/hashscan.c,v 1.33 2004/01/07 18:56:23 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@ typedef struct HashScanListData
 
 typedef HashScanListData *HashScanList;
 
-static HashScanList HashScans = (HashScanList) NULL;
+static HashScanList HashScans = NULL;
 
 
 /*
@@ -73,16 +73,16 @@ _hash_dropscan(IndexScanDesc scan)
 	HashScanList chk,
 				last;
 
-	last = (HashScanList) NULL;
+	last = NULL;
 	for (chk = HashScans;
-		 chk != (HashScanList) NULL && chk->hashsl_scan != scan;
+		 chk != NULL && chk->hashsl_scan != scan;
 		 chk = chk->hashsl_next)
 		last = chk;
 
-	if (chk == (HashScanList) NULL)
+	if (chk == NULL)
 		elog(ERROR, "hash scan list trashed; can't find 0x%p", (void *) scan);
 
-	if (last == (HashScanList) NULL)
+	if (last == NULL)
 		HashScans = chk->hashsl_next;
 	else
 		last->hashsl_next = chk->hashsl_next;
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 6f642c7e8e414cefca999f996896f835e70bdaac..a4f9b3afd33eb0a3911bad3b3f8fc90bdabf0b11 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.160 2004/01/05 20:36:04 neilc Exp $
+ *	  $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.161 2004/01/07 18:56:24 neilc Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -124,7 +124,7 @@ heapgettup(Relation relation,
 	int			linesleft;
 	ItemPointer tid;
 
-	tid = (tuple->t_data == NULL) ? (ItemPointer) NULL : &(tuple->t_self);
+	tid = (tuple->t_data == NULL) ? NULL : &(tuple->t_self);
 
 	/*
 	 * debugging stuff
@@ -919,7 +919,7 @@ heap_fetch(Relation relation,
 	 * check time qualification of tuple, then release lock
 	 */
 	HeapTupleSatisfies(tuple, relation, buffer, dp,
-					   snapshot, 0, (ScanKey) NULL, valid);
+					   snapshot, 0, NULL, valid);
 
 	LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
 
@@ -1026,7 +1026,7 @@ heap_get_latest_tid(Relation relation,
 	 */
 
 	HeapTupleSatisfies(&tp, relation, buffer, dp,
-					   snapshot, 0, (ScanKey) NULL, valid);
+					   snapshot, 0, NULL, valid);
 
 	linkend = true;
 	if ((t_data->t_infomask & HEAP_XMIN_COMMITTED) != 0 &&
@@ -1946,7 +1946,7 @@ heap_restrpos(HeapScanDesc scan)
 				   &(scan->rs_cbuf),
 				   scan->rs_snapshot,
 				   0,
-				   (ScanKey) NULL);
+				   NULL);
 	}
 }
 
diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c
index b23006460956bff90bc4bda6436b1aaa99b5d2ab..51601efc597ce992e9329298fb034df3e3e9d9c5 100644
--- a/src/backend/access/nbtree/nbtinsert.c
+++ b/src/backend/access/nbtree/nbtinsert.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.110 2003/12/21 01:23:06 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.111 2004/01/07 18:56:24 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1186,7 +1186,7 @@ _bt_insert_parent(Relation rel,
 	{
 		Buffer		rootbuf;
 
-		Assert(stack == (BTStack) NULL);
+		Assert(stack == NULL);
 		Assert(is_only);
 		/* create a new root node and update the metapage */
 		rootbuf = _bt_newroot(rel, buf, rbuf);
@@ -1206,7 +1206,7 @@ _bt_insert_parent(Relation rel,
 		BTItem		ritem;
 		Buffer		pbuf;
 
-		if (stack == (BTStack) NULL)
+		if (stack == NULL)
 		{
 			BTPageOpaque lpageop;
 
diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c
index 8c04f5496bb4ec6850b3147a8cf5491bfdfc3740..b989ee3c23c8c3ad8b723f0f729bac9ce3886006 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
- *	  $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.108 2003/11/29 19:51:40 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.109 2004/01/07 18:56:24 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -396,7 +396,7 @@ btrescan(PG_FUNCTION_ARGS)
 		if (scan->numberOfKeys > 0)
 			so->keyData = (ScanKey) palloc(scan->numberOfKeys * sizeof(ScanKeyData));
 		else
-			so->keyData = (ScanKey) NULL;
+			so->keyData = NULL;
 		scan->opaque = so;
 	}
 
@@ -459,7 +459,7 @@ btendscan(PG_FUNCTION_ARGS)
 		ItemPointerSetInvalid(iptr);
 	}
 
-	if (so->keyData != (ScanKey) NULL)
+	if (so->keyData != NULL)
 		pfree(so->keyData);
 	pfree(so);
 
diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c
index 583a18f1711fac9e0667df9707fa269cf85f8fcd..0986f49a6e3d4570fdb145859c8d60e230a394cd 100644
--- a/src/backend/access/nbtree/nbtsort.c
+++ b/src/backend/access/nbtree/nbtsort.c
@@ -36,7 +36,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsort.c,v 1.79 2003/11/29 19:51:40 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsort.c,v 1.80 2004/01/07 18:56:24 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -257,7 +257,7 @@ _bt_pagestate(Relation index, uint32 level)
 	/* create initial page */
 	_bt_blnewpage(index, &(state->btps_buf), &(state->btps_page), level);
 
-	state->btps_minkey = (BTItem) NULL;
+	state->btps_minkey = NULL;
 	/* initialize lastoff so first item goes into P_FIRSTKEY */
 	state->btps_lastoff = P_HIKEY;
 	state->btps_level = level;
@@ -267,7 +267,7 @@ _bt_pagestate(Relation index, uint32 level)
 	else
 		state->btps_full = PageGetPageSize(state->btps_page) / 10;
 	/* no parent level, yet */
-	state->btps_next = (BTPageState *) NULL;
+	state->btps_next = NULL;
 
 	return state;
 }
@@ -444,7 +444,7 @@ _bt_buildadd(Relation index, BTPageState *state, BTItem bti)
 		 * we don't have a parent, we have to create one; this adds a new
 		 * btree level.
 		 */
-		if (state->btps_next == (BTPageState *) NULL)
+		if (state->btps_next == NULL)
 			state->btps_next = _bt_pagestate(index, state->btps_level + 1);
 
 		Assert(state->btps_minkey != NULL);
@@ -520,7 +520,7 @@ _bt_uppershutdown(Relation index, BTPageState *state)
 	/*
 	 * Each iteration of this loop completes one more level of the tree.
 	 */
-	for (s = state; s != (BTPageState *) NULL; s = s->btps_next)
+	for (s = state; s != NULL; s = s->btps_next)
 	{
 		BlockNumber blkno;
 		BTPageOpaque opaque;
@@ -536,7 +536,7 @@ _bt_uppershutdown(Relation index, BTPageState *state)
 		 * key.  This may cause the last page of the parent level to
 		 * split, but that's not a problem -- we haven't gotten to it yet.
 		 */
-		if (s->btps_next == (BTPageState *) NULL)
+		if (s->btps_next == NULL)
 		{
 			opaque->btpo_flags |= BTP_ROOT;
 			rootblkno = blkno;
diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c
index 888c20e882f937c6700a74a7e4bc1587f52dcd93..1c401e5e22d377886c7736029c2302292bfeb2b8 100644
--- a/src/backend/access/nbtree/nbtutils.c
+++ b/src/backend/access/nbtree/nbtutils.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/access/nbtree/nbtutils.c,v 1.57 2003/11/29 19:51:40 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/access/nbtree/nbtutils.c,v 1.58 2004/01/07 18:56:24 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -126,7 +126,7 @@ _bt_freestack(BTStack stack)
 {
 	BTStack		ostack;
 
-	while (stack != (BTStack) NULL)
+	while (stack != NULL)
 	{
 		ostack = stack;
 		stack = stack->bts_parent;
diff --git a/src/backend/access/nbtree/nbtxlog.c b/src/backend/access/nbtree/nbtxlog.c
index 0a6aaa114708e5569472d78fdc88373031637b0d..02dbd33341d643d90f59afbb6430180eb3d0ce72 100644
--- a/src/backend/access/nbtree/nbtxlog.c
+++ b/src/backend/access/nbtree/nbtxlog.c
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.9 2003/12/14 00:34:47 neilc Exp $
+ *	  $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.10 2004/01/07 18:56:24 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -995,7 +995,7 @@ btree_xlog_cleanup(void)
 		/* if the two pages are all of their level, it's a only-page split */
 		is_only = P_LEFTMOST(lpageop) && P_RIGHTMOST(rpageop);
 
-		_bt_insert_parent(reln, lbuf, rbuf, (BTStack) NULL,
+		_bt_insert_parent(reln, lbuf, rbuf, NULL,
 						  split->is_root, is_only);
 	}
 	incomplete_splits = NIL;
diff --git a/src/backend/access/rtree/rtget.c b/src/backend/access/rtree/rtget.c
index 0f7a046964d2621c5c40d3c8d00de3869f807368..a20ce5bc2fae5a01adc22e4e936c44e9687ce7f7 100644
--- a/src/backend/access/rtree/rtget.c
+++ b/src/backend/access/rtree/rtget.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/access/rtree/rtget.c,v 1.30 2003/11/29 19:51:40 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/access/rtree/rtget.c,v 1.31 2004/01/07 18:56:24 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -74,7 +74,7 @@ rtfirst(IndexScanDesc s, ScanDirection dir)
 		while (n < FirstOffsetNumber || n > maxoff)
 		{
 			ReleaseBuffer(b);
-			if (so->s_stack == (RTSTACK *) NULL)
+			if (so->s_stack == NULL)
 				return false;
 
 			stk = so->s_stack;
@@ -156,7 +156,7 @@ rtnext(IndexScanDesc s, ScanDirection dir)
 		while (n < FirstOffsetNumber || n > maxoff)
 		{
 			ReleaseBuffer(b);
-			if (so->s_stack == (RTSTACK *) NULL)
+			if (so->s_stack == NULL)
 				return false;
 
 			stk = so->s_stack;
diff --git a/src/backend/access/rtree/rtproc.c b/src/backend/access/rtree/rtproc.c
index 6fe35565af9e729fbb1fb69c6710d1e272b290e3..97030e2d60bb39993b540122c5108427f6e9bb38 100644
--- a/src/backend/access/rtree/rtproc.c
+++ b/src/backend/access/rtree/rtproc.c
@@ -15,7 +15,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/access/rtree/rtproc.c,v 1.39 2003/11/29 19:51:40 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/access/rtree/rtproc.c,v 1.40 2004/01/07 18:56:24 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -74,7 +74,7 @@ rt_box_size(PG_FUNCTION_ARGS)
 	/* NB: size is an output argument */
 	float	   *size = (float *) PG_GETARG_POINTER(1);
 
-	if (a == (BOX *) NULL || a->high.x <= a->low.x || a->high.y <= a->low.y)
+	if (a == NULL || a->high.x <= a->low.x || a->high.y <= a->low.y)
 		*size = 0.0;
 	else
 		*size = (float) ((a->high.x - a->low.x) * (a->high.y - a->low.y));
diff --git a/src/backend/access/rtree/rtree.c b/src/backend/access/rtree/rtree.c
index 221fff2092acec3e32ac7af002153b6d08ca3b43..9414e3142898cbf7c8047908b446a1e49aafad45 100644
--- a/src/backend/access/rtree/rtree.c
+++ b/src/backend/access/rtree/rtree.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/access/rtree/rtree.c,v 1.81 2003/11/29 19:51:40 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/access/rtree/rtree.c,v 1.82 2004/01/07 18:56:24 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -244,7 +244,7 @@ rtinsert(PG_FUNCTION_ARGS)
 	if (IndexTupleHasNulls(itup))
 	{
 		pfree(itup);
-		PG_RETURN_POINTER((InsertIndexResult) NULL);
+		PG_RETURN_POINTER(NULL);
 	}
 
 	initRtstate(&rtState, r);
@@ -275,7 +275,7 @@ rtdoinsert(Relation r, IndexTuple itup, RTSTATE *rtstate)
 
 	blk = P_ROOT;
 	buffer = InvalidBuffer;
-	stack = (RTSTACK *) NULL;
+	stack = NULL;
 
 	do
 	{
@@ -360,7 +360,7 @@ rttighten(Relation r,
 				newd_size;
 	Buffer		b;
 
-	if (stk == (RTSTACK *) NULL)
+	if (stk == NULL)
 		return;
 
 	b = ReadBuffer(r, stk->rts_blk);
@@ -622,7 +622,7 @@ rtintinsert(Relation r,
 				newdatum;
 	InsertIndexResult res;
 
-	if (stk == (RTSTACK *) NULL)
+	if (stk == NULL)
 	{
 		rtnewroot(r, ltup, rtup);
 		return;
@@ -912,7 +912,7 @@ rtpicksplit(Relation r,
 	 */
 
 	/* to keep compiler quiet */
-	cost_vector = (SPLITCOST *) NULL;
+	cost_vector = NULL;
 
 	if (num_tuples_without_seeds > 0)
 	{
@@ -1172,7 +1172,7 @@ freestack(RTSTACK *s)
 {
 	RTSTACK    *p;
 
-	while (s != (RTSTACK *) NULL)
+	while (s != NULL)
 	{
 		p = s->rts_parent;
 		pfree(s);
@@ -1213,7 +1213,7 @@ rtbulkdelete(PG_FUNCTION_ARGS)
 	 */
 
 	/* walk through the entire index */
-	iscan = index_beginscan(NULL, rel, SnapshotAny, 0, (ScanKey) NULL);
+	iscan = index_beginscan(NULL, rel, SnapshotAny, 0, NULL);
 	/* including killed tuples */
 	iscan->ignore_killed_tuples = false;
 
diff --git a/src/backend/access/rtree/rtscan.c b/src/backend/access/rtree/rtscan.c
index b5ceeb8b0e14795e6ffd00b7f08db10e3961eb7b..9dac2a15c06bda71be5a1387702a0ffd52243d1d 100644
--- a/src/backend/access/rtree/rtscan.c
+++ b/src/backend/access/rtree/rtscan.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/access/rtree/rtscan.c,v 1.50 2003/11/29 19:51:40 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/access/rtree/rtscan.c,v 1.51 2004/01/07 18:56:24 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -48,7 +48,7 @@ typedef struct RTScanListData
 typedef RTScanListData *RTScanList;
 
 /* pointer to list of local scans on rtrees */
-static RTScanList RTScans = (RTScanList) NULL;
+static RTScanList RTScans = NULL;
 
 Datum
 rtbeginscan(PG_FUNCTION_ARGS)
@@ -80,19 +80,19 @@ rtrescan(PG_FUNCTION_ARGS)
 	ItemPointerSetInvalid(&s->currentMarkData);
 
 	p = (RTreeScanOpaque) s->opaque;
-	if (p != (RTreeScanOpaque) NULL)
+	if (p != NULL)
 	{
 		/* rescan an existing indexscan --- reset state */
 		freestack(p->s_stack);
 		freestack(p->s_markstk);
-		p->s_stack = p->s_markstk = (RTSTACK *) NULL;
+		p->s_stack = p->s_markstk = NULL;
 		p->s_flags = 0x0;
 	}
 	else
 	{
 		/* initialize opaque data */
 		p = (RTreeScanOpaque) palloc(sizeof(RTreeScanOpaqueData));
-		p->s_stack = p->s_markstk = (RTSTACK *) NULL;
+		p->s_stack = p->s_markstk = NULL;
 		p->s_internalNKey = s->numberOfKeys;
 		p->s_flags = 0x0;
 		s->opaque = p;
@@ -156,11 +156,11 @@ rtmarkpos(PG_FUNCTION_ARGS)
 	else
 		p->s_flags &= ~RTS_MRKBEFORE;
 
-	o = (RTSTACK *) NULL;
+	o = NULL;
 	n = p->s_stack;
 
 	/* copy the parent stack from the current item data */
-	while (n != (RTSTACK *) NULL)
+	while (n != NULL)
 	{
 		tmp = (RTSTACK *) palloc(sizeof(RTSTACK));
 		tmp->rts_child = n->rts_child;
@@ -192,11 +192,11 @@ rtrestrpos(PG_FUNCTION_ARGS)
 	else
 		p->s_flags &= ~RTS_CURBEFORE;
 
-	o = (RTSTACK *) NULL;
+	o = NULL;
 	n = p->s_markstk;
 
 	/* copy the parent stack from the current item data */
-	while (n != (RTSTACK *) NULL)
+	while (n != NULL)
 	{
 		tmp = (RTSTACK *) palloc(sizeof(RTSTACK));
 		tmp->rts_child = n->rts_child;
@@ -220,7 +220,7 @@ rtendscan(PG_FUNCTION_ARGS)
 
 	p = (RTreeScanOpaque) s->opaque;
 
-	if (p != (RTreeScanOpaque) NULL)
+	if (p != NULL)
 	{
 		freestack(p->s_stack);
 		freestack(p->s_markstk);
@@ -250,18 +250,18 @@ rtdropscan(IndexScanDesc s)
 	RTScanList	l;
 	RTScanList	prev;
 
-	prev = (RTScanList) NULL;
+	prev = NULL;
 
 	for (l = RTScans;
-		 l != (RTScanList) NULL && l->rtsl_scan != s;
+		 l != NULL && l->rtsl_scan != s;
 		 l = l->rtsl_next)
 		prev = l;
 
-	if (l == (RTScanList) NULL)
+	if (l == NULL)
 		elog(ERROR, "rtree scan list corrupted -- could not find 0x%p",
 			 (void *) s);
 
-	if (prev == (RTScanList) NULL)
+	if (prev == NULL)
 		RTScans = l->rtsl_next;
 	else
 		prev->rtsl_next = l->rtsl_next;
@@ -297,7 +297,7 @@ rtadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum)
 	Oid			relid;
 
 	relid = RelationGetRelid(r);
-	for (l = RTScans; l != (RTScanList) NULL; l = l->rtsl_next)
+	for (l = RTScans; l != NULL; l = l->rtsl_next)
 	{
 		if (RelationGetRelid(l->rtsl_scan->indexRelation) == relid)
 			rtadjone(l->rtsl_scan, op, blkno, offnum);
@@ -414,12 +414,10 @@ adjustiptr(IndexScanDesc s,
  *		are looking at already in this transaction, we ignore the update
  *		request.
  */
-/*ARGSUSED*/
 static void
-adjuststack(RTSTACK *stk,
-			BlockNumber blkno)
+adjuststack(RTSTACK *stk, BlockNumber blkno)
 {
-	while (stk != (RTSTACK *) NULL)
+	while (stk != NULL)
 	{
 		if (stk->rts_blk == blkno)
 			stk->rts_child = FirstOffsetNumber;
diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c
index 2cd6a7dba1f402b68a8b1c455ca5210a4a10a512..d09a9d504d605cc84896ecadf009847ea6746877 100644
--- a/src/backend/access/transam/varsup.c
+++ b/src/backend/access/transam/varsup.c
@@ -6,7 +6,7 @@
  * Copyright (c) 2000-2003, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.53 2003/11/29 19:51:40 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.54 2004/01/07 18:56:24 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -77,7 +77,7 @@ GetNewTransactionId(void)
 	 * (SInvalLock would then mean primarily that PROCs couldn't be added/
 	 * removed while holding the lock.)
 	 */
-	if (MyProc != (PGPROC *) NULL)
+	if (MyProc != NULL)
 		MyProc->xid = xid;
 
 	LWLockRelease(XidGenLock);
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index 93375b2960ef2a92873d47252a7c700224c39cc3..c7725b0f6218ebafe2436e51d96d6ce2d23f0991 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.158 2003/12/02 19:26:47 joe Exp $
+ *	  $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.159 2004/01/07 18:56:24 neilc Exp $
  *
  * NOTES
  *		Transaction aborts can now occur two ways:
@@ -947,7 +947,7 @@ CommitTransaction(void)
 	 * as running as well or it will see two tuple versions - one deleted
 	 * by xid 1 and one inserted by xid 0.	See notes in GetSnapshotData.
 	 */
-	if (MyProc != (PGPROC *) NULL)
+	if (MyProc != NULL)
 	{
 		/* Lock SInvalLock because that's what GetSnapshotData uses. */
 		LWLockAcquire(SInvalLock, LW_EXCLUSIVE);
@@ -1064,7 +1064,7 @@ AbortTransaction(void)
 	 * this must be done _before_ releasing locks we hold and _after_
 	 * RecordTransactionAbort.
 	 */
-	if (MyProc != (PGPROC *) NULL)
+	if (MyProc != NULL)
 	{
 		/* Lock SInvalLock because that's what GetSnapshotData uses. */
 		LWLockAcquire(SInvalLock, LW_EXCLUSIVE);
@@ -1831,7 +1831,7 @@ xact_desc(char *buf, uint8 xl_info, char *rec)
 }
 
 void
-			XactPushRollback(void (*func) (void *), void *data)
+XactPushRollback(void (*func) (void *), void *data)
 {
 #ifdef XLOG_II
 	if (_RollbackFunc != NULL)
diff --git a/src/backend/bootstrap/bootparse.y b/src/backend/bootstrap/bootparse.y
index c5baca0c175cc9ce1ac1e86ae308e3a809844b0a..e768fb24b4f478086202a252df97a1535e5d1d82 100644
--- a/src/backend/bootstrap/bootparse.y
+++ b/src/backend/bootstrap/bootparse.y
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.63 2003/11/29 19:51:41 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.64 2004/01/07 18:56:25 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -220,7 +220,7 @@ Boot_InsertStmt:
 					if (num_columns_read != numattr)
 						elog(ERROR, "incorrect number of columns in row (expected %d, got %d)",
 							 numattr, num_columns_read);
-					if (boot_reldesc == (Relation) NULL)
+					if (boot_reldesc == NULL)
 					{
 						elog(ERROR, "relation not open");
 						err_out();
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index c1105f3b11e14c1015af49dc3e0f9c9532906143..8d29134d39d01cc5209125e927a36a148ef17737 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
- *	  $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.174 2004/01/06 23:55:18 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.175 2004/01/07 18:56:25 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -142,8 +142,8 @@ struct typmap
 	FormData_pg_type am_typ;
 };
 
-static struct typmap **Typ = (struct typmap **) NULL;
-static struct typmap *Ap = (struct typmap *) NULL;
+static struct typmap **Typ = NULL;
+static struct typmap *Ap = NULL;
 
 static int	Warnings = 0;
 static char Blanks[MAXATTR];
@@ -173,7 +173,7 @@ typedef struct _IndexList
 	struct _IndexList *il_next;
 } IndexList;
 
-static IndexList *ILHead = (IndexList *) NULL;
+static IndexList *ILHead = NULL;
 
 
 /* ----------------------------------------------------------------
@@ -509,7 +509,7 @@ BootstrapMain(int argc, char *argv[])
 	/* Initialize stuff for bootstrap-file processing */
 	for (i = 0; i < MAXATTR; i++)
 	{
-		attrtypes[i] = (Form_pg_attribute) NULL;
+		attrtypes[i] = NULL;
 		Blanks[i] = ' ';
 	}
 	for (i = 0; i < STRTABLESIZE; ++i)
@@ -569,10 +569,10 @@ boot_openrel(char *relname)
 	if (strlen(relname) >= NAMEDATALEN - 1)
 		relname[NAMEDATALEN - 1] = '\0';
 
-	if (Typ == (struct typmap **) NULL)
+	if (Typ == NULL)
 	{
 		rel = heap_openr(TypeRelationName, NoLock);
-		scan = heap_beginscan(rel, SnapshotNow, 0, (ScanKey) NULL);
+		scan = heap_beginscan(rel, SnapshotNow, 0, NULL);
 		i = 0;
 		while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
 			++i;
@@ -580,8 +580,8 @@ boot_openrel(char *relname)
 		app = Typ = ALLOC(struct typmap *, i + 1);
 		while (i-- > 0)
 			*app++ = ALLOC(struct typmap, 1);
-		*app = (struct typmap *) NULL;
-		scan = heap_beginscan(rel, SnapshotNow, 0, (ScanKey) NULL);
+		*app = NULL;
+		scan = heap_beginscan(rel, SnapshotNow, 0, NULL);
 		app = Typ;
 		while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
 		{
@@ -648,7 +648,7 @@ closerel(char *name)
 	{
 		elog(DEBUG4, "close relation %s", relname ? relname : "(null)");
 		heap_close(boot_reldesc, NoLock);
-		boot_reldesc = (Relation) NULL;
+		boot_reldesc = NULL;
 	}
 }
 
@@ -674,7 +674,7 @@ DefineAttr(char *name, char *type, int attnum)
 		closerel(relname);
 	}
 
-	if (attrtypes[attnum] == (Form_pg_attribute) NULL)
+	if (attrtypes[attnum] == NULL)
 		attrtypes[attnum] = AllocateAttribute();
 	MemSet(attrtypes[attnum], 0, ATTRIBUTE_TUPLE_SIZE);
 
@@ -684,7 +684,7 @@ DefineAttr(char *name, char *type, int attnum)
 
 	typeoid = gettype(type);
 
-	if (Typ != (struct typmap **) NULL)
+	if (Typ != NULL)
 	{
 		attrtypes[attnum]->atttypid = Ap->am_oid;
 		attlen = attrtypes[attnum]->attlen = Ap->am_typ.typlen;
@@ -817,7 +817,7 @@ InsertOneValue(char *value, int i)
 
 	elog(DEBUG4, "inserting column %d value \"%s\"", i, value);
 
-	if (Typ != (struct typmap **) NULL)
+	if (Typ != NULL)
 	{
 		struct typmap *ap;
 
@@ -949,9 +949,9 @@ gettype(char *type)
 	HeapTuple	tup;
 	struct typmap **app;
 
-	if (Typ != (struct typmap **) NULL)
+	if (Typ != NULL)
 	{
-		for (app = Typ; *app != (struct typmap *) NULL; app++)
+		for (app = Typ; *app != NULL; app++)
 		{
 			if (strncmp(NameStr((*app)->am_typ.typname), type, NAMEDATALEN) == 0)
 			{
@@ -969,7 +969,7 @@ gettype(char *type)
 		}
 		elog(DEBUG4, "external type: %s", type);
 		rel = heap_openr(TypeRelationName, NoLock);
-		scan = heap_beginscan(rel, SnapshotNow, 0, (ScanKey) NULL);
+		scan = heap_beginscan(rel, SnapshotNow, 0, NULL);
 		i = 0;
 		while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
 			++i;
@@ -977,8 +977,8 @@ gettype(char *type)
 		app = Typ = ALLOC(struct typmap *, i + 1);
 		while (i-- > 0)
 			*app++ = ALLOC(struct typmap, 1);
-		*app = (struct typmap *) NULL;
-		scan = heap_beginscan(rel, SnapshotNow, 0, (ScanKey) NULL);
+		*app = NULL;
+		scan = heap_beginscan(rel, SnapshotNow, 0, NULL);
 		app = Typ;
 		while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
 		{
@@ -1223,7 +1223,7 @@ index_register(Oid heap,
 	 */
 
 	if (nogc == NULL)
-		nogc = AllocSetContextCreate((MemoryContext) NULL,
+		nogc = AllocSetContextCreate(NULL,
 									 "BootstrapNoGC",
 									 ALLOCSET_DEFAULT_MINSIZE,
 									 ALLOCSET_DEFAULT_INITSIZE,
@@ -1253,9 +1253,9 @@ index_register(Oid heap,
 }
 
 void
-build_indices()
+build_indices(void)
 {
-	for (; ILHead != (IndexList *) NULL; ILHead = ILHead->il_next)
+	for (; ILHead != NULL; ILHead = ILHead->il_next)
 	{
 		Relation	heap;
 		Relation	ind;
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 59effe8e3213e80e996e956111e754a85211ae78..91c951362157144d093087d6373dde2d180ac822 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.224 2003/12/28 21:57:36 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.225 2004/01/07 18:56:25 neilc Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -1419,7 +1419,7 @@ IndexBuildHeapScan(Relation heapRelation,
 	scan = heap_beginscan(heapRelation, /* relation */
 						  snapshot,		/* seeself */
 						  0,	/* number of keys */
-						  (ScanKey) NULL);		/* scan key */
+						  NULL);		/* scan key */
 
 	reltuples = 0;
 
diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c
index bae085a75e535a44e9a4b77a4b58c9e73c0ca325..802b01f759ee382803d00805f4a39338fe9fda13 100644
--- a/src/backend/catalog/pg_type.c
+++ b/src/backend/catalog/pg_type.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/catalog/pg_type.c,v 1.91 2003/11/29 19:51:46 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/catalog/pg_type.c,v 1.92 2004/01/07 18:56:25 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -336,7 +336,7 @@ TypeCreate(const char *typeName,
 								 baseType,
 								 (defaultTypeBin ?
 								  stringToNode(defaultTypeBin) :
-								  (void *) NULL),
+								  NULL),
 								 rebuildDeps);
 
 	/*
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 3063815533d892be382136ebf49c463f561fd053..bd90961315cb669a0fa9278ec6df95528ddccaa5 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
- *	  $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.106 2003/12/12 18:45:08 petere Exp $
+ *	  $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.107 2004/01/07 18:56:25 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -199,7 +199,7 @@ Async_Listen(char *relname, int pid)
 	lRel = heap_openr(ListenerRelationName, AccessExclusiveLock);
 
 	/* Detect whether we are already listening on this relname */
-	scan = heap_beginscan(lRel, SnapshotNow, 0, (ScanKey) NULL);
+	scan = heap_beginscan(lRel, SnapshotNow, 0, NULL);
 	while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
 	{
 		Form_pg_listener listener = (Form_pg_listener) GETSTRUCT(tuple);
@@ -292,7 +292,7 @@ Async_Unlisten(char *relname, int pid)
 
 	lRel = heap_openr(ListenerRelationName, AccessExclusiveLock);
 
-	scan = heap_beginscan(lRel, SnapshotNow, 0, (ScanKey) NULL);
+	scan = heap_beginscan(lRel, SnapshotNow, 0, NULL);
 	while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
 	{
 		Form_pg_listener listener = (Form_pg_listener) GETSTRUCT(tuple);
@@ -459,7 +459,7 @@ AtCommit_Notify(void)
 
 	lRel = heap_openr(ListenerRelationName, AccessExclusiveLock);
 	tdesc = RelationGetDescr(lRel);
-	scan = heap_beginscan(lRel, SnapshotNow, 0, (ScanKey) NULL);
+	scan = heap_beginscan(lRel, SnapshotNow, 0, NULL);
 
 	while ((lTuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
 	{
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 91cccd5cacd2dfa3716f82512223e8de4f291318..2b8fdb9a2d4abd2717c94a6c15ac04a7883674cc 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.129 2003/12/15 22:56:44 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.130 2004/01/07 18:56:25 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -749,7 +749,7 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
 		datum = heap_getattr(tuple, Anum_pg_database_datconfig,
 							 RelationGetDescr(rel), &isnull);
 
-		a = isnull ? ((ArrayType *) NULL) : DatumGetArrayTypeP(datum);
+		a = isnull ? NULL : DatumGetArrayTypeP(datum);
 
 		if (valuestr)
 			a = GUCArrayAdd(a, stmt->variable, valuestr);
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c
index c2fa6dc9110e4197dff433dc9a4d3569927698b6..0f95f3bfc0544fe8c9559198fa517fe0af67078b 100644
--- a/src/backend/commands/prepare.c
+++ b/src/backend/commands/prepare.c
@@ -10,7 +10,7 @@
  * Copyright (c) 2002-2003, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.24 2003/11/29 19:51:47 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.25 2004/01/07 18:56:25 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -323,7 +323,7 @@ StorePreparedStatement(const char *stmt_name,
 	 * out-of-memory failure only wastes memory and doesn't leave us with
 	 * an incomplete (ie corrupt) hashtable entry.
 	 */
-	qstring = query_string ? pstrdup(query_string) : (char *) NULL;
+	qstring = query_string ? pstrdup(query_string) : NULL;
 	query_list = (List *) copyObject(query_list);
 	plan_list = (List *) copyObject(plan_list);
 	argtype_list = listCopy(argtype_list);
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index 54acb5b89cd32588a481dc0e521a970a47c3ed2f..3fcc76a72bc0805f79e4717ab3d63e2e52b1370c 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.106 2003/12/14 00:34:47 neilc Exp $
+ *	  $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.107 2004/01/07 18:56:25 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -946,7 +946,7 @@ init_params(List *options, Form_pg_sequence new, bool isInit)
 	}
 
 	/* INCREMENT BY */
-	if (increment_by != (DefElem *) NULL)
+	if (increment_by != NULL)
 	{
 		new->increment_by = defGetInt64(increment_by);
 		if (new->increment_by == 0)
@@ -958,7 +958,7 @@ init_params(List *options, Form_pg_sequence new, bool isInit)
 		new->increment_by = 1;
 
 	/* CYCLE */
-	if (is_cycled != (DefElem *) NULL)
+	if (is_cycled != NULL)
 	{
 		new->is_cycled = intVal(is_cycled->arg);
 		Assert(new->is_cycled == false || new->is_cycled == true);
@@ -967,11 +967,11 @@ init_params(List *options, Form_pg_sequence new, bool isInit)
 		new->is_cycled = false;
 
 	/* MAXVALUE (null arg means NO MAXVALUE) */
-	if (max_value != (DefElem *) NULL && max_value->arg)
+	if (max_value != NULL && max_value->arg)
 	{
 		new->max_value = defGetInt64(max_value);
 	}
-	else if (isInit || max_value != (DefElem *) NULL)
+	else if (isInit || max_value != NULL)
 	{
 		if (new->increment_by > 0)
 			new->max_value = SEQ_MAXVALUE;		/* ascending seq */
@@ -980,11 +980,11 @@ init_params(List *options, Form_pg_sequence new, bool isInit)
 	}
 
 	/* MINVALUE (null arg means NO MINVALUE) */
-	if (min_value != (DefElem *) NULL && min_value->arg)
+	if (min_value != NULL && min_value->arg)
 	{
 		new->min_value = defGetInt64(min_value);
 	}
-	else if (isInit || min_value != (DefElem *) NULL)
+	else if (isInit || min_value != NULL)
 	{
 		if (new->increment_by > 0)
 			new->min_value = 1;					/* ascending seq */
@@ -1007,7 +1007,7 @@ init_params(List *options, Form_pg_sequence new, bool isInit)
 	}
 
 	/* START WITH */
-	if (last_value != (DefElem *) NULL)
+	if (last_value != NULL)
 		new->last_value = defGetInt64(last_value);
 	else if (isInit)
 	{
@@ -1044,7 +1044,7 @@ init_params(List *options, Form_pg_sequence new, bool isInit)
 	}
 
 	/* CACHE */
-	if (cache_value != (DefElem *) NULL)
+	if (cache_value != NULL)
 	{
 		new->cache_value = defGetInt64(cache_value);
 		if (new->cache_value <= 0)
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index 20be53fbd50899dc649e433bd6403566781fe03d..bd8c6b91b9e804e8d61019a9961243fd32358778 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.131 2003/11/29 19:51:47 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.132 2004/01/07 18:56:25 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -986,7 +986,7 @@ AlterUserSet(AlterUserSetStmt *stmt)
 		datum = SysCacheGetAttr(SHADOWNAME, oldtuple,
 								Anum_pg_shadow_useconfig, &isnull);
 
-		array = isnull ? ((ArrayType *) NULL) : DatumGetArrayTypeP(datum);
+		array = isnull ? NULL : DatumGetArrayTypeP(datum);
 
 		if (valuestr)
 			array = GUCArrayAdd(array, stmt->variable, valuestr);
@@ -1457,7 +1457,7 @@ AlterGroup(AlterGroupStmt *stmt, const char *tag)
 	/* Fetch old group membership. */
 	datum = heap_getattr(group_tuple, Anum_pg_group_grolist,
 						 pg_group_dsc, &null);
-	oldarray = null ? ((IdList *) NULL) : DatumGetIdListP(datum);
+	oldarray = null ? NULL : DatumGetIdListP(datum);
 
 	/* initialize list with old array contents */
 	newlist = IdArrayToList(oldarray);
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 71844ff9b939a3afeaa40940db521950be663594..dae8c3f37cddfda321ae03623996c39acbd58f7a 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -13,7 +13,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.270 2004/01/06 18:07:31 neilc Exp $
+ *	  $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.271 2004/01/07 18:56:25 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -958,7 +958,7 @@ full_vacuum_rel(Relation onerel, VacuumStmt *vacstmt)
 		vacrelstats->hasindex = true;
 
 	/* Clean/scan index relation(s) */
-	if (Irel != (Relation *) NULL)
+	if (Irel != NULL)
 	{
 		if (vacuum_pages.num_pages > 0)
 		{
@@ -1257,7 +1257,7 @@ scan_heap(VRelStats *vacrelstats, Relation onerel,
 				 * removal of dead tuples.	But note we are NOT changing
 				 * the real page yet...
 				 */
-				if (tempPage == (Page) NULL)
+				if (tempPage == NULL)
 				{
 					Size		pageSize;
 
@@ -1284,7 +1284,7 @@ scan_heap(VRelStats *vacrelstats, Relation onerel,
 			}
 		}						/* scan along page */
 
-		if (tempPage != (Page) NULL)
+		if (tempPage != NULL)
 		{
 			/* Some tuples are removable; figure free space after removal */
 			PageRepairFragmentation(tempPage, NULL);
@@ -2406,7 +2406,7 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
 	if (Nvacpagelist.num_pages > 0)
 	{
 		/* vacuum indexes again if needed */
-		if (Irel != (Relation *) NULL)
+		if (Irel != NULL)
 		{
 			VacPage    *vpleft,
 					   *vpright,
@@ -3057,7 +3057,7 @@ vac_open_indexes(Relation relation, int *nindexes, Relation **Irel)
 void
 vac_close_indexes(int nindexes, Relation *Irel)
 {
-	if (Irel == (Relation *) NULL)
+	if (Irel == NULL)
 		return;
 
 	while (nindexes--)
diff --git a/src/backend/executor/execJunk.c b/src/backend/executor/execJunk.c
index 28b482437877b662615f1fb78878f5ece37dfc77..e970086d522ddd301e095793c3ac9a334b98c947 100644
--- a/src/backend/executor/execJunk.c
+++ b/src/backend/executor/execJunk.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/executor/execJunk.c,v 1.37 2003/11/29 19:51:48 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/executor/execJunk.c,v 1.38 2004/01/07 18:56:26 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -267,7 +267,7 @@ ExecRemoveJunk(JunkFilter *junkfilter, TupleTableSlot *slot)
 	 * Handle the trivial case first.
 	 */
 	if (cleanLength == 0)
-		return (HeapTuple) NULL;
+		return NULL;
 
 	/*
 	 * Create the arrays that will hold the attribute values and the null
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index f84b4dd690e290716321d240dec98c993b858cfe..cf581907a4fbcab2db71ccd1b259050b1321ae77 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -26,7 +26,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.224 2003/12/28 21:57:36 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.225 2004/01/07 18:56:26 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -782,7 +782,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
 	 *
 	 * If EXPLAIN, skip creating the "into" relation.
 	 */
-	intoRelationDesc = (Relation) NULL;
+	intoRelationDesc = NULL;
 
 	if (do_select_into && !explainOnly)
 	{
@@ -1076,7 +1076,7 @@ lnext:	;
 		 *
 		 * Also, extract all the junk information we need.
 		 */
-		if ((junkfilter = estate->es_junkFilter) != (JunkFilter *) NULL)
+		if ((junkfilter = estate->es_junkFilter) != NULL)
 		{
 			Datum		datum;
 			HeapTuple	newTuple;
diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c
index 0377f9f41046d4403557dd5983874f2307a6a069..bbed6f014b13e5f2bd4b2f5aa80233d7156706fd 100644
--- a/src/backend/executor/execQual.c
+++ b/src/backend/executor/execQual.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.152 2003/12/18 22:23:42 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.153 2004/01/07 18:56:26 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -548,7 +548,7 @@ GetAttributeByNum(TupleTableSlot *slot,
 	if (!AttributeNumberIsValid(attrno))
 		elog(ERROR, "invalid attribute number %d", attrno);
 
-	if (isNull == (bool *) NULL)
+	if (isNull == NULL)
 		elog(ERROR, "a NULL isNull pointer was passed");
 
 	if (TupIsNull(slot))
@@ -579,7 +579,7 @@ GetAttributeByName(TupleTableSlot *slot, char *attname, bool *isNull)
 	if (attname == NULL)
 		elog(ERROR, "invalid attribute name");
 
-	if (isNull == (bool *) NULL)
+	if (isNull == NULL)
 		elog(ERROR, "a NULL isNull pointer was passed");
 
 	if (TupIsNull(slot))
@@ -3116,7 +3116,7 @@ ExecProject(ProjectionInfo *projInfo, ExprDoneCond *isDone)
 	 * sanity checks
 	 */
 	if (projInfo == NULL)
-		return (TupleTableSlot *) NULL;
+		return NULL;
 
 	/*
 	 * get the projection info we want
diff --git a/src/backend/executor/execTuples.c b/src/backend/executor/execTuples.c
index e7e02fdb6d87ad52d9075484df2572ac8b209b8c..0bb59d26b11758c755fa7d2ff934a4ff43092194 100644
--- a/src/backend/executor/execTuples.c
+++ b/src/backend/executor/execTuples.c
@@ -15,7 +15,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.74 2003/12/01 23:09:02 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.75 2004/01/07 18:56:26 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -271,11 +271,11 @@ ExecAllocTableSlot(TupleTable table)
 
 	/* Make sure the allocated slot is valid (and empty) */
 	slot->type = T_TupleTableSlot;
-	slot->val = (HeapTuple) NULL;
+	slot->val = NULL;
 	slot->ttc_shouldFree = true;
 	slot->ttc_descIsNew = true;
 	slot->ttc_shouldFreeDesc = true;
-	slot->ttc_tupleDescriptor = (TupleDesc) NULL;
+	slot->ttc_tupleDescriptor = NULL;
 	slot->ttc_buffer = InvalidBuffer;
 
 	return slot;
@@ -296,11 +296,11 @@ MakeTupleTableSlot(void)
 	TupleTableSlot *slot = makeNode(TupleTableSlot);
 
 	/* This should match ExecAllocTableSlot() */
-	slot->val = (HeapTuple) NULL;
+	slot->val = NULL;
 	slot->ttc_shouldFree = true;
 	slot->ttc_descIsNew = true;
 	slot->ttc_shouldFreeDesc = true;
-	slot->ttc_tupleDescriptor = (TupleDesc) NULL;
+	slot->ttc_tupleDescriptor = NULL;
 	slot->ttc_buffer = InvalidBuffer;
 
 	return slot;
@@ -406,7 +406,7 @@ ExecClearTuple(TupleTableSlot *slot)	/* slot in which to store tuple */
 	if (slot->ttc_shouldFree && oldtuple != NULL)
 		heap_freetuple(oldtuple);
 
-	slot->val = (HeapTuple) NULL;
+	slot->val = NULL;
 
 	slot->ttc_shouldFree = true;	/* probably useless code... */
 
diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c
index 03a4abbe2f54a78e2cc16be7b8a3d1d391fa81ff..6ffc8875f1950d16c14b7a21af7151ff61257ef7 100644
--- a/src/backend/executor/functions.c
+++ b/src/backend/executor/functions.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.76 2003/11/29 19:51:48 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.77 2004/01/07 18:56:26 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -47,7 +47,7 @@ typedef struct local_es
 	QueryDesc  *qd;				/* null unless status == RUN */
 } execution_state;
 
-#define LAST_POSTQUEL_COMMAND(es) ((es)->next == (execution_state *) NULL)
+#define LAST_POSTQUEL_COMMAND(es) ((es)->next == NULL)
 
 
 /*
@@ -259,7 +259,7 @@ init_sql_fcache(FmgrInfo *finfo)
 		}
 	}
 	else
-		argOidVect = (Oid *) NULL;
+		argOidVect = NULL;
 
 	tmp = SysCacheGetAttr(PROCOID,
 						  procedureTuple,
@@ -304,7 +304,7 @@ postquel_getnext(execution_state *es)
 	if (es->qd->operation == CMD_UTILITY)
 	{
 		ProcessUtility(es->qd->parsetree->utilityStmt, es->qd->dest, NULL);
-		return (TupleTableSlot *) NULL;
+		return NULL;
 	}
 
 	/*
@@ -358,7 +358,7 @@ postquel_sub_params(SQLFunctionCachePtr fcache,
 		paramLI[nargs].kind = PARAM_INVALID;
 	}
 	else
-		paramLI = (ParamListInfo) NULL;
+		paramLI = NULL;
 
 	if (fcache->paramLI)
 		pfree(fcache->paramLI);
@@ -551,7 +551,7 @@ fmgr_sql(PG_FUNCTION_ARGS)
 	/*
 	 * If we've gone through every command in this function, we are done.
 	 */
-	if (es == (execution_state *) NULL)
+	if (es == NULL)
 	{
 		/*
 		 * Reset the execution states to start over again on next call.
diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c
index 5dc61a1a1852ecd6a1f1d3c219e52ff55557b2f4..f0c1ee69e69bf8063142b9f98f683cfa9dd18e7c 100644
--- a/src/backend/executor/nodeHashjoin.c
+++ b/src/backend/executor/nodeHashjoin.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/executor/nodeHashjoin.c,v 1.59 2003/11/29 19:51:48 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/executor/nodeHashjoin.c,v 1.60 2004/01/07 18:56:26 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -405,10 +405,10 @@ ExecInitHashJoin(HashJoin *node, EState *estate)
 	 */
 
 	hjstate->hj_hashdone = false;
-	hjstate->hj_HashTable = (HashJoinTable) NULL;
+	hjstate->hj_HashTable = NULL;
 
 	hjstate->hj_CurBucketNo = 0;
-	hjstate->hj_CurTuple = (HashJoinTuple) NULL;
+	hjstate->hj_CurTuple = NULL;
 
 	/*
 	 * Deconstruct the hash clauses into outer and inner argument values,
@@ -733,9 +733,9 @@ ExecReScanHashJoin(HashJoinState *node, ExprContext *exprCtxt)
 
 	/* Always reset intra-tuple state */
 	node->hj_CurBucketNo = 0;
-	node->hj_CurTuple = (HashJoinTuple) NULL;
+	node->hj_CurTuple = NULL;
 
-	node->js.ps.ps_OuterTupleSlot = (TupleTableSlot *) NULL;
+	node->js.ps.ps_OuterTupleSlot = NULL;
 	node->js.ps.ps_TupFromTlist = false;
 	node->hj_NeedNewOuter = true;
 	node->hj_MatchedOuter = false;
diff --git a/src/backend/executor/nodeIndexscan.c b/src/backend/executor/nodeIndexscan.c
index 3a489b361c64742b0abd17e7c04a2b4f8113e503..d7c62110e930da7afe1efb9f5a486505abfce63f 100644
--- a/src/backend/executor/nodeIndexscan.c
+++ b/src/backend/executor/nodeIndexscan.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.89 2004/01/06 04:31:01 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.90 2004/01/07 18:56:26 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -758,9 +758,9 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
 		lossyflags = lfirst(indxlossy);
 		indxlossy = lnext(indxlossy);
 		n_keys = length(quals);
-		scan_keys = (n_keys <= 0) ? (ScanKey) NULL :
+		scan_keys = (n_keys <= 0) ? NULL :
 			(ScanKey) palloc(n_keys * sizeof(ScanKeyData));
-		run_keys = (n_keys <= 0) ? (ExprState **) NULL :
+		run_keys = (n_keys <= 0) ? NULL :
 			(ExprState **) palloc(n_keys * sizeof(ExprState *));
 
 		/*
diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c
index 0fbf3bf287fc743b26c414aa29b1708c692003a5..bbfcb1b454eca204394a56eb7717493e613d244b 100644
--- a/src/backend/nodes/readfuncs.c
+++ b/src/backend/nodes/readfuncs.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.163 2003/11/29 19:51:49 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.164 2004/01/07 18:56:26 neilc Exp $
  *
  * NOTES
  *	  Path and Plan nodes do not have any readfuncs support, because we
@@ -129,7 +129,7 @@
 #define strtobool(x)  ((*(x) == 't') ? true : false)
 
 #define nullable_string(token,length)  \
-	((length) == 0 ? (char *) NULL : debackslash(token, length))
+	((length) == 0 ? NULL : debackslash(token, length))
 
 
 static Datum readDatum(bool typbyval);
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
index a1030c8779c9f550ddcfd2c82af4284ca99a06ce..0f83f390715aeed5d7b0123c9e06f79f5628f685 100644
--- a/src/backend/optimizer/plan/createplan.c
+++ b/src/backend/optimizer/plan/createplan.c
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.165 2004/01/06 04:31:01 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.166 2004/01/07 18:56:26 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -2177,7 +2177,7 @@ make_agg(Query *root, List *tlist, List *qual,
 	plan->qual = qual;
 	plan->targetlist = tlist;
 	plan->lefttree = lefttree;
-	plan->righttree = (Plan *) NULL;
+	plan->righttree = NULL;
 
 	return node;
 }
@@ -2229,7 +2229,7 @@ make_group(Query *root,
 	plan->qual = NIL;
 	plan->targetlist = tlist;
 	plan->lefttree = lefttree;
-	plan->righttree = (Plan *) NULL;
+	plan->righttree = NULL;
 
 	return node;
 }
diff --git a/src/backend/optimizer/util/tlist.c b/src/backend/optimizer/util/tlist.c
index 8780ea6c2076321d8766d3f4cbb9e930c5e41b12..2c891c49644c72498400dc833997623ca23d8b18 100644
--- a/src/backend/optimizer/util/tlist.c
+++ b/src/backend/optimizer/util/tlist.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/optimizer/util/tlist.c,v 1.61 2003/11/29 19:51:51 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/optimizer/util/tlist.c,v 1.62 2004/01/07 18:56:26 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -58,7 +58,7 @@ matching_tlist_expr(Node *node, List *targetlist)
 	if (tlentry)
 		return tlentry->expr;
 
-	return (Node *) NULL;
+	return NULL;
 }
 #endif
 
@@ -76,7 +76,7 @@ tlist_member(Node *node, List *targetlist)
 	if (tlentry)
 		return tlentry->resdom;
 
-	return (Resdom *) NULL;
+	return NULL;
 }
 
 /*
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index a578e5d31167a880207c5e686aa541bfad4ebe84..fa7ba0ecde75fede76f92afbdad2d82e1c724c04 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.442 2004/01/06 23:55:18 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.443 2004/01/07 18:56:27 neilc Exp $
  *
  * HISTORY
  *	  AUTHOR			DATE			MAJOR EVENT
@@ -467,13 +467,13 @@ stmtblock:	stmtmulti								{ parsetree = $1; }
 
 /* the thrashing around here is to discard "empty" statements... */
 stmtmulti:	stmtmulti ';' stmt
-				{ if ($3 != (Node *)NULL)
+				{ if ($3 != NULL)
 					$$ = lappend($1, $3);
 				  else
 					$$ = $1;
 				}
 			| stmt
-					{ if ($1 != (Node *)NULL)
+					{ if ($1 != NULL)
 						$$ = makeList1($1);
 					  else
 						$$ = NIL;
@@ -553,7 +553,7 @@ stmt :
 			| VariableShowStmt
 			| ViewStmt
 			| /*EMPTY*/
-				{ $$ = (Node *)NULL; }
+				{ $$ = NULL; }
 		;
 
 /*****************************************************************************
@@ -1955,11 +1955,11 @@ OptSeqElem: CACHE NumericOnly
 				}
 			| NO MAXVALUE
 				{
-					$$ = makeDefElem("maxvalue", (Node *)NULL);
+					$$ = makeDefElem("maxvalue", NULL);
 				}
 			| NO MINVALUE
 				{
-					$$ = makeDefElem("minvalue", (Node *)NULL);
+					$$ = makeDefElem("minvalue", NULL);
 				}
 			| START opt_with NumericOnly
 				{
@@ -2371,7 +2371,7 @@ def_elem:  ColLabel '=' def_arg
 				}
 			| ColLabel
 				{
-					$$ = makeDefElem($1, (Node *)NULL);
+					$$ = makeDefElem($1, NULL);
 				}
 		;
 
@@ -3563,13 +3563,13 @@ RuleActionList:
 /* the thrashing around here is to discard "empty" statements... */
 RuleActionMulti:
 			RuleActionMulti ';' RuleActionStmtOrEmpty
-				{ if ($3 != (Node *) NULL)
+				{ if ($3 != NULL)
 					$$ = lappend($1, $3);
 				  else
 					$$ = $1;
 				}
 			| RuleActionStmtOrEmpty
-				{ if ($1 != (Node *) NULL)
+				{ if ($1 != NULL)
 					$$ = makeList1($1);
 				  else
 					$$ = NIL;
@@ -3586,7 +3586,7 @@ RuleActionStmt:
 
 RuleActionStmtOrEmpty:
 			RuleActionStmt							{ $$ = $1; }
-			|	/*EMPTY*/							{ $$ = (Node *)NULL; }
+			|	/*EMPTY*/							{ $$ = NULL; }
 		;
 
 /* change me to select, update, etc. some day */
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c
index 372be916ddb059c88f990a7252327be6fa9043fa..24b2fefe16af3ef0b1c01f67d71701a00a6a6cbb 100644
--- a/src/backend/parser/parse_func.c
+++ b/src/backend/parser/parse_func.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.164 2003/11/29 19:51:52 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.165 2004/01/07 18:56:27 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -993,7 +993,7 @@ argtype_inherit(int nargs, Oid *argtypes)
 		else
 		{
 			arginh[i].nsupers = 0;
-			arginh[i].supervec = (Oid *) NULL;
+			arginh[i].supervec = NULL;
 		}
 	}
 
@@ -1090,7 +1090,7 @@ find_inheritors(Oid relid, Oid **supervec)
 		}
 	}
 	else
-		*supervec = (Oid *) NULL;
+		*supervec = NULL;
 
 	freeList(visited);
 
diff --git a/src/backend/port/dynloader/darwin.c b/src/backend/port/dynloader/darwin.c
index 57ca0f3f38c834cfe8d6d22b8a5ec0b0ba8c11bf..72e9598dc1fa3f8e09867b1038cd2c6b2c1a1f2a 100644
--- a/src/backend/port/dynloader/darwin.c
+++ b/src/backend/port/dynloader/darwin.c
@@ -3,7 +3,7 @@
  * available with a PostgreSQL-compatible license.	Kudos Wilfredo
  * Sánchez <wsanchez@apple.com>.
  *
- * $PostgreSQL: pgsql/src/backend/port/dynloader/darwin.c,v 1.9 2003/11/29 19:51:54 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/port/dynloader/darwin.c,v 1.10 2004/01/07 18:56:27 neilc Exp $
  */
 #include "postgres.h"
 
@@ -50,7 +50,7 @@ pg_dlsym(void *handle, char *funcname)
 	else
 	{
 		free(symname);
-		return (PGFunction) NULL;
+		return NULL;
 	}
 }
 
diff --git a/src/backend/port/dynloader/freebsd.c b/src/backend/port/dynloader/freebsd.c
index 39fb7b48b8a262d0cc0cb89e089c5fda85cb672f..64688c6e93d608fe2dddcbc61d8554bbcf052702 100644
--- a/src/backend/port/dynloader/freebsd.c
+++ b/src/backend/port/dynloader/freebsd.c
@@ -52,7 +52,7 @@ BSD44_derived_dlerror(void)
 
 	strcpy(ret, error_message);
 	error_message[0] = 0;
-	return (ret[0] == 0) ? (char *) NULL : ret;
+	return (ret[0] == 0) ? NULL : ret;
 }
 
 void *
@@ -65,7 +65,7 @@ BSD44_derived_dlopen(const char *file, int num)
 #else
 	void	   *vp;
 
-	if ((vp = dlopen((char *) file, num)) == (void *) NULL)
+	if ((vp = dlopen((char *) file, num)) == NULL)
 		snprintf(error_message, sizeof(error_message),
 				 "dlopen '%s' failed. (%s)", file, dlerror());
 	return vp;
@@ -91,7 +91,7 @@ BSD44_derived_dlsym(void *handle, const char *name)
 		name = buf;
 	}
 #endif
-	if ((vp = dlsym(handle, (char *) name)) == (void *) NULL)
+	if ((vp = dlsym(handle, (char *) name)) == NULL)
 		snprintf(error_message, sizeof(error_message),
 				 "dlsym (%s) failed", name);
 	return vp;
diff --git a/src/backend/port/dynloader/netbsd.c b/src/backend/port/dynloader/netbsd.c
index 4b77049b3ba81b99038b6862d46c44f3871af855..81ae5607722adc9c7a8ae5250bfb7f1a60b7f94e 100644
--- a/src/backend/port/dynloader/netbsd.c
+++ b/src/backend/port/dynloader/netbsd.c
@@ -53,7 +53,7 @@ BSD44_derived_dlerror(void)
 
 	strcpy(ret, error_message);
 	error_message[0] = 0;
-	return (ret[0] == 0) ? (char *) NULL : ret;
+	return (ret[0] == 0) ? NULL : ret;
 }
 
 void *
@@ -66,7 +66,7 @@ BSD44_derived_dlopen(const char *file, int num)
 #else
 	void	   *vp;
 
-	if ((vp = dlopen((char *) file, num)) == (void *) NULL)
+	if ((vp = dlopen((char *) file, num)) == NULL)
 		snprintf(error_message, sizeof(error_message),
 				 "dlopen (%s) failed", file);
 	return vp;
@@ -91,7 +91,7 @@ BSD44_derived_dlsym(void *handle, const char *name)
 		snprintf(buf, sizeof(buf), "_%s", name);
 		name = buf;
 	}
-	if ((vp = dlsym(handle, (char *) name)) == (void *) NULL)
+	if ((vp = dlsym(handle, (char *) name)) == NULL)
 		snprintf(error_message, sizeof(error_message),
 				 "dlsym (%s) failed", name);
 	return vp;
diff --git a/src/backend/port/dynloader/openbsd.c b/src/backend/port/dynloader/openbsd.c
index 4b77049b3ba81b99038b6862d46c44f3871af855..81ae5607722adc9c7a8ae5250bfb7f1a60b7f94e 100644
--- a/src/backend/port/dynloader/openbsd.c
+++ b/src/backend/port/dynloader/openbsd.c
@@ -53,7 +53,7 @@ BSD44_derived_dlerror(void)
 
 	strcpy(ret, error_message);
 	error_message[0] = 0;
-	return (ret[0] == 0) ? (char *) NULL : ret;
+	return (ret[0] == 0) ? NULL : ret;
 }
 
 void *
@@ -66,7 +66,7 @@ BSD44_derived_dlopen(const char *file, int num)
 #else
 	void	   *vp;
 
-	if ((vp = dlopen((char *) file, num)) == (void *) NULL)
+	if ((vp = dlopen((char *) file, num)) == NULL)
 		snprintf(error_message, sizeof(error_message),
 				 "dlopen (%s) failed", file);
 	return vp;
@@ -91,7 +91,7 @@ BSD44_derived_dlsym(void *handle, const char *name)
 		snprintf(buf, sizeof(buf), "_%s", name);
 		name = buf;
 	}
-	if ((vp = dlsym(handle, (char *) name)) == (void *) NULL)
+	if ((vp = dlsym(handle, (char *) name)) == NULL)
 		snprintf(error_message, sizeof(error_message),
 				 "dlsym (%s) failed", name);
 	return vp;
diff --git a/src/backend/port/dynloader/qnx4.c b/src/backend/port/dynloader/qnx4.c
index 6a6c7e868aa3501738c6d7d6fda0634ef03475b1..c211ce68f431ec91dc7fee1e6cd3737597f0d566 100644
--- a/src/backend/port/dynloader/qnx4.c
+++ b/src/backend/port/dynloader/qnx4.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/port/dynloader/qnx4.c,v 1.5 2003/11/29 19:51:54 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/port/dynloader/qnx4.c,v 1.6 2004/01/07 18:56:27 neilc Exp $
  *
  *	NOTES
  *
@@ -28,7 +28,7 @@
 void *
 pg_dlopen(char *filename)
 {
-	return (void *) NULL;
+	return NULL;
 }
 
 PGFunction
diff --git a/src/backend/port/sysv_shmem.c b/src/backend/port/sysv_shmem.c
index f47b0709b3a4461d6742c315325a0c483cd7e3ad..519714938a1a6093ace0dee78cfcac88418339f5 100644
--- a/src/backend/port/sysv_shmem.c
+++ b/src/backend/port/sysv_shmem.c
@@ -10,7 +10,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.27 2003/12/01 22:15:37 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.28 2004/01/07 18:56:27 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -174,7 +174,7 @@ IpcMemoryDetach(int status, Datum shmaddr)
 static void
 IpcMemoryDelete(int status, Datum shmId)
 {
-	if (shmctl(DatumGetInt32(shmId), IPC_RMID, (struct shmid_ds *) NULL) < 0)
+	if (shmctl(DatumGetInt32(shmId), IPC_RMID, NULL) < 0)
 		elog(LOG, "shmctl(%d, %d, 0) failed: %m",
 			 DatumGetInt32(shmId), IPC_RMID);
 }
@@ -299,7 +299,7 @@ PGSharedMemoryCreate(uint32 size, bool makePrivate, int port)
 		 * quietly.
 		 */
 		shmdt(memAddress);
-		if (shmctl(shmid, IPC_RMID, (struct shmid_ds *) NULL) < 0)
+		if (shmctl(shmid, IPC_RMID, NULL) < 0)
 			continue;
 
 		/*
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 9d648b8067d25196476265bfc702f206dc525fe9..be645c343250aee6a9e401094d200f5e0b6e4b9f 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -37,7 +37,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.354 2004/01/06 23:15:22 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.355 2004/01/07 18:56:27 neilc Exp $
  *
  * NOTES
  *
@@ -167,7 +167,7 @@ int			MaxBackends;
 int			ReservedBackends;
 
 
-static char *progname = (char *) NULL;
+static char *progname = NULL;
 
 /* The socket(s) we're listening to. */
 #define MAXLISTEN	10
@@ -1082,8 +1082,7 @@ ServerLoop(void)
 
 		PG_SETMASK(&UnBlockSig);
 
-		if (select(nSockets, &rmask, (fd_set *) NULL,
-				   (fd_set *) NULL, &timeout) < 0)
+		if (select(nSockets, &rmask, NULL, NULL, &timeout) < 0)
 		{
 			PG_SETMASK(&BlockSig);
 			if (errno == EINTR || errno == EWOULDBLOCK)
@@ -2583,7 +2582,7 @@ BackendRun(Port *port)
 	if (port->cmdline_options)
 		split_opts(av, &ac, port->cmdline_options);
 
-	av[ac] = (char *) NULL;
+	av[ac] = NULL;
 
 	Assert(ac < maxac);
 
@@ -3038,7 +3037,7 @@ SSDataBase(int xlop)
 		av[ac++] = "template1";
 #endif
 
-		av[ac] = (char *) NULL;
+		av[ac] = NULL;
 
 		Assert(ac < lengthof(av));
 
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index 1ac603e68df040c6105f990c5cd10afe78dabebf..285617678a1b3a9e6a92c69f6f59943f3f00ba79 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.150 2003/12/20 22:18:02 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.151 2004/01/07 18:56:27 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -372,7 +372,7 @@ BufferAlloc(Relation reln,
 	 * it to disk. Remember to unlock BufMgrLock while doing the IOs.
 	 */
 	inProgress = FALSE;
-	for (buf = (BufferDesc *) NULL; buf == (BufferDesc *) NULL;)
+	for (buf = NULL; buf == NULL;)
 	{
 		buf = StrategyGetBuffer();
 
@@ -399,7 +399,7 @@ BufferAlloc(Relation reln,
 			if ((buf->flags & BM_IO_ERROR) != 0)
 			{
 				UnpinBuffer(buf);
-				buf = (BufferDesc *) NULL;
+				buf = NULL;
 				continue;
 			}
 
@@ -440,7 +440,7 @@ BufferAlloc(Relation reln,
 				buf->flags &= ~BM_IO_IN_PROGRESS;
 				TerminateBufferIO(buf);
 				UnpinBuffer(buf);
-				buf = (BufferDesc *) NULL;
+				buf = NULL;
 			}
 			else
 			{
@@ -476,7 +476,7 @@ BufferAlloc(Relation reln,
 				buf->flags &= ~BM_IO_IN_PROGRESS;
 				TerminateBufferIO(buf);
 				UnpinBuffer(buf);
-				buf = (BufferDesc *) NULL;
+				buf = NULL;
 			}
 
 			/*
@@ -799,7 +799,7 @@ BufferSync(int percent, int maxpages)
 		bufHdr->flags &= ~BM_JUST_DIRTIED;
 		LWLockRelease(BufMgrLock);
 
-		if (reln == (Relation) NULL)
+		if (reln == NULL)
 		{
 			status = smgrblindwrt(DEFAULT_SMGR,
 								  bufHdr->tag.rnode,
@@ -849,7 +849,7 @@ BufferSync(int percent, int maxpages)
 		LWLockRelease(BufMgrLock);
 
 		/* drop refcnt obtained by RelationNodeCacheGetRelation */
-		if (reln != (Relation) NULL)
+		if (reln != NULL)
 			RelationDecrementReferenceCount(reln);
 	}
 
@@ -1105,7 +1105,7 @@ BufferReplace(BufferDesc *bufHdr)
 
 	reln = RelationNodeCacheGetRelation(bufHdr->tag.rnode);
 
-	if (reln != (Relation) NULL)
+	if (reln != NULL)
 	{
 		status = smgrwrite(DEFAULT_SMGR, reln,
 						   bufHdr->tag.blockNum,
@@ -1119,7 +1119,7 @@ BufferReplace(BufferDesc *bufHdr)
 	}
 
 	/* drop relcache refcnt incremented by RelationNodeCacheGetRelation */
-	if (reln != (Relation) NULL)
+	if (reln != NULL)
 		RelationDecrementReferenceCount(reln);
 
 	/* Pop the error context stack */
@@ -1949,7 +1949,7 @@ LockBufferForCleanup(Buffer buffer)
  *	Note : We assume that nested buffer IO never occur.
  *	i.e at most one io_in_progress lock is held per proc.
 */
-static BufferDesc *InProgressBuf = (BufferDesc *) NULL;
+static BufferDesc *InProgressBuf = NULL;
 static bool IsForInput;
 
 /*
@@ -1991,7 +1991,7 @@ TerminateBufferIO(BufferDesc *buf)
 {
 	Assert(buf == InProgressBuf);
 	LWLockRelease(buf->io_in_progress_lock);
-	InProgressBuf = (BufferDesc *) NULL;
+	InProgressBuf = NULL;
 }
 
 /*
@@ -2016,7 +2016,7 @@ ContinueBufferIO(BufferDesc *buf, bool forInput)
 void
 InitBufferIO(void)
 {
-	InProgressBuf = (BufferDesc *) NULL;
+	InProgressBuf = NULL;
 }
 #endif
 
diff --git a/src/backend/storage/buffer/localbuf.c b/src/backend/storage/buffer/localbuf.c
index fe282a8c66aa7b9f214964da8f1ffcd0551eff0d..01c8303928055e49a61bd38a1b983e701b708998 100644
--- a/src/backend/storage/buffer/localbuf.c
+++ b/src/backend/storage/buffer/localbuf.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/storage/buffer/localbuf.c,v 1.50 2003/11/29 19:51:56 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/storage/buffer/localbuf.c,v 1.51 2004/01/07 18:56:27 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -41,7 +41,7 @@ BufferDesc *
 LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
 {
 	int			i;
-	BufferDesc *bufHdr = (BufferDesc *) NULL;
+	BufferDesc *bufHdr = NULL;
 
 	/* a low tech search for now -- not optimized for scans */
 	for (i = 0; i < NLocBuffer; i++)
@@ -93,7 +93,7 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
 		Relation	bufrel = RelationNodeCacheGetRelation(bufHdr->tag.rnode);
 
 		/* flush this page */
-		if (bufrel == (Relation) NULL)
+		if (bufrel == NULL)
 		{
 			smgrblindwrt(DEFAULT_SMGR,
 						 bufHdr->tag.rnode,
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
index dfd6d16cca21a007a30160e1d5fb405eda1390fb..682cc741f3562c6d213d073721cdc85845bfc83d 100644
--- a/src/backend/storage/lmgr/proc.c
+++ b/src/backend/storage/lmgr/proc.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.143 2003/12/25 03:52:51 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.144 2004/01/07 18:56:27 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -745,7 +745,7 @@ ProcWakeup(PGPROC *proc, int errType)
 	/* Proc should be sleeping ... */
 	if (proc->links.prev == INVALID_OFFSET ||
 		proc->links.next == INVALID_OFFSET)
-		return (PGPROC *) NULL;
+		return NULL;
 
 	/* Save next process before we zap the list link */
 	retProc = (PGPROC *) MAKE_PTR(proc->links.next);
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
index f3ac6f4d1a1d7517bfc9610d8138942b168d29ad..0405c2849a0b8d201edbec9c4e0cda91e46f2927 100644
--- a/src/backend/storage/smgr/md.c
+++ b/src/backend/storage/smgr/md.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.100 2004/01/06 18:07:31 neilc Exp $
+ *	  $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.101 2004/01/07 18:56:27 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -60,7 +60,7 @@ typedef struct _MdfdVec
 } MdfdVec;
 
 static int	Nfds = 100;			/* initial/current size of Md_fdvec array */
-static MdfdVec *Md_fdvec = (MdfdVec *) NULL;
+static MdfdVec *Md_fdvec = NULL;
 static int	Md_Free = -1;		/* head of freelist of unused fdvec
 								 * entries */
 static int	CurFd = 0;			/* first never-used fdvec index */
@@ -158,7 +158,7 @@ mdcreate(Relation reln)
 	Md_fdvec[vfd].mdfd_vfd = fd;
 	Md_fdvec[vfd].mdfd_flags = (uint16) 0;
 #ifndef LET_OS_MANAGE_FILESIZE
-	Md_fdvec[vfd].mdfd_chain = (MdfdVec *) NULL;
+	Md_fdvec[vfd].mdfd_chain = NULL;
 #endif
 
 	return vfd;
@@ -322,7 +322,7 @@ mdopen(Relation reln)
 	Md_fdvec[vfd].mdfd_vfd = fd;
 	Md_fdvec[vfd].mdfd_flags = (uint16) 0;
 #ifndef LET_OS_MANAGE_FILESIZE
-	Md_fdvec[vfd].mdfd_chain = (MdfdVec *) NULL;
+	Md_fdvec[vfd].mdfd_chain = NULL;
 	Assert(_mdnblocks(fd, BLCKSZ) <= ((BlockNumber) RELSEG_SIZE));
 #endif
 
@@ -359,7 +359,7 @@ mdclose_fd(int fd)
 	MdfdVec    *v;
 
 #ifndef LET_OS_MANAGE_FILESIZE
-	for (v = &Md_fdvec[fd]; v != (MdfdVec *) NULL;)
+	for (v = &Md_fdvec[fd]; v != NULL;)
 	{
 		MdfdVec    *ov = v;
 
@@ -372,10 +372,10 @@ mdclose_fd(int fd)
 			pfree(ov);
 	}
 
-	Md_fdvec[fd].mdfd_chain = (MdfdVec *) NULL;
+	Md_fdvec[fd].mdfd_chain = NULL;
 #else
 	v = &Md_fdvec[fd];
-	if (v != (MdfdVec *) NULL)
+	if (v != NULL)
 	{
 		if (v->mdfd_vfd >= 0)
 			FileClose(v->mdfd_vfd);
@@ -553,7 +553,7 @@ mdnblocks(Relation reln)
 	 * levels to handle that scenario by closing and re-opening the md
 	 * fd.)
 	 */
-	while (v->mdfd_chain != (MdfdVec *) NULL)
+	while (v->mdfd_chain != NULL)
 	{
 		segno++;
 		v = v->mdfd_chain;
@@ -572,7 +572,7 @@ mdnblocks(Relation reln)
 		 */
 		segno++;
 
-		if (v->mdfd_chain == (MdfdVec *) NULL)
+		if (v->mdfd_chain == NULL)
 		{
 			/*
 			 * Because we pass O_CREAT, we will create the next segment
@@ -582,7 +582,7 @@ mdnblocks(Relation reln)
 			 * worth.
 			 */
 			v->mdfd_chain = _mdfd_openseg(reln, segno, O_CREAT);
-			if (v->mdfd_chain == (MdfdVec *) NULL)
+			if (v->mdfd_chain == NULL)
 				elog(ERROR, "could not count blocks of \"%s\": %m",
 					 RelationGetRelationName(reln));
 		}
@@ -625,7 +625,7 @@ mdtruncate(Relation reln, BlockNumber nblocks)
 
 #ifndef LET_OS_MANAGE_FILESIZE
 	priorblocks = 0;
-	while (v != (MdfdVec *) NULL)
+	while (v != NULL)
 	{
 		MdfdVec    *ov = v;
 
@@ -660,7 +660,7 @@ mdtruncate(Relation reln, BlockNumber nblocks)
 			if (FileTruncate(v->mdfd_vfd, lastsegblocks * BLCKSZ) < 0)
 				return InvalidBlockNumber;
 			v = v->mdfd_chain;
-			ov->mdfd_chain = (MdfdVec *) NULL;
+			ov->mdfd_chain = NULL;
 		}
 		else
 		{
@@ -815,7 +815,7 @@ _mdfd_openseg(Relation reln, BlockNumber segno, int oflags)
 	pfree(fullpath);
 
 	if (fd < 0)
-		return (MdfdVec *) NULL;
+		return NULL;
 
 	/* allocate an mdfdvec entry for it */
 	v = (MdfdVec *) MemoryContextAlloc(MdCxt, sizeof(MdfdVec));
@@ -824,7 +824,7 @@ _mdfd_openseg(Relation reln, BlockNumber segno, int oflags)
 	v->mdfd_vfd = fd;
 	v->mdfd_flags = (uint16) 0;
 #ifndef LET_OS_MANAGE_FILESIZE
-	v->mdfd_chain = (MdfdVec *) NULL;
+	v->mdfd_chain = NULL;
 	Assert(_mdnblocks(fd, BLCKSZ) <= ((BlockNumber) RELSEG_SIZE));
 #endif
 
@@ -877,7 +877,7 @@ _mdfd_getseg(Relation reln, BlockNumber blkno)
 		 i++, segno--)
 	{
 
-		if (v->mdfd_chain == (MdfdVec *) NULL)
+		if (v->mdfd_chain == NULL)
 		{
 			/*
 			 * We will create the next segment only if the target block is
@@ -891,7 +891,7 @@ _mdfd_getseg(Relation reln, BlockNumber blkno)
 			 */
 			v->mdfd_chain = _mdfd_openseg(reln, i, (segno == 1) ? O_CREAT : 0);
 
-			if (v->mdfd_chain == (MdfdVec *) NULL)
+			if (v->mdfd_chain == NULL)
 				elog(ERROR, "could not open segment %u of relation \"%s\" (target block %u): %m",
 					 i, RelationGetRelationName(reln), blkno);
 		}
diff --git a/src/backend/storage/smgr/mm.c b/src/backend/storage/smgr/mm.c
index 233b1a981713d92d932eed349b75c6a9cfd14289..5043fd66a577f98331a93daa104c23e1560df515 100644
--- a/src/backend/storage/smgr/mm.c
+++ b/src/backend/storage/smgr/mm.c
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/storage/smgr/mm.c,v 1.35 2003/11/29 19:51:57 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/storage/smgr/mm.c,v 1.36 2004/01/07 18:56:27 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -96,7 +96,7 @@ mminit(void)
 	mmsize += MAXALIGN((MMNBUFFERS * sizeof(MMCacheTag)));
 	mmcacheblk = (char *) ShmemInitStruct("Main memory smgr", mmsize, &found);
 
-	if (mmcacheblk == (char *) NULL)
+	if (mmcacheblk == NULL)
 	{
 		LWLockRelease(MMCacheLock);
 		return SM_FAIL;
@@ -110,7 +110,7 @@ mminit(void)
 							  MMNBUFFERS, MMNBUFFERS,
 							  &info, (HASH_ELEM | HASH_FUNCTION));
 
-	if (MMCacheHT == (HTAB *) NULL)
+	if (MMCacheHT == NULL)
 	{
 		LWLockRelease(MMCacheLock);
 		return SM_FAIL;
@@ -124,7 +124,7 @@ mminit(void)
 								 MMNRELATIONS, MMNRELATIONS,
 								 &info, (HASH_ELEM | HASH_FUNCTION));
 
-	if (MMRelCacheHT == (HTAB *) NULL)
+	if (MMRelCacheHT == NULL)
 	{
 		LWLockRelease(MMCacheLock);
 		return SM_FAIL;
@@ -183,7 +183,7 @@ mmcreate(Relation reln)
 										   (void *) &tag,
 										   HASH_ENTER, &found);
 
-	if (entry == (MMRelHashEntry *) NULL)
+	if (entry == NULL)
 	{
 		LWLockRelease(MMCacheLock);
 		ereport(FATAL,
@@ -228,7 +228,7 @@ mmunlink(RelFileNode rnode)
 			entry = (MMHashEntry *) hash_search(MMCacheHT,
 												(void *) &MMBlockTags[i],
 												HASH_REMOVE, NULL);
-			if (entry == (MMHashEntry *) NULL)
+			if (entry == NULL)
 			{
 				LWLockRelease(MMCacheLock);
 				elog(FATAL, "cache hash table corrupted");
@@ -245,7 +245,7 @@ mmunlink(RelFileNode rnode)
 											(void *) &rtag,
 											HASH_REMOVE, NULL);
 
-	if (rentry == (MMRelHashEntry *) NULL)
+	if (rentry == NULL)
 	{
 		LWLockRelease(MMCacheLock);
 		elog(FATAL, "rel cache hash table corrupted");
@@ -308,7 +308,7 @@ mmextend(Relation reln, BlockNumber blocknum, char *buffer)
 	rentry = (MMRelHashEntry *) hash_search(MMRelCacheHT,
 											(void *) &rtag,
 											HASH_FIND, NULL);
-	if (rentry == (MMRelHashEntry *) NULL)
+	if (rentry == NULL)
 	{
 		LWLockRelease(MMCacheLock);
 		elog(FATAL, "rel cache hash table corrupted");
@@ -319,7 +319,7 @@ mmextend(Relation reln, BlockNumber blocknum, char *buffer)
 	entry = (MMHashEntry *) hash_search(MMCacheHT,
 										(void *) &tag,
 										HASH_ENTER, &found);
-	if (entry == (MMHashEntry *) NULL || found)
+	if (entry == NULL || found)
 	{
 		LWLockRelease(MMCacheLock);
 		elog(FATAL, "cache hash table corrupted");
@@ -389,7 +389,7 @@ mmread(Relation reln, BlockNumber blocknum, char *buffer)
 										(void *) &tag,
 										HASH_FIND, NULL);
 
-	if (entry == (MMHashEntry *) NULL)
+	if (entry == NULL)
 	{
 		/* reading nonexistent pages is defined to fill them with zeroes */
 		LWLockRelease(MMCacheLock);
@@ -430,7 +430,7 @@ mmwrite(Relation reln, BlockNumber blocknum, char *buffer)
 										(void *) &tag,
 										HASH_FIND, NULL);
 
-	if (entry == (MMHashEntry *) NULL)
+	if (entry == NULL)
 	{
 		LWLockRelease(MMCacheLock);
 		elog(FATAL, "cache hash table missing requested page");
diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c
index 7d3a7ad3d5b479d1d1ff87649ea1590c6c1d074b..856a9e8589e75401de264b18bd215075d9a3f531 100644
--- a/src/backend/tcop/fastpath.c
+++ b/src/backend/tcop/fastpath.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.70 2003/11/29 19:51:57 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.71 2004/01/07 18:56:27 neilc Exp $
  *
  * NOTES
  *	  This cruft is the server side of PQfn.
@@ -206,7 +206,7 @@ fetch_fp_info(Oid func_id, struct fp_info * fip)
 	Form_pg_proc pp;
 
 	Assert(OidIsValid(func_id));
-	Assert(fip != (struct fp_info *) NULL);
+	Assert(fip != NULL);
 
 	/*
 	 * Since the validity of this structure is determined by whether the
diff --git a/src/backend/utils/Gen_fmgrtab.sh b/src/backend/utils/Gen_fmgrtab.sh
index d4f8cc8ba87ad7a00ddba0bd65137408d9a79d5d..dc302ddbd92236b30e9f42134ea7cdaf775f1342 100644
--- a/src/backend/utils/Gen_fmgrtab.sh
+++ b/src/backend/utils/Gen_fmgrtab.sh
@@ -9,7 +9,7 @@
 #
 #
 # IDENTIFICATION
-#    $PostgreSQL: pgsql/src/backend/utils/Gen_fmgrtab.sh,v 1.28 2004/01/04 05:57:21 tgl Exp $
+#    $PostgreSQL: pgsql/src/backend/utils/Gen_fmgrtab.sh,v 1.29 2004/01/07 18:56:28 neilc Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -223,7 +223,7 @@ cat >> "$$-$TABLEFILE" <<FuNkYfMgRtAbStUfF
   /* dummy entry is easier than getting rid of comma after last real one */
   /* (not that there has ever been anything wrong with *having* a
      comma after the last field in an array initializer) */
-  { 0, NULL, 0, false, false, (PGFunction) NULL }
+  { 0, NULL, 0, false, false, NULL }
 };
 
 /* Note fmgr_nbuiltins excludes the dummy entry */
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c
index 94a5de09d90560bd773b9c3940cb8071da360343..ba734a0975269844d8a8495dffc76be6f07c7470 100644
--- a/src/backend/utils/adt/arrayfuncs.c
+++ b/src/backend/utils/adt/arrayfuncs.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.101 2003/11/29 19:51:57 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.102 2004/01/07 18:56:28 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -307,10 +307,8 @@ array_in(PG_FUNCTION_ARGS)
 	retval->size = nbytes;
 	retval->ndim = ndim;
 	retval->elemtype = element_type;
-	memcpy((char *) ARR_DIMS(retval), (char *) dim,
-		   ndim * sizeof(int));
-	memcpy((char *) ARR_LBOUND(retval), (char *) lBound,
-		   ndim * sizeof(int));
+	memcpy(ARR_DIMS(retval), dim, ndim * sizeof(int));
+	memcpy(ARR_LBOUND(retval), lBound, ndim * sizeof(int));
 
 	CopyArrayEls(ARR_DATA_PTR(retval), dataPtr, nitems,
 				 typlen, typbyval, typalign, true);
@@ -972,10 +970,8 @@ array_recv(PG_FUNCTION_ARGS)
 	retval->size = nbytes;
 	retval->ndim = ndim;
 	retval->elemtype = element_type;
-	memcpy((char *) ARR_DIMS(retval), (char *) dim,
-		   ndim * sizeof(int));
-	memcpy((char *) ARR_LBOUND(retval), (char *) lBound,
-		   ndim * sizeof(int));
+	memcpy(ARR_DIMS(retval), dim, ndim * sizeof(int));
+	memcpy(ARR_LBOUND(retval), lBound, ndim * sizeof(int));
 
 	CopyArrayEls(ARR_DATA_PTR(retval), dataPtr, nitems,
 				 typlen, typbyval, typalign, true);
@@ -1384,7 +1380,7 @@ array_ref(ArrayType *array,
 	char	   *arraydataptr,
 			   *retptr;
 
-	if (array == (ArrayType *) NULL)
+	if (array == NULL)
 		RETURN_NULL(Datum);
 
 	if (arraylen > 0)
@@ -1463,7 +1459,7 @@ array_get_slice(ArrayType *array,
 	int			bytes,
 				span[MAXDIM];
 
-	if (array == (ArrayType *) NULL)
+	if (array == NULL)
 		RETURN_NULL(ArrayType *);
 
 	if (arraylen > 0)
@@ -1602,7 +1598,7 @@ array_set(ArrayType *array,
 				lenbefore,
 				lenafter;
 
-	if (array == (ArrayType *) NULL)
+	if (array == NULL)
 		RETURN_NULL(ArrayType *);
 
 	if (arraylen > 0)
@@ -1798,9 +1794,9 @@ array_set_slice(ArrayType *array,
 				lenbefore,
 				lenafter;
 
-	if (array == (ArrayType *) NULL)
+	if (array == NULL)
 		RETURN_NULL(ArrayType *);
-	if (srcArray == (ArrayType *) NULL)
+	if (srcArray == NULL)
 		return array;
 
 	if (arraylen > 0)
@@ -2279,8 +2275,8 @@ construct_md_array(Datum *elems,
 	result->ndim = ndims;
 	result->flags = 0;
 	result->elemtype = elmtype;
-	memcpy((char *) ARR_DIMS(result), (char *) dims, ndims * sizeof(int));
-	memcpy((char *) ARR_LBOUND(result), (char *) lbs, ndims * sizeof(int));
+	memcpy(ARR_DIMS(result), dims, ndims * sizeof(int));
+	memcpy(ARR_LBOUND(result), lbs, ndims * sizeof(int));
 	CopyArrayEls(ARR_DATA_PTR(result), elems, nelems,
 				 elmlen, elmbyval, elmalign, false);
 
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index d808ac90e25d66b8754cc1044824d64faa241976..25db1b0f5d3fb5dd55e0d4b5f3dc515fc5602ff5 100644
--- a/src/backend/utils/adt/formatting.c
+++ b/src/backend/utils/adt/formatting.c
@@ -1,7 +1,7 @@
 /* -----------------------------------------------------------------------
  * formatting.c
  *
- * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.71 2003/12/25 03:36:23 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.72 2004/01/07 18:56:28 neilc Exp $
  *
  *
  *	 Portions Copyright (c) 1999-2003, PostgreSQL Global Development Group
@@ -927,7 +927,7 @@ index_seq_search(char *str, KeyWord *kw, int *index)
 	int			poz;
 
 	if (!KeyWord_INDEX_FILTER(*str))
-		return (KeyWord *) NULL;
+		return NULL;
 
 	if ((poz = *(index + (*str - ' '))) > -1)
 	{
@@ -940,10 +940,10 @@ index_seq_search(char *str, KeyWord *kw, int *index)
 				return k;
 			k++;
 			if (!k->name)
-				return (KeyWord *) NULL;
+				return NULL;
 		} while (*str == *k->name);
 	}
-	return (KeyWord *) NULL;
+	return NULL;
 }
 
 static KeySuffix *
@@ -959,7 +959,7 @@ suff_search(char *str, KeySuffix *suf, int type)
 		if (!strncmp(str, s->name, s->len))
 			return s;
 	}
-	return (KeySuffix *) NULL;
+	return NULL;
 }
 
 /* ----------
@@ -1246,7 +1246,7 @@ parse_format(FormatNode *node, char *str, KeyWord *kw,
 					}
 					n->type = NODE_TYPE_CHAR;
 					n->character = *str;
-					n->key = (KeyWord *) NULL;
+					n->key = NULL;
 					n->suffix = 0;
 					++n;
 					x = *str;
@@ -1266,7 +1266,7 @@ parse_format(FormatNode *node, char *str, KeyWord *kw,
 			{
 				n->type = NODE_TYPE_CHAR;
 				n->character = *str;
-				n->key = (KeyWord *) NULL;
+				n->key = NULL;
 				node_set = 1;
 				last = 0;
 				str++;
@@ -2731,7 +2731,7 @@ DCH_cache_getnew(char *str)
 		return ent;
 	}
 
-	return (DCHCacheEntry *) NULL;		/* never */
+	return NULL;		/* never */
 }
 
 static DCHCacheEntry *
@@ -2761,7 +2761,7 @@ DCH_cache_search(char *str)
 		i++;
 	}
 
-	return (DCHCacheEntry *) NULL;
+	return NULL;
 }
 
 static text *
@@ -3362,7 +3362,7 @@ NUM_cache_search(char *str)
 		i++;
 	}
 
-	return (NUMCacheEntry *) NULL;
+	return NULL;
 }
 
 static void
diff --git a/src/backend/utils/adt/numutils.c b/src/backend/utils/adt/numutils.c
index 2f004af28717d449d23dd3490323924f6b567dba..d169be8bd09a927b0721af7f14742056049e1631 100644
--- a/src/backend/utils/adt/numutils.c
+++ b/src/backend/utils/adt/numutils.c
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/utils/adt/numutils.c,v 1.59 2003/11/29 19:51:59 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/utils/adt/numutils.c,v 1.60 2004/01/07 18:56:28 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -64,7 +64,7 @@ pg_atoi(char *s, int size, int c)
 	 * Some versions of strtol treat the empty string as an error, but
 	 * some seem not to.  Make an explicit test to be sure we catch it.
 	 */
-	if (s == (char *) NULL)
+	if (s == NULL)
 		elog(ERROR, "NULL pointer");
 	if (*s == 0)
 		ereport(ERROR,
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c
index 71fa86fc1e70dcfc67fcb86680b8e4b838d294e5..73aab9e57813ff2d0923198e7ca296986e13e4c0 100644
--- a/src/backend/utils/adt/ri_triggers.c
+++ b/src/backend/utils/adt/ri_triggers.c
@@ -17,7 +17,7 @@
  *
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.65 2003/11/29 19:51:59 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.66 2004/01/07 18:56:28 neilc Exp $
  *
  * ----------
  */
@@ -114,7 +114,7 @@ typedef struct RI_QueryHashEntry
  * Local data
  * ----------
  */
-static HTAB *ri_query_cache = (HTAB *) NULL;
+static HTAB *ri_query_cache = NULL;
 
 
 /* ----------
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index 93e8040b9b512b763db5173b8309e43381c50a72..bc5e8c799b6cf07dfea5334f39bdb1d28e5e6927 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -15,7 +15,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.153 2004/01/05 23:39:54 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.154 2004/01/07 18:56:28 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -3822,7 +3822,7 @@ make_greater_string(const Const *str_const)
 	if (workstr != NULL)
 		pfree(workstr);
 
-	return (Const *) NULL;
+	return NULL;
 }
 
 /*
diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c
index dd0f84af61dbecae6e55bd95da5cb2f66675a59b..6c690f7b380062554b3aeeb916be28b788189e1f 100644
--- a/src/backend/utils/fmgr/dfmgr.c
+++ b/src/backend/utils/fmgr/dfmgr.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.67 2003/11/29 19:52:01 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.68 2004/01/07 18:56:29 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -40,8 +40,8 @@ typedef struct df_files
 	 */
 } DynamicFileList;
 
-static DynamicFileList *file_list = (DynamicFileList *) NULL;
-static DynamicFileList *file_tail = (DynamicFileList *) NULL;
+static DynamicFileList *file_list = NULL;
+static DynamicFileList *file_tail = NULL;
 
 #define SAME_INODE(A,B) ((A).st_ino == (B).inode && (A).st_dev == (B).device)
 
@@ -84,11 +84,11 @@ load_external_function(char *filename, char *funcname,
 	 * Scan the list of loaded FILES to see if the file has been loaded.
 	 */
 	for (file_scanner = file_list;
-		 file_scanner != (DynamicFileList *) NULL &&
+		 file_scanner != NULL &&
 		 strcmp(fullname, file_scanner->filename) != 0;
 		 file_scanner = file_scanner->next)
 		;
-	if (file_scanner == (DynamicFileList *) NULL)
+	if (file_scanner == NULL)
 	{
 		/*
 		 * Check for same files - different paths (ie, symlink or link)
@@ -100,13 +100,13 @@ load_external_function(char *filename, char *funcname,
 							fullname)));
 
 		for (file_scanner = file_list;
-			 file_scanner != (DynamicFileList *) NULL &&
+			 file_scanner != NULL &&
 			 !SAME_INODE(stat_buf, *file_scanner);
 			 file_scanner = file_scanner->next)
 			;
 	}
 
-	if (file_scanner == (DynamicFileList *) NULL)
+	if (file_scanner == NULL)
 	{
 		/*
 		 * File not loaded yet.
@@ -122,10 +122,10 @@ load_external_function(char *filename, char *funcname,
 		strcpy(file_scanner->filename, fullname);
 		file_scanner->device = stat_buf.st_dev;
 		file_scanner->inode = stat_buf.st_ino;
-		file_scanner->next = (DynamicFileList *) NULL;
+		file_scanner->next = NULL;
 
 		file_scanner->handle = pg_dlopen(fullname);
-		if (file_scanner->handle == (void *) NULL)
+		if (file_scanner->handle == NULL)
 		{
 			load_error = (char *) pg_dlerror();
 			free((char *) file_scanner);
@@ -137,7 +137,7 @@ load_external_function(char *filename, char *funcname,
 		}
 
 		/* OK to link it into list */
-		if (file_list == (DynamicFileList *) NULL)
+		if (file_list == NULL)
 			file_list = file_scanner;
 		else
 			file_tail->next = file_scanner;
@@ -151,15 +151,15 @@ load_external_function(char *filename, char *funcname,
 	/*
 	 * If funcname is NULL, we only wanted to load the file.
 	 */
-	if (funcname == (char *) NULL)
+	if (funcname == NULL)
 	{
 		pfree(fullname);
-		return (PGFunction) NULL;
+		return NULL;
 	}
 
 	retval = pg_dlsym(file_scanner->handle, funcname);
 
-	if (retval == (PGFunction) NULL && signalNotFound)
+	if (retval == NULL && signalNotFound)
 		ereport(ERROR,
 				(errcode(ERRCODE_UNDEFINED_FUNCTION),
 				 errmsg("could not find function \"%s\" in file \"%s\"",
@@ -221,7 +221,7 @@ load_file(char *filename)
 			prv = file_scanner;
 	}
 
-	load_external_function(fullname, (char *) NULL, false, (void *) NULL);
+	load_external_function(fullname, NULL, false, NULL);
 
 	pfree(fullname);
 }
diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c
index c42dfba32b54dfb7633f4805a6958f7dd9b47538..82f84bdd4e2aa7ccc5c141a9023a7f77991e9425 100644
--- a/src/backend/utils/fmgr/fmgr.c
+++ b/src/backend/utils/fmgr/fmgr.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.78 2004/01/06 23:55:19 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.79 2004/01/07 18:56:29 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -93,7 +93,7 @@ fmgr_isbuiltin(Oid id)
 		else
 			high = i - 1;
 	}
-	return (const FmgrBuiltin *) NULL;
+	return NULL;
 }
 
 /*
@@ -111,7 +111,7 @@ fmgr_lookupByName(const char *name)
 		if (strcmp(name, fmgr_builtins[i].funcName) == 0)
 			return fmgr_builtins + i;
 	}
-	return (const FmgrBuiltin *) NULL;
+	return NULL;
 }
 
 /*
@@ -384,7 +384,7 @@ fetch_finfo_record(void *filehandle, char *funcname)
 	/* Try to look up the info function */
 	infofunc = (PGFInfoFunction) lookup_external_function(filehandle,
 														  infofuncname);
-	if (infofunc == (PGFInfoFunction) NULL)
+	if (infofunc == NULL)
 	{
 		/* Not found --- assume version 0 */
 		pfree(infofuncname);
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c
index 0953ebb6e4ca2fbfe400af81860502e0c40427ec..e540f99e83f31bec5667388e107fb201584bcee4 100644
--- a/src/interfaces/ecpg/ecpglib/execute.c
+++ b/src/interfaces/ecpg/ecpglib/execute.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.30 2003/12/03 08:49:17 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.31 2004/01/07 18:56:29 neilc Exp $ */
 
 /*
  * The aim is to get a simpler inteface to the database routines.
@@ -190,7 +190,7 @@ free_variable(struct variable * var)
 {
 	struct variable *var_next;
 
-	if (var == (struct variable *) NULL)
+	if (var == NULL)
 		return;
 	var_next = var->next;
 	ECPGfree(var);
@@ -206,7 +206,7 @@ free_variable(struct variable * var)
 static void
 free_statement(struct statement * stmt)
 {
-	if (stmt == (struct statement *) NULL)
+	if (stmt == NULL)
 		return;
 	free_variable(stmt->inlist);
 	free_variable(stmt->outlist);
diff --git a/src/interfaces/libpgtcl/pgtcl.c b/src/interfaces/libpgtcl/pgtcl.c
index f6e625048c7d1ff4ac34ea63c7d35bce935a26d9..7c4432e9221ce79e096407dc7041e0cc262a9d20 100644
--- a/src/interfaces/libpgtcl/pgtcl.c
+++ b/src/interfaces/libpgtcl/pgtcl.c
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/interfaces/libpgtcl/pgtcl.c,v 1.29 2003/11/29 19:52:11 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/interfaces/libpgtcl/pgtcl.c,v 1.30 2004/01/07 18:56:29 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -53,109 +53,109 @@ Pgtcl_Init(Tcl_Interp *interp)
 	Tcl_CreateCommand(interp,
 					  "pg_conndefaults",
 					  Pg_conndefaults,
-					  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+					  NULL, NULL);
 
 	Tcl_CreateCommand(interp,
 					  "pg_connect",
 					  Pg_connect,
-					  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+					  NULL, NULL);
 
 	Tcl_CreateCommand(interp,
 					  "pg_disconnect",
 					  Pg_disconnect,
-					  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+					  NULL, NULL);
 
 	Tcl_CreateCommand(interp,
 					  "pg_exec",
 					  Pg_exec,
-					  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+					  NULL, NULL);
 
 	Tcl_CreateCommand(interp,
 					  "pg_select",
 					  Pg_select,
-					  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+					  NULL, NULL);
 
 	Tcl_CreateCommand(interp,
 					  "pg_result",
 					  Pg_result,
-					  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+					  NULL, NULL);
 
 	Tcl_CreateCommand(interp,
 					  "pg_execute",
 					  Pg_execute,
-					  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+					  NULL, NULL);
 
 	Tcl_CreateCommand(interp,
 					  "pg_lo_open",
 					  Pg_lo_open,
-					  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+					  NULL, NULL);
 
 	Tcl_CreateCommand(interp,
 					  "pg_lo_close",
 					  Pg_lo_close,
-					  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+					  NULL, NULL);
 
 #ifdef PGTCL_USE_TCLOBJ
 	Tcl_CreateObjCommand(interp,
 						 "pg_lo_read",
 						 Pg_lo_read,
-						 (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+						 NULL, NULL);
 
 	Tcl_CreateObjCommand(interp,
 						 "pg_lo_write",
 						 Pg_lo_write,
-						 (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+						 NULL, NULL);
 #else
 	Tcl_CreateCommand(interp,
 					  "pg_lo_read",
 					  Pg_lo_read,
-					  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+					  NULL, NULL);
 
 	Tcl_CreateCommand(interp,
 					  "pg_lo_write",
 					  Pg_lo_write,
-					  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+					  NULL, NULL);
 #endif
 
 	Tcl_CreateCommand(interp,
 					  "pg_lo_lseek",
 					  Pg_lo_lseek,
-					  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+					  NULL, NULL);
 
 	Tcl_CreateCommand(interp,
 					  "pg_lo_creat",
 					  Pg_lo_creat,
-					  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+					  NULL, NULL);
 
 	Tcl_CreateCommand(interp,
 					  "pg_lo_tell",
 					  Pg_lo_tell,
-					  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+					  NULL, NULL);
 
 	Tcl_CreateCommand(interp,
 					  "pg_lo_unlink",
 					  Pg_lo_unlink,
-					  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+					  NULL, NULL);
 
 	Tcl_CreateCommand(interp,
 					  "pg_lo_import",
 					  Pg_lo_import,
-					  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+					  NULL, NULL);
 
 	Tcl_CreateCommand(interp,
 					  "pg_lo_export",
 					  Pg_lo_export,
-					  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+					  NULL, NULL);
 
 	Tcl_CreateCommand(interp,
 					  "pg_listen",
 					  Pg_listen,
-					  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+					  NULL, NULL);
 
 	Tcl_CreateCommand(interp,
 					  "pg_on_connection_loss",
 					  Pg_on_connection_loss,
-					  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+					  NULL, NULL);
 
 	Tcl_PkgProvide(interp, "Pgtcl", "1.4");
 
diff --git a/src/interfaces/libpgtcl/pgtclCmds.c b/src/interfaces/libpgtcl/pgtclCmds.c
index 10b995117f06532d4c297208338a31288b015961..bbd0064bf9167f7474c52eca659f817f1a20a6b4 100644
--- a/src/interfaces/libpgtcl/pgtclCmds.c
+++ b/src/interfaces/libpgtcl/pgtclCmds.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/interfaces/libpgtcl/pgtclCmds.c,v 1.76 2003/11/29 19:52:11 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/interfaces/libpgtcl/pgtclCmds.c,v 1.77 2004/01/07 18:56:29 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -153,7 +153,7 @@ tcl_value(char *value)
 	char	   *p;
 
 	if (!value)
-		return (char *) NULL;
+		return NULL;
 
 #ifdef TCL_ARRAYS_DEBUG
 	printf("pq_value  = '%s'\n", value);
@@ -417,8 +417,8 @@ Pg_disconnect(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv
 	}
 
 	/* Check that it is a PG connection and not something else */
-	conn = PgGetConnectionId(interp, argv[1], (Pg_ConnectionId **) NULL);
-	if (conn == (PGconn *) NULL)
+	conn = PgGetConnectionId(interp, argv[1], NULL);
+	if (conn == NULL)
 		return TCL_ERROR;
 
 	return Tcl_UnregisterChannel(interp, conn_chan);
@@ -450,7 +450,7 @@ Pg_exec(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
 	}
 
 	conn = PgGetConnectionId(interp, argv[1], &connid);
-	if (conn == (PGconn *) NULL)
+	if (conn == NULL)
 		return TCL_ERROR;
 
 	if (connid->res_copyStatus != RES_COPY_NONE)
@@ -555,7 +555,7 @@ Pg_result(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
 	}
 
 	result = PgGetResultId(interp, argv[1]);
-	if (result == (PGresult *) NULL)
+	if (result == NULL)
 	{
 		Tcl_AppendResult(interp, "\n",
 						 argv[1], " is not a valid query result", 0);
@@ -878,7 +878,7 @@ Pg_execute(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
 	 * Get the connection and make sure no COPY command is pending
 	 */
 	conn = PgGetConnectionId(interp, argv[i++], &connid);
-	if (conn == (PGconn *) NULL)
+	if (conn == NULL)
 		return TCL_ERROR;
 
 	if (connid->res_copyStatus != RES_COPY_NONE)
@@ -1085,8 +1085,8 @@ Pg_lo_open(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
 		return TCL_ERROR;
 	}
 
-	conn = PgGetConnectionId(interp, argv[1], (Pg_ConnectionId **) NULL);
-	if (conn == (PGconn *) NULL)
+	conn = PgGetConnectionId(interp, argv[1], NULL);
+	if (conn == NULL)
 		return TCL_ERROR;
 
 	lobjId = atoi(argv[2]);
@@ -1153,8 +1153,8 @@ Pg_lo_close(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[]
 		return TCL_ERROR;
 	}
 
-	conn = PgGetConnectionId(interp, argv[1], (Pg_ConnectionId **) NULL);
-	if (conn == (PGconn *) NULL)
+	conn = PgGetConnectionId(interp, argv[1], NULL);
+	if (conn == NULL)
 		return TCL_ERROR;
 
 	fd = atoi(argv[2]);
@@ -1195,8 +1195,8 @@ Pg_lo_read(ClientData cData, Tcl_Interp *interp, int objc,
 	}
 
 	conn = PgGetConnectionId(interp, Tcl_GetStringFromObj(objv[1], NULL),
-							 (Pg_ConnectionId **) NULL);
-	if (conn == (PGconn *) NULL)
+							 NULL);
+	if (conn == NULL)
 		return TCL_ERROR;
 
 	if (Tcl_GetIntFromObj(interp, objv[2], &fd) != TCL_OK)
@@ -1254,8 +1254,8 @@ Pg_lo_read(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
 		return TCL_ERROR;
 	}
 
-	conn = PgGetConnectionId(interp, argv[1], (Pg_ConnectionId **) NULL);
-	if (conn == (PGconn *) NULL)
+	conn = PgGetConnectionId(interp, argv[1], NULL);
+	if (conn == NULL)
 		return TCL_ERROR;
 
 	fd = atoi(argv[2]);
@@ -1310,8 +1310,8 @@ Pg_lo_write(ClientData cData, Tcl_Interp *interp, int objc,
 	}
 
 	conn = PgGetConnectionId(interp, Tcl_GetStringFromObj(objv[1], NULL),
-							 (Pg_ConnectionId **) NULL);
-	if (conn == (PGconn *) NULL)
+							 NULL);
+	if (conn == NULL)
 		return TCL_ERROR;
 
 	if (Tcl_GetIntFromObj(interp, objv[2], &fd) != TCL_OK)
@@ -1357,8 +1357,8 @@ Pg_lo_write(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[]
 		return TCL_ERROR;
 	}
 
-	conn = PgGetConnectionId(interp, argv[1], (Pg_ConnectionId **) NULL);
-	if (conn == (PGconn *) NULL)
+	conn = PgGetConnectionId(interp, argv[1], NULL);
+	if (conn == NULL)
 		return TCL_ERROR;
 
 	fd = atoi(argv[2]);
@@ -1405,8 +1405,8 @@ Pg_lo_lseek(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[]
 		return TCL_ERROR;
 	}
 
-	conn = PgGetConnectionId(interp, argv[1], (Pg_ConnectionId **) NULL);
-	if (conn == (PGconn *) NULL)
+	conn = PgGetConnectionId(interp, argv[1], NULL);
+	if (conn == NULL)
 		return TCL_ERROR;
 
 	fd = atoi(argv[2]);
@@ -1457,8 +1457,8 @@ Pg_lo_creat(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[]
 		return TCL_ERROR;
 	}
 
-	conn = PgGetConnectionId(interp, argv[1], (Pg_ConnectionId **) NULL);
-	if (conn == (PGconn *) NULL)
+	conn = PgGetConnectionId(interp, argv[1], NULL);
+	if (conn == NULL)
 		return TCL_ERROR;
 
 	modeStr = strdup(argv[2]);
@@ -1477,7 +1477,7 @@ Pg_lo_creat(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[]
 		return TCL_ERROR;
 	}
 
-	while ((modeWord = strtok((char *) NULL, "|")) != NULL)
+	while ((modeWord = strtok(NULL, "|")) != NULL)
 	{
 		if (strcmp(modeWord, "INV_READ") == 0)
 			mode |= INV_READ;
@@ -1518,8 +1518,8 @@ Pg_lo_tell(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
 		return TCL_ERROR;
 	}
 
-	conn = PgGetConnectionId(interp, argv[1], (Pg_ConnectionId **) NULL);
-	if (conn == (PGconn *) NULL)
+	conn = PgGetConnectionId(interp, argv[1], NULL);
+	if (conn == NULL)
 		return TCL_ERROR;
 
 	fd = atoi(argv[2]);
@@ -1552,8 +1552,8 @@ Pg_lo_unlink(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[
 		return TCL_ERROR;
 	}
 
-	conn = PgGetConnectionId(interp, argv[1], (Pg_ConnectionId **) NULL);
-	if (conn == (PGconn *) NULL)
+	conn = PgGetConnectionId(interp, argv[1], NULL);
+	if (conn == NULL)
 		return TCL_ERROR;
 
 	lobjId = atoi(argv[2]);
@@ -1594,8 +1594,8 @@ Pg_lo_import(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[
 		return TCL_ERROR;
 	}
 
-	conn = PgGetConnectionId(interp, argv[1], (Pg_ConnectionId **) NULL);
-	if (conn == (PGconn *) NULL)
+	conn = PgGetConnectionId(interp, argv[1], NULL);
+	if (conn == NULL)
 		return TCL_ERROR;
 
 	filename = argv[2];
@@ -1638,8 +1638,8 @@ Pg_lo_export(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[
 		return TCL_ERROR;
 	}
 
-	conn = PgGetConnectionId(interp, argv[1], (Pg_ConnectionId **) NULL);
-	if (conn == (PGconn *) NULL)
+	conn = PgGetConnectionId(interp, argv[1], NULL);
+	if (conn == NULL)
 		return TCL_ERROR;
 
 	lobjId = atoi(argv[2]);
@@ -1702,7 +1702,7 @@ Pg_select(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
 	}
 
 	conn = PgGetConnectionId(interp, argv[1], &connid);
-	if (conn == (PGconn *) NULL)
+	if (conn == NULL)
 		return TCL_ERROR;
 
 	if ((result = PQexec(conn, argv[2])) == 0)
@@ -1858,7 +1858,7 @@ Pg_listen(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
 	 * allocated by us.
 	 */
 	conn = PgGetConnectionId(interp, argv[1], &connid);
-	if (conn == (PGconn *) NULL)
+	if (conn == NULL)
 		return TCL_ERROR;
 
 	/*
@@ -2032,7 +2032,7 @@ Pg_on_connection_loss(ClientData cData, Tcl_Interp *interp, int argc, CONST84 ch
 	 * Get the command arguments.
 	 */
 	conn = PgGetConnectionId(interp, argv[1], &connid);
-	if (conn == (PGconn *) NULL)
+	if (conn == NULL)
 		return TCL_ERROR;
 
 	if ((argc > 2) && *argv[2])
diff --git a/src/interfaces/libpgtcl/pgtclId.c b/src/interfaces/libpgtcl/pgtclId.c
index a86a2944762ab203eab19d45741a96ddddc34f9a..1cdd85b975b9486c41b8cfb23b25a0275500d80e 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
- *	  $PostgreSQL: pgsql/src/interfaces/libpgtcl/pgtclId.c,v 1.44 2003/11/29 19:52:11 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/interfaces/libpgtcl/pgtclId.c,v 1.45 2004/01/07 18:56:29 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -133,7 +133,7 @@ PgOutputProc(DRIVER_OUTPUT_PROTO)
 Tcl_File
 PgGetFileProc(ClientData cData, int direction)
 {
-	return (Tcl_File) NULL;
+	return NULL;
 }
 #endif
 
@@ -231,7 +231,7 @@ PgGetConnectionId(Tcl_Interp *interp, CONST84 char *id,
 		Tcl_AppendResult(interp, id, " is not a valid postgresql connection", 0);
 		if (connid_p)
 			*connid_p = NULL;
-		return (PGconn *) NULL;
+		return NULL;
 	}
 
 	connid = (Pg_ConnectionId *) Tcl_GetChannelInstanceData(conn_chan);
diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c
index e0c51b203db1b509cca2b4256e87829bae5b2d1d..1113b3abb0afc474778794fc0c8642f7e4a3e459 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
- *	  $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.88 2003/12/20 18:45:49 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.89 2004/01/07 18:56:29 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -173,7 +173,7 @@ pg_krb4_authname(char *PQerrormsg)
 		snprintf(PQerrormsg, PQERRORMSG_LENGTH,
 				 "pg_krb4_authname: krb_get_tf_fullname: %s\n",
 				 krb_err_txt[status]);
-		return (char *) NULL;
+		return NULL;
 	}
 	return name;
 }
@@ -220,8 +220,8 @@ pg_krb4_sendauth(char *PQerrormsg, int sock,
 						  hostname,
 						  realm,
 						  (u_long) 0,
-						  (MSG_DAT *) NULL,
-						  (CREDENTIALS *) NULL,
+						  NULL,
+						  NULL,
 						  NULL,
 						  laddr,
 						  raddr,
@@ -712,8 +712,8 @@ fe_getauthsvc(char *PQerrormsg)
 char *
 fe_getauthname(char *PQerrormsg)
 {
-	const char *name = (char *) NULL;
-	char	   *authn = (char *) NULL;
+	const char *name = NULL;
+	char	   *authn = NULL;
 	MsgType		authsvc;
 
 	authsvc = fe_getauthsvc(PQerrormsg);
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index ed996619cbfaf1c1ea32caf7e1a7966f54f3a7cd..233d3a2fe16d9fe4ec209edd2166916e8f5d5656 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.265 2003/12/19 21:50:54 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.266 2004/01/07 18:56:29 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -279,7 +279,7 @@ PQconnectStart(const char *conninfo)
 	 */
 	conn = makeEmptyPGconn();
 	if (conn == NULL)
-		return (PGconn *) NULL;
+		return NULL;
 
 	/*
 	 * Parse the conninfo string
@@ -532,7 +532,7 @@ PQsetdbLogin(const char *pghost, const char *pgport, const char *pgoptions,
 	 */
 	conn = makeEmptyPGconn();
 	if (conn == NULL)
-		return (PGconn *) NULL;
+		return NULL;
 
 	/*
 	 * Parse an empty conninfo string in order to set up the same defaults
@@ -1938,7 +1938,7 @@ makeEmptyPGconn(void)
 	WSADATA		wsaData;
 
 	if (WSAStartup(MAKEWORD(1, 1), &wsaData))
-		return (PGconn *) NULL;
+		return NULL;
 	WSASetLastError(0);
 #endif
 
@@ -1947,7 +1947,7 @@ makeEmptyPGconn(void)
 		return conn;
 
 	/* Zero all pointers and booleans */
-	MemSet((char *) conn, 0, sizeof(PGconn));
+	MemSet(conn, 0, sizeof(PGconn));
 
 	conn->noticeHooks.noticeRec = defaultNoticeReceiver;
 	conn->noticeHooks.noticeProc = defaultNoticeProcessor;
@@ -2765,7 +2765,7 @@ char *
 PQdb(const PGconn *conn)
 {
 	if (!conn)
-		return (char *) NULL;
+		return NULL;
 	return conn->dbName;
 }
 
@@ -2773,7 +2773,7 @@ char *
 PQuser(const PGconn *conn)
 {
 	if (!conn)
-		return (char *) NULL;
+		return NULL;
 	return conn->pguser;
 }
 
@@ -2781,7 +2781,7 @@ char *
 PQpass(const PGconn *conn)
 {
 	if (!conn)
-		return (char *) NULL;
+		return NULL;
 	return conn->pgpass;
 }
 
@@ -2789,7 +2789,7 @@ char *
 PQhost(const PGconn *conn)
 {
 	if (!conn)
-		return (char *) NULL;
+		return NULL;
 	return conn->pghost ? conn->pghost : conn->pgunixsocket;
 }
 
@@ -2797,7 +2797,7 @@ char *
 PQport(const PGconn *conn)
 {
 	if (!conn)
-		return (char *) NULL;
+		return NULL;
 	return conn->pgport;
 }
 
@@ -2805,7 +2805,7 @@ char *
 PQtty(const PGconn *conn)
 {
 	if (!conn)
-		return (char *) NULL;
+		return NULL;
 	return conn->pgtty;
 }
 
@@ -2813,7 +2813,7 @@ char *
 PQoptions(const PGconn *conn)
 {
 	if (!conn)
-		return (char *) NULL;
+		return NULL;
 	return conn->pgoptions;
 }
 
@@ -2915,7 +2915,7 @@ PQsetClientEncoding(PGconn *conn, const char *encoding)
 	sprintf(qbuf, query, encoding);
 	res = PQexec(conn, qbuf);
 
-	if (res == (PGresult *) NULL)
+	if (res == NULL)
 		return -1;
 	if (res->resultStatus != PGRES_COMMAND_OK)
 		status = -1;
diff --git a/src/interfaces/libpq/fe-lobj.c b/src/interfaces/libpq/fe-lobj.c
index 6d42ea1d28a7992c7169d47b6a73d3dd22106883..822ccfe11d6bb7fc9699d633b43fa4b47a32eb41 100644
--- a/src/interfaces/libpq/fe-lobj.c
+++ b/src/interfaces/libpq/fe-lobj.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/interfaces/libpq/fe-lobj.c,v 1.45 2003/11/29 19:52:12 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/interfaces/libpq/fe-lobj.c,v 1.46 2004/01/07 18:56:29 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -58,7 +58,7 @@ lo_open(PGconn *conn, Oid lobjId, int mode)
 	argv[1].len = 4;
 	argv[1].u.integer = mode;
 
-	if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
+	if (conn->lobjfuncs == NULL)
 	{
 		if (lo_initialize(conn) < 0)
 			return -1;
@@ -97,7 +97,7 @@ lo_close(PGconn *conn, int fd)
 	int			retval;
 	int			result_len;
 
-	if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
+	if (conn->lobjfuncs == NULL)
 	{
 		if (lo_initialize(conn) < 0)
 			return -1;
@@ -135,7 +135,7 @@ lo_read(PGconn *conn, int fd, char *buf, size_t len)
 	PGresult   *res;
 	int			result_len;
 
-	if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
+	if (conn->lobjfuncs == NULL)
 	{
 		if (lo_initialize(conn) < 0)
 			return -1;
@@ -177,7 +177,7 @@ lo_write(PGconn *conn, int fd, char *buf, size_t len)
 	int			result_len;
 	int			retval;
 
-	if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
+	if (conn->lobjfuncs == NULL)
 	{
 		if (lo_initialize(conn) < 0)
 			return -1;
@@ -223,7 +223,7 @@ lo_lseek(PGconn *conn, int fd, int offset, int whence)
 	int			retval;
 	int			result_len;
 
-	if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
+	if (conn->lobjfuncs == NULL)
 	{
 		if (lo_initialize(conn) < 0)
 			return -1;
@@ -272,7 +272,7 @@ lo_creat(PGconn *conn, int mode)
 	int			retval;
 	int			result_len;
 
-	if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
+	if (conn->lobjfuncs == NULL)
 	{
 		if (lo_initialize(conn) < 0)
 			return InvalidOid;
@@ -310,7 +310,7 @@ lo_tell(PGconn *conn, int fd)
 	PGresult   *res;
 	int			result_len;
 
-	if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
+	if (conn->lobjfuncs == NULL)
 	{
 		if (lo_initialize(conn) < 0)
 			return -1;
@@ -348,7 +348,7 @@ lo_unlink(PGconn *conn, Oid lobjId)
 	int			result_len;
 	int			retval;
 
-	if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
+	if (conn->lobjfuncs == NULL)
 	{
 		if (lo_initialize(conn) < 0)
 			return -1;
@@ -534,7 +534,7 @@ lo_initialize(PGconn *conn)
 	 * Allocate the structure to hold the functions OID's
 	 */
 	lobjfuncs = (PGlobjfuncs *) malloc(sizeof(PGlobjfuncs));
-	if (lobjfuncs == (PGlobjfuncs *) NULL)
+	if (lobjfuncs == NULL)
 	{
 		printfPQExpBuffer(&conn->errorMessage,
 						  libpq_gettext("out of memory\n"));
@@ -554,7 +554,7 @@ lo_initialize(PGconn *conn)
 		   or proname = 'lo_tell'	\
 		   or proname = 'loread'	\
 		   or proname = 'lowrite'");
-	if (res == (PGresult *) NULL)
+	if (res == NULL)
 	{
 		free(lobjfuncs);
 		return -1;
diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c
index b74e07e7501c6ca9dcef688c4f13662064950893..a00d5586246d495839a43740758e8b7c6ec4c7ef 100644
--- a/src/pl/plpgsql/src/pl_comp.c
+++ b/src/pl/plpgsql/src/pl_comp.c
@@ -3,7 +3,7 @@
  *			  procedural language
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.72 2004/01/07 06:20:02 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.73 2004/01/07 18:56:30 neilc Exp $
  *
  *	  This software is copyrighted by Jan Wieck - Hamburg.
  *
@@ -84,7 +84,7 @@ PLpgSQL_function *plpgsql_curr_compile;
  * Hash table for compiled functions
  * ----------
  */
-static HTAB *plpgsql_HashTable = (HTAB *) NULL;
+static HTAB *plpgsql_HashTable = NULL;
 
 typedef struct plpgsql_hashent
 {
@@ -1856,7 +1856,7 @@ plpgsql_HashTableLookup(PLpgSQL_func_hashkey *func_key)
 	if (hentry)
 		return hentry->function;
 	else
-		return (PLpgSQL_function *) NULL;
+		return NULL;
 }
 
 static void
diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c
index 54d612670d09287793e5abca9aa8f4cd521c0d35..0da1399d836cd2089c2c979c13a560007a2cd6ec 100644
--- a/src/pl/plpython/plpython.c
+++ b/src/pl/plpython/plpython.c
@@ -29,7 +29,7 @@
  * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  *
  * IDENTIFICATION
- *	$PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.44 2004/01/06 23:55:19 tgl Exp $
+ *	$PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.45 2004/01/07 18:56:30 neilc Exp $
  *
  *********************************************************************
  */
@@ -720,7 +720,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc, HeapTuple *
 
 		PyDict_SetItemString(pltdata, "old", Py_None);
 		PyDict_SetItemString(pltdata, "new", Py_None);
-		*rv = (HeapTuple) NULL;
+		*rv = NULL;
 
 		if (TRIGGER_FIRED_BY_INSERT(tdata->tg_event))
 			pltevent = PyString_FromString("INSERT");
diff --git a/src/test/examples/testlibpq4.c b/src/test/examples/testlibpq4.c
index 6fa167e3b1cef809cae1809bf896b9002f92141e..57b5f56ff51eeb57a344c6fabd5c2cc12e259e25 100644
--- a/src/test/examples/testlibpq4.c
+++ b/src/test/examples/testlibpq4.c
@@ -106,7 +106,7 @@ main(int argc, char **argv)
 	{
 		fprintf(stderr, "DECLARE CURSOR command failed\n");
 		PQclear(res1);
-		exit_nicely(conn1, (PGconn *) NULL);
+		exit_nicely(conn1, NULL);
 	}
 	PQclear(res1);
 
@@ -115,7 +115,7 @@ main(int argc, char **argv)
 	{
 		fprintf(stderr, "FETCH ALL command didn't return tuples properly\n");
 		PQclear(res1);
-		exit_nicely(conn1, (PGconn *) NULL);
+		exit_nicely(conn1, NULL);
 	}
 
 	/* first, print out the attribute names */