diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 5be360040adebf468737d6e1bf2d43bd90d1d2d3..d23eb91735f79bd9d8ffc0f906f43d483fa0d431 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.168 2003/11/29 19:51:41 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.169 2003/12/01 22:15:37 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -290,7 +290,9 @@ BootstrapMain(int argc, char *argv[])
 #ifdef EXEC_BACKEND
 					char	   *p;
 
-					sscanf(optarg, "%d,%p,", &UsedShmemSegID, &UsedShmemSegAddr);
+					sscanf(optarg, "%lu,%p,",
+						   &UsedShmemSegID,
+						   &UsedShmemSegAddr);
 					p = strchr(optarg, ',');
 					if (p)
 						p = strchr(p + 1, ',');
diff --git a/src/backend/port/sysv_sema.c b/src/backend/port/sysv_sema.c
index 2a0b78b7a02f58e1800c38f1c2afdca0550f5e61..20f0d6bc514dd7ccfac8118aef870029822e2b23 100644
--- a/src/backend/port/sysv_sema.c
+++ b/src/backend/port/sysv_sema.c
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/port/sysv_sema.c,v 1.11 2003/11/29 19:51:54 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/port/sysv_sema.c,v 1.12 2003/12/01 22:15:37 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -42,7 +42,7 @@ union semun
 };
 #endif
 
-typedef uint32 IpcSemaphoreKey; /* semaphore key passed to semget(2) */
+typedef key_t IpcSemaphoreKey;	/* semaphore key passed to semget(2) */
 typedef int IpcSemaphoreId;		/* semaphore ID returned by semget(2) */
 
 /*
@@ -115,8 +115,8 @@ InternalIpcSemaphoreCreate(IpcSemaphoreKey semKey, int numSems)
 		 */
 		ereport(FATAL,
 				(errmsg("could not create semaphores: %m"),
-				 errdetail("Failed system call was semget(%d, %d, 0%o).",
-						   (int) semKey, numSems,
+				 errdetail("Failed system call was semget(%lu, %d, 0%o).",
+						   (unsigned long) semKey, numSems,
 						   IPC_CREAT | IPC_EXCL | IPCProtection),
 				 (errno == ENOSPC) ?
 				 errhint("This error does *not* mean that you have run out of disk space.\n"
diff --git a/src/backend/port/sysv_shmem.c b/src/backend/port/sysv_shmem.c
index 12934943b8f06b5d0da29e18c7cd0c61ff06dd1c..f47b0709b3a4461d6742c315325a0c483cd7e3ad 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.26 2003/11/29 19:51:54 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.27 2003/12/01 22:15:37 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -34,12 +34,14 @@
 #include "storage/ipc.h"
 #include "storage/pg_shmem.h"
 
+
+typedef key_t IpcMemoryKey;		/* shared memory key passed to shmget(2) */
 typedef int IpcMemoryId;		/* shared memory ID returned by shmget(2) */
 
 #define IPCProtection	(0600)	/* access/modify by user only */
 
 
-IpcMemoryKey UsedShmemSegID = 0;
+unsigned long UsedShmemSegID = 0;
 void	   *UsedShmemSegAddr = NULL;
 
 static void *InternalIpcMemoryCreate(IpcMemoryKey memKey, uint32 size);
@@ -90,8 +92,8 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, uint32 size)
 		 */
 		ereport(FATAL,
 				(errmsg("could not create shared memory segment: %m"),
-			errdetail("Failed system call was shmget(key=%d, size=%u, 0%o).",
-					  (int) memKey, size,
+			errdetail("Failed system call was shmget(key=%lu, size=%u, 0%o).",
+					  (unsigned long) memKey, size,
 					  IPC_CREAT | IPC_EXCL | IPCProtection),
 				 (errno == EINVAL) ?
 				 errhint("This error usually means that PostgreSQL's request for a shared memory "
@@ -247,9 +249,10 @@ PGSharedMemoryCreate(uint32 size, bool makePrivate, int port)
 	/* If Exec case, just attach and return the pointer */
 	if (ExecBackend && UsedShmemSegAddr != NULL && !makePrivate)
 	{
-		if ((hdr = PGSharedMemoryAttach(UsedShmemSegID, &shmid)) == NULL)
-			elog(FATAL, "could not attach to proper memory at fixed address: shmget(key=%d, addr=%p) failed: %m",
-				 (int) UsedShmemSegID, UsedShmemSegAddr);
+		hdr = PGSharedMemoryAttach((IpcMemoryKey) UsedShmemSegID, &shmid);
+		if (hdr == NULL)
+			elog(FATAL, "could not attach to proper memory at fixed address: shmget(key=%lu, addr=%p) failed: %m",
+				 UsedShmemSegID, UsedShmemSegAddr);
 		return hdr;
 	}
 
@@ -331,7 +334,7 @@ PGSharedMemoryCreate(uint32 size, bool makePrivate, int port)
 
 	/* Save info for possible future use */
 	UsedShmemSegAddr = memAddress;
-	UsedShmemSegID = NextShmemSegID;
+	UsedShmemSegID = (unsigned long) NextShmemSegID;
 
 	return hdr;
 }
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index a985708537d383f8cf5ac7f9f4132bc123223d92..b17ade737619969ffed3a84edd6947a0a7f5212a 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.350 2003/11/29 19:51:55 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.351 2003/12/01 22:15:37 tgl Exp $
  *
  * NOTES
  *
@@ -2558,8 +2558,10 @@ BackendFork(Port *port)
 #ifdef EXEC_BACKEND
 	Assert(UsedShmemSegID != 0 && UsedShmemSegAddr != NULL);
 	/* database name at the end because it might contain commas */
-	snprintf(pbuf, NAMEDATALEN + 256, "%d,%d,%d,%p,%s", port->sock, canAcceptConnections(),
-			 UsedShmemSegID, UsedShmemSegAddr, port->database_name);
+	snprintf(pbuf, sizeof(pbuf), "%d,%d,%lu,%p,%s",
+			 port->sock, canAcceptConnections(),
+			 UsedShmemSegID, UsedShmemSegAddr,
+			 port->database_name);
 	av[ac++] = pbuf;
 #else
 	av[ac++] = port->database_name;
@@ -2902,8 +2904,8 @@ SSDataBase(int xlop)
 #ifdef EXEC_BACKEND
 		Assert(UsedShmemSegID != 0 && UsedShmemSegAddr != NULL);
 		/* database name at the end because it might contain commas */
-		snprintf(pbuf, NAMEDATALEN + 256, "%d,%p,%s", UsedShmemSegID,
-				 UsedShmemSegAddr, "template1");
+		snprintf(pbuf, sizeof(pbuf), "%lu,%p,%s",
+				 UsedShmemSegID, UsedShmemSegAddr, "template1");
 		av[ac++] = pbuf;
 #else
 		av[ac++] = "template1";
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 0cd91e8fd9533cda87756e8b5a99bf2217fadfb8..0162cdc2d4b18e5c50d109bf8882505fcb1a3e28 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.378 2003/11/29 21:40:43 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.379 2003/12/01 22:15:37 tgl Exp $
  *
  * NOTES
  *	  this is the "main" module of the postgres backend and
@@ -2282,7 +2282,8 @@ PostgresMain(int argc, char *argv[], const char *username)
 														 * global or static,
 														 * when fork */
 
-					sscanf(optarg, "%d,%d,%d,%p,", &MyProcPort->sock, &PMcanAcceptConnections,
+					sscanf(optarg, "%d,%d,%lu,%p,",
+						   &MyProcPort->sock, &PMcanAcceptConnections,
 						   &UsedShmemSegID, &UsedShmemSegAddr);
 					/* Grab dbname as last param */
 					for (i = 0, p = optarg - 1; i < 4 && p; i++)
diff --git a/src/include/storage/pg_shmem.h b/src/include/storage/pg_shmem.h
index 13702daec111ba4a1b568edfac090043dba33a90..955d251c3cfc8724ede391d65fa6d370dea9d7c9 100644
--- a/src/include/storage/pg_shmem.h
+++ b/src/include/storage/pg_shmem.h
@@ -17,15 +17,13 @@
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/storage/pg_shmem.h,v 1.9 2003/11/29 22:41:13 pgsql Exp $
+ * $PostgreSQL: pgsql/src/include/storage/pg_shmem.h,v 1.10 2003/12/01 22:15:38 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
 #ifndef PG_SHMEM_H
 #define PG_SHMEM_H
 
-typedef uint32 IpcMemoryKey;	/* shared memory key passed to shmget(2) */
-
 typedef struct PGShmemHeader	/* standard header for all Postgres shmem */
 {
 	int32		magic;			/* magic # to identify Postgres segments */
@@ -37,7 +35,7 @@ typedef struct PGShmemHeader	/* standard header for all Postgres shmem */
 
 
 #ifdef EXEC_BACKEND
-extern IpcMemoryKey UsedShmemSegID;
+extern unsigned long UsedShmemSegID;
 extern void *UsedShmemSegAddr;
 #endif