summaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-exec.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2002-04-15 23:35:51 +0000
committerBruce Momjian <bruce@momjian.us>2002-04-15 23:35:51 +0000
commit5b92d004fa8226ea52b696e647d0867d5bb1f076 (patch)
treeb5931a56200feca4a01dc68ae06cefaab9e9db66 /src/interfaces/libpq/fe-exec.c
parent394eec1068f1caea4c6ac4a3f2191eaef2a6719e (diff)
Fix for NOTIFY when NAMEDATALEN is nonstandard in server. Fix idea from
Tom Lane to move string storage to end of structure but keep pointer in the same location.
Diffstat (limited to 'src/interfaces/libpq/fe-exec.c')
-rw-r--r--src/interfaces/libpq/fe-exec.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
index 0633663c890..88fc1a9f00d 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;