diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index 2a9177170c7ca3d315f8fbab5ed509cb25f460d8..59d59a5e6f0b6e00e409755c47c435450078f4f3 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -1,5 +1,5 @@
 <!--
-$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.265 2004/05/26 18:51:43 momjian Exp $
+$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.266 2004/06/10 22:26:17 momjian Exp $
 -->
 
 <Chapter Id="runtime">
@@ -2617,8 +2617,9 @@ SET ENABLE_SEQSCAN TO OFF;
        </para>
 
        <para>
-        The value for <varname>dynamic_library_path</varname> has to be a colon-separated
-        list of absolute directory names. If a directory name starts
+        The value for <varname>dynamic_library_path</varname> has to be a
+        list of absolute directory names separated by colon or, in windows
+        environments with semi-colon. If a directory name starts
         with the special value <literal>$libdir</literal>, the
         compiled-in <productname>PostgreSQL</productname> package
         library directory is substituted. This where the modules
@@ -2628,6 +2629,10 @@ SET ENABLE_SEQSCAN TO OFF;
         example:
 <programlisting>
 dynamic_library_path = '/usr/local/lib/postgresql:/home/my_project/lib:$libdir'
+</programlisting>
+        or, in a windows environment:
+<programlisting>
+dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
 </programlisting>
        </para>
 
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 02c1bf8e2042a9441486593ba0229765eab049fc..337ec5395fbe9ad639740cb45536d4b763843ef6 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.134 2004/05/26 13:56:45 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.135 2004/06/10 22:26:18 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -941,7 +941,7 @@ resolve_alt_dbpath(const char *dbpath, Oid dboid)
 	if (dbpath == NULL || dbpath[0] == '\0')
 		return NULL;
 
-	if (first_path_separator(dbpath))
+	if (first_dir_separator(dbpath))
 	{
 		if (!is_absolute_path(dbpath))
 			ereport(ERROR,
diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c
index 0d1bfc3b20b19bf895fab71e1a2b01a1675e9d66..6be4093166e4ff61f24c78e36ad4e847fd3eed9e 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.73 2004/05/26 18:35:39 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.74 2004/06/10 22:26:19 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -288,7 +288,7 @@ expand_dynamic_library_name(const char *name)
 
 	AssertArg(name);
 
-	have_slash = (first_path_separator(name) != NULL);
+	have_slash = (first_dir_separator(name) != NULL);
 
 	if (!have_slash)
 	{
@@ -343,7 +343,7 @@ substitute_libpath_macro(const char *name)
 	if (name[0] != '$')
 		return pstrdup(name);
 
-	if ((sep_ptr = first_path_separator(name)) == NULL)
+	if ((sep_ptr = first_dir_separator(name)) == NULL)
 		sep_ptr = name + strlen(name);
 		
 	if (strlen("$libdir") != sep_ptr - name ||
@@ -374,7 +374,7 @@ find_in_dynamic_libpath(const char *basename)
 	size_t		baselen;
 
 	AssertArg(basename != NULL);
-	AssertArg(first_path_separator(basename) == NULL);
+	AssertArg(first_dir_separator(basename) == NULL);
 	AssertState(Dynamic_library_path != NULL);
 
 	p = Dynamic_library_path;
@@ -390,13 +390,17 @@ find_in_dynamic_libpath(const char *basename)
 		char	   *mangled;
 		char	   *full;
 
-		len = strcspn(p, ":");
-
-		if (len == 0)
+		piece = first_path_separator(p);
+		if(piece == p)
 			ereport(ERROR,
 					(errcode(ERRCODE_INVALID_NAME),
 			   errmsg("zero-length component in parameter \"dynamic_library_path\"")));
 
+		if(piece == 0)
+		   len = strlen(p);
+		else
+		   len = piece - p;
+
 		piece = palloc(len + 1);
 		strncpy(piece, p, len);
 		piece[len] = '\0';
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 726e4658fd72dd4c750ea08475d0b640b8def5ff..3ded3d8775b46da0f5df87d3910603cd00993c97 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -39,7 +39,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  * Portions taken from FreeBSD.
  *
- * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.36 2004/06/10 16:35:16 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.37 2004/06/10 22:26:20 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1934,7 +1934,7 @@ main(int argc, char *argv[])
 
 	/* store binary directory */
 	strcpy(bin_path, backend_exec);
-	*last_path_separator(bin_path) = '\0';
+	*last_dir_separator(bin_path) = '\0';
 
 	if (!share_path)
 	{
diff --git a/src/include/port.h b/src/include/port.h
index 8d089a8e23e69ae9715b15d3507f0acbf777c5fe..1a4a4d4336144d63f50ffe581f494c92d5f62c17 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.41 2004/06/10 16:35:18 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/port.h,v 1.42 2004/06/10 22:26:20 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -22,8 +22,22 @@
 bool set_noblock(int sock);
 
 /* Portable path handling for Unix/Win32 */
+
+/* Find the location of the first directory separator, return
+ * NULL if not found.
+ */
+extern char *first_dir_separator(const char *filename);
+
+/* Find the location of the last directory separator, return
+ * NULL if not found.
+ */
+extern char *last_dir_separator(const char *filename);
+
+/* Find the location of the first path separator (i.e. ':' on
+ * Unix, ';' on Windows), return NULL if not found.
+ */
 extern char *first_path_separator(const char *filename);
-extern char *last_path_separator(const char *filename);
+
 extern void canonicalize_path(char *path);
 extern const char *get_progname(const char *argv0);
 extern void get_share_path(const char *my_exec_path, char *ret_path);
diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c
index 82504723d12e5f5fba2edfcc3cc0dd46c65ec41f..838cedf5c94ac647204ea1b79413001eb205ddba 100644
--- a/src/interfaces/ecpg/ecpglib/connect.c
+++ b/src/interfaces/ecpg/ecpglib/connect.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.21 2004/03/15 16:27:43 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.22 2004/06/10 22:26:21 momjian Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -323,7 +323,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
 				*tmp = '\0';
 			}
 
-			tmp = last_path_separator(dbname + offset);
+			tmp = last_dir_separator(dbname + offset);
 			if (tmp != NULL)	/* database name given */
 			{
 				realname = strdup(tmp + 1);
diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c
index fb2f14a20f077b9e64503be8f799099845bfe3a8..f8013e487c36d5b23c103bc512db7370ef29c5b6 100644
--- a/src/interfaces/ecpg/preproc/ecpg.c
+++ b/src/interfaces/ecpg/preproc/ecpg.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.87 2004/05/17 14:35:34 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.88 2004/06/10 22:26:23 momjian Exp $ */
 
 /* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
 /* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
@@ -268,7 +268,7 @@ main(int argc, char *const argv[])
 				strcpy(input_filename, argv[fnr]);
 
 				/* take care of relative paths */
-				ptr2ext = last_path_separator(input_filename);
+				ptr2ext = last_dir_separator(input_filename);
 				ptr2ext = (ptr2ext ? strrchr(ptr2ext, '.') : strrchr(input_filename, '.'));
 
 				/* no extension? */
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index f741509d080772b4d8f507a83e6c3c9ce301384e..720c47fb86b946bb52f6565373bdcd2ef0157737 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.273 2004/06/08 13:49:23 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.274 2004/06/10 22:26:24 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -679,7 +679,7 @@ update_db_info(PGconn *conn)
 				*tmp = '\0';
 			}
 
-			tmp = last_path_separator(conn->dbName + offset);
+			tmp = last_dir_separator(conn->dbName + offset);
 			if (tmp != NULL)	/* database name given */
 			{
 				if (conn->dbName)
diff --git a/src/port/exec.c b/src/port/exec.c
index dbdc04b0ba27ef3b096394a5e382db57b2f1070d..c8ba1227a15e93681e60fdae5dbbdb53c22692c6 100644
--- a/src/port/exec.c
+++ b/src/port/exec.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/port/exec.c,v 1.15 2004/05/24 22:35:37 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/port/exec.c,v 1.16 2004/06/10 22:26:24 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -28,13 +28,6 @@
 
 #define _(x) gettext(x)
 
-/* $PATH (or %PATH%) path separator */
-#ifdef WIN32
-#define PATHSEP ';'
-#else
-#define PATHSEP ':'
-#endif
-
 #ifndef S_IRUSR					/* XXX [TRH] should be in a header */
 #define S_IRUSR		 S_IREAD
 #define S_IWUSR		 S_IWRITE
@@ -196,7 +189,7 @@ find_my_exec(const char *argv0, char *retpath)
 	 * it).
 	 */
 	/* Does argv0 have a separator? */
-	if ((path = last_path_separator(argv0)))
+	if ((path = last_dir_separator(argv0)))
 	{
 		if (*++path == '\0')
 		{
@@ -247,7 +240,7 @@ find_my_exec(const char *argv0, char *retpath)
 			else
 				startp = endp + 1;
 
-			endp = strchr(startp, PATHSEP);
+			endp = first_path_separator(startp);
 			if (!endp)
 				endp = startp + strlen(startp);	/* point to end */
 
@@ -303,7 +296,7 @@ find_other_exec(const char *argv0, const char *target,
 		return -1;
 
 	/* Trim off program name and keep just directory */	
-	*last_path_separator(retpath) = '\0';
+	*last_dir_separator(retpath) = '\0';
 
 	snprintf(retpath + strlen(retpath), MAXPGPATH - strlen(retpath),
 			 "/%s%s", target, EXE);
diff --git a/src/port/path.c b/src/port/path.c
index 7e6f5b4b73726557568245283955e3194238f8c8..864cb1e3a6abc1f7e83d90002ed00722e6bb3727 100644
--- a/src/port/path.c
+++ b/src/port/path.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/port/path.c,v 1.18 2004/06/08 13:49:23 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/port/path.c,v 1.19 2004/06/10 22:26:24 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -21,9 +21,15 @@
 
 
 #ifndef WIN32
-#define	ISSEP(ch)	((ch) == '/')
+#define	IS_DIR_SEP(ch)	((ch) == '/')
 #else
-#define	ISSEP(ch)	((ch) == '/' || (ch) == '\\')
+#define	IS_DIR_SEP(ch)	((ch) == '/' || (ch) == '\\')
+#endif
+
+#ifndef WIN32
+#define	IS_PATH_SEP(ch)	((ch) == ':')
+#else
+#define	IS_PATH_SEP(ch)	((ch) == ';')
 #endif
 
 const static char *relative_path(const char *bin_path, const char *other_path);
@@ -33,7 +39,7 @@ static void trim_trailing_separator(char *path);
 /* Move to last of consecutive separators or to null byte */
 #define MOVE_TO_SEP_END(p) \
 { \
-	while (ISSEP((p)[0]) && (ISSEP((p)[1]) || !(p)[1])) \
+	while (IS_DIR_SEP((p)[0]) && (IS_DIR_SEP((p)[1]) || !(p)[1])) \
 		(p)++; \
 }
 
@@ -46,6 +52,20 @@ do { \
 		snprintf(ret_path, MAXPGPATH, "%s/%s", path, p); \
 } while (0)
 
+/*
+ *	first_dir_separator
+ */
+char *
+first_dir_separator(const char *filename)
+{
+	char	   *p;
+
+	for (p = (char *)filename; *p; p++)
+		if (IS_DIR_SEP(*p))
+			return p;
+	return NULL;
+}
+
 /*
  *	first_path_separator
  */
@@ -55,22 +75,21 @@ first_path_separator(const char *filename)
 	char	   *p;
 
 	for (p = (char *)filename; *p; p++)
-		if (ISSEP(*p))
+		if (IS_PATH_SEP(*p))
 			return p;
 	return NULL;
 }
 
-
 /*
- *	last_path_separator
+ *	last_dir_separator
  */
 char *
-last_path_separator(const char *filename)
+last_dir_separator(const char *filename)
 {
 	char	   *p, *ret = NULL;
 
 	for (p = (char *)filename; *p; p++)
-		if (ISSEP(*p))
+		if (IS_DIR_SEP(*p))
 			ret = p;
 	return ret;
 }
@@ -108,10 +127,10 @@ canonicalize_path(char *path)
 const char *
 get_progname(const char *argv0)
 {
-	if (!last_path_separator(argv0))
+	if (!last_dir_separator(argv0))
 		return argv0;
 	else
-		return last_path_separator(argv0) + 1;
+		return last_dir_separator(argv0) + 1;
 }
 
 
@@ -307,7 +326,7 @@ relative_path(const char *bin_path, const char *other_path)
 			break;
 
 		/* Win32 filesystem is case insensitive */
-		if ((!ISSEP(*bin_path) || !ISSEP(*other_path)) &&
+		if ((!IS_DIR_SEP(*bin_path) || !IS_DIR_SEP(*other_path)) &&
 #ifndef WIN32
 			*bin_path != *other_path)
 #else
@@ -315,7 +334,7 @@ relative_path(const char *bin_path, const char *other_path)
 #endif
 				break;
 
-		if (ISSEP(*other_path))
+		if (IS_DIR_SEP(*other_path))
 			other_sep = other_path + 1;		/* past separator */
 			
 		bin_path++;
@@ -327,7 +346,7 @@ relative_path(const char *bin_path, const char *other_path)
 		return NULL;
 
 	/* advance past directory name */	
-	while (!ISSEP(*bin_path) && *bin_path)
+	while (!IS_DIR_SEP(*bin_path) && *bin_path)
 		bin_path++;
 
 	MOVE_TO_SEP_END(bin_path);
@@ -353,9 +372,9 @@ trim_directory(char *path)
 	if (path[0] == '\0')
 		return;
 
-	for (p = path + strlen(path) - 1; ISSEP(*p) && p > path; p--)
+	for (p = path + strlen(path) - 1; IS_DIR_SEP(*p) && p > path; p--)
 		;
-	for (; !ISSEP(*p) && p > path; p--)
+	for (; !IS_DIR_SEP(*p) && p > path; p--)
 		;
 	*p = '\0';
 	return;
@@ -373,6 +392,6 @@ trim_trailing_separator(char *path)
 	
 	/* trim off trailing slashes */
 	if (p > path)
-		for (p--; p >= path && ISSEP(*p); p--)
+		for (p--; p >= path && IS_DIR_SEP(*p); p--)
 			*p = '\0';
 }