Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5b92d00

Browse files
committed
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 inthe same location.
1 parent394eec1 commit5b92d00

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

‎src/interfaces/libpq/fe-exec.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.118 2002/04/08 03:48:10 ishii Exp $
11+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.119 2002/04/15 23:35:51 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1510,8 +1510,16 @@ getNotify(PGconn *conn)
15101510
returnEOF;
15111511
if (pqGets(&conn->workBuffer,conn))
15121512
returnEOF;
1513-
newNotify= (PGnotify*)malloc(sizeof(PGnotify));
1514-
strncpy(newNotify->relname,conn->workBuffer.data,NAMEDATALEN);
1513+
1514+
/*
1515+
* Store the relation name right after the PQnotify structure so it can
1516+
* all be freed at once. We don't use NAMEDATALEN because we don't
1517+
* want to tie this interface to a specific server name length.
1518+
*/
1519+
newNotify= (PGnotify*)malloc(sizeof(PGnotify)+
1520+
strlen(conn->workBuffer.data)+1);
1521+
newNotify->relname= (char*)newNotify+sizeof(PGnotify);
1522+
strcpy(newNotify->relname,conn->workBuffer.data);
15151523
newNotify->be_pid=be_pid;
15161524
DLAddTail(conn->notifyList,DLNewElem(newNotify));
15171525
return0;

‎src/interfaces/libpq/libpq-fe.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: libpq-fe.h,v 1.83 2002/03/05 06:07:26 momjian Exp $
10+
* $Id: libpq-fe.h,v 1.84 2002/04/15 23:35:51 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -105,8 +105,7 @@ typedef struct pg_result PGresult;
105105
*/
106106
typedefstructpgNotify
107107
{
108-
charrelname[NAMEDATALEN];/* name of relation containing
109-
* data */
108+
char*relname;/* name of relation containing data */
110109
intbe_pid;/* process id of backend */
111110
}PGnotify;
112111

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp