diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
index 0633663c89047139274de6240c725eafb6d1f377..88fc1a9f00d0258f2faeb583561e8946b33ccdd5 100644
--- a/src/interfaces/libpq/fe-exec.c
+++ b/src/interfaces/libpq/fe-exec.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.118 2002/04/08 03:48:10 ishii Exp $
+ *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.119 2002/04/15 23:35:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1510,8 +1510,16 @@ getNotify(PGconn *conn)
 		return EOF;
 	if (pqGets(&conn->workBuffer, conn))
 		return EOF;
-	newNotify = (PGnotify *) malloc(sizeof(PGnotify));
-	strncpy(newNotify->relname, conn->workBuffer.data, NAMEDATALEN);
+
+	/*
+	 * Store the relation name right after the PQnotify structure so it can
+	 * all be freed at once.  We don't use NAMEDATALEN because we don't
+	 * want to tie this interface to a specific server name length.
+	 */
+	newNotify = (PGnotify *) malloc(sizeof(PGnotify) +
+				strlen(conn->workBuffer.data) + 1);
+	newNotify->relname = (char *)newNotify + sizeof(PGnotify);
+	strcpy(newNotify->relname, conn->workBuffer.data);
 	newNotify->be_pid = be_pid;
 	DLAddTail(conn->notifyList, DLNewElem(newNotify));
 	return 0;
diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h
index b034b3992a1da917f0d551602d34d67e3e5d8a84..7f77f8aec4ff349077d24b25ed648ea41c818774 100644
--- a/src/interfaces/libpq/libpq-fe.h
+++ b/src/interfaces/libpq/libpq-fe.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: libpq-fe.h,v 1.83 2002/03/05 06:07:26 momjian Exp $
+ * $Id: libpq-fe.h,v 1.84 2002/04/15 23:35:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -105,8 +105,7 @@ typedef struct pg_result PGresult;
  */
 typedef struct pgNotify
 {
-	char		relname[NAMEDATALEN];	/* name of relation containing
-										 * data */
+	char		*relname;		/* name of relation containing data */
 	int			be_pid;			/* process id of backend */
 } PGnotify;