diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 144a2e3723c6889ac278840e4b56ec5c895d6bf3..a52828ab681811e374515f520188fdfe3ab80c2d 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -13,7 +13,7 @@
  *
  *	Copyright (c) 2001-2003, PostgreSQL Global Development Group
  *
- *	$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.64 2004/03/27 17:59:35 momjian Exp $
+ *	$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.65 2004/04/05 03:16:21 momjian Exp $
  * ----------
  */
 #include "postgres.h"
@@ -143,19 +143,6 @@ static void pgstat_recv_tabpurge(PgStat_MsgTabpurge *msg, int len);
 static void pgstat_recv_dropdb(PgStat_MsgDropdb *msg, int len);
 static void pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg, int len);
 
-/*
- *	WIN32 doesn't allow descriptors returned by pipe() to be used in select(),
- *	so for that platform we use socket() instead of pipe().
- */
-#ifndef WIN32
-#define pgpipe(a)			pipe(a)
-#define piperead(a,b,c)		read(a,b,c)
-#define pipewrite(a,b,c)	write(a,b,c)
-#else
-extern int pgpipe(int handles[2]); /* pgpipe() is in /src/port */
-#define piperead(a,b,c)		recv(a,b,c,0)
-#define pipewrite(a,b,c)	send(a,b,c,0)
-#endif
 
 /* ------------------------------------------------------------
  * Public functions called from postmaster follow
diff --git a/src/bin/psql/win32.mak b/src/bin/psql/win32.mak
index 072b30d6a1a743faf1db50375d57977ee816258a..60f57552f123381a2bb98a63284a73954d0fff9c 100644
--- a/src/bin/psql/win32.mak
+++ b/src/bin/psql/win32.mak
@@ -32,6 +32,7 @@ CLEAN :
 	-@erase "$(INTDIR)\large_obj.obj"
 	-@erase "$(INTDIR)\print.obj"
 	-@erase "$(INTDIR)\describe.obj"
+	-@erase "$(INTDIR)\psqlscan.obj"
 	-@erase "$(INTDIR)\tab-complete.obj"
 	-@erase "$(INTDIR)\sprompt.obj"
 	-@erase "$(INTDIR)\getopt.obj"
@@ -70,6 +71,7 @@ LINK32_OBJS= \
 	"$(INTDIR)\large_obj.obj" \
 	"$(INTDIR)\print.obj" \
 	"$(INTDIR)\describe.obj" \
+	"$(INTDIR)\psqlscan.obj" \
 	"$(INTDIR)\tab-complete.obj" \
 	"$(INTDIR)\sprompt.obj" \
 	"$(INTDIR)\getopt.obj" \
@@ -115,4 +117,3 @@ LINK32_OBJS= \
 
 sql_help.h: create_help.pl
         $(PERL) create_help.pl $(REFDOCDIR) $@
-
diff --git a/src/include/libpq/libpq-be.h b/src/include/libpq/libpq-be.h
index 3200042dae0f9fd81fc24b8c250a05c7b9ea5a85..718001c9b3a394299aeed1d43f1f09dfb43eaec8 100644
--- a/src/include/libpq/libpq-be.h
+++ b/src/include/libpq/libpq-be.h
@@ -11,14 +11,16 @@
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/libpq/libpq-be.h,v 1.43 2004/03/19 02:23:59 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/libpq/libpq-be.h,v 1.44 2004/04/05 03:16:21 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 #ifndef LIBPQ_BE_H
 #define LIBPQ_BE_H
 
+#ifndef _MSC_VER
 #include <sys/time.h>
+#endif
 #ifdef USE_SSL
 #include <openssl/ssl.h>
 #include <openssl/err.h>
diff --git a/src/include/port.h b/src/include/port.h
index 70f2b5f3fe5aa0e6ae9f26e9839a206f54ff6d06..e539d1f25db141b654aed2c0f8f1d0420edae56a 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -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/include/port.h,v 1.23 2004/03/24 03:54:16 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/port.h,v 1.24 2004/04/05 03:16:21 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -38,13 +38,26 @@ extern int	fseeko(FILE *stream, off_t offset, int whence);
 extern off_t ftello(FILE *stream);
 #endif
 
-#if defined(WIN32) || defined(__CYGWIN__)
+/*
+ *	WIN32 doesn't allow descriptors returned by pipe() to be used in select(),
+ *	so for that platform we use socket() instead of pipe().
+ */
+#ifndef WIN32
+#define pgpipe(a)			pipe(a)
+#define piperead(a,b,c)		read(a,b,c)
+#define pipewrite(a,b,c)	write(a,b,c)
+#else
+extern int pgpipe(int handles[2]);
+#define piperead(a,b,c)		recv(a,b,c,0)
+#define pipewrite(a,b,c)	send(a,b,c,0)
+#endif
+
+#if defined(__MINGW32__) || defined(__CYGWIN__)
 /*
  * Win32 doesn't have reliable rename/unlink during concurrent access
  */
 extern int	pgrename(const char *from, const char *to);
 extern int	pgunlink(const char *path);
-
 #define rename(from, to)	pgrename(from, to)
 #define unlink(path)		pgunlink(path)
 #endif
@@ -52,8 +65,10 @@ extern int	pgunlink(const char *path);
 #ifdef WIN32
 
 /* open() replacement to allow delete of held files */
+#ifndef _MSC_VER
 extern int	win32_open(const char*,int,...);
 #define 	open(a,b,...)	win32_open(a,b,##__VA_ARGS__)
+#endif
 
 extern int	copydir(char *fromdir, char *todir);
 
diff --git a/src/interfaces/libpq/libpqdll.def b/src/interfaces/libpq/libpqdll.def
index 4973ddd713866449e17b96bca2e77fbc0bf8facc..302d299266464f5c630b676294e58305e1576622 100644
--- a/src/interfaces/libpq/libpqdll.def
+++ b/src/interfaces/libpq/libpqdll.def
@@ -113,3 +113,4 @@ EXPORTS
     PQfformat               @ 109
     PQexecPrepared          @ 110
     PQsendQueryPrepared     @ 111
+    PQdsplen                @ 112
diff --git a/src/interfaces/libpq/win32.mak b/src/interfaces/libpq/win32.mak
index 3623b1fe579ed99eda316ae94bcb0c331d688f28..de6c14090ac8e570ac61831418d0d7e49b150203 100644
--- a/src/interfaces/libpq/win32.mak
+++ b/src/interfaces/libpq/win32.mak
@@ -48,6 +48,7 @@ CLEAN :
 	-@erase "$(INTDIR)\thread.obj"
 	-@erase "$(INTDIR)\inet_aton.obj"
 	-@erase "$(INTDIR)\crypt.obj"
+	-@erase "$(INTDIR)\noblock.obj"
 	-@erase "$(INTDIR)\path.obj"
 	-@erase "$(INTDIR)\dllist.obj"
 	-@erase "$(INTDIR)\md5.obj"
@@ -96,6 +97,7 @@ LIB32_OBJS= \
 	"$(INTDIR)\thread.obj" \
 	"$(INTDIR)\inet_aton.obj" \
         "$(INTDIR)\crypt.obj" \
+	"$(INTDIR)\noblock.obj" \
 	"$(INTDIR)\path.obj" \
 	"$(INTDIR)\dllist.obj" \
 	"$(INTDIR)\md5.obj" \
@@ -161,6 +163,11 @@ LINK32_OBJS= \
     $(CPP_PROJ) ..\..\port\crypt.c
 <<
 
+"$(INTDIR)\noblock.obj" : ..\..\port\noblock.c
+    $(CPP) @<<
+    $(CPP_PROJ) ..\..\port\noblock.c
+<<
+
 "$(INTDIR)\path.obj" : ..\..\port\path.c
     $(CPP) @<<
     $(CPP_PROJ) ..\..\port\path.c