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

Commitf59175d

Browse files
author
Neil Conway
committed
Minor API cleanup for async notifications: we can only register the
current backend in pg_listener, so there is little point in makingthe PID to register part of async.c's public API. Other minor tweaks.
1 parent6634769 commitf59175d

File tree

3 files changed

+19
-28
lines changed

3 files changed

+19
-28
lines changed

‎src/backend/commands/async.c

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.124 2005/08/20 00:39:53 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.125 2005/10/06 21:30:32 neilc Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -146,13 +146,10 @@ static void ClearPendingNotifies(void);
146146
*Actual notification happens during transaction commit.
147147
*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
148148
*
149-
* Results:
150-
*XXX
151-
*
152149
*--------------------------------------------------------------
153150
*/
154151
void
155-
Async_Notify(char*relname)
152+
Async_Notify(constchar*relname)
156153
{
157154
if (Trace_notify)
158155
elog(DEBUG1,"Async_Notify(%s)",relname);
@@ -180,19 +177,16 @@ Async_Notify(char *relname)
180177
*
181178
*This is executed by the SQL listen command.
182179
*
183-
*Register a backend (identified by its Unix PID) as listening
184-
*on the specified relation.
185-
*
186-
* Results:
187-
*XXX
180+
*Register the current backend as listening on the specified
181+
*relation.
188182
*
189183
* Side effects:
190184
*pg_listener is updated.
191185
*
192186
*--------------------------------------------------------------
193187
*/
194188
void
195-
Async_Listen(char*relname,intpid)
189+
Async_Listen(constchar*relname)
196190
{
197191
RelationlRel;
198192
HeapScanDescscan;
@@ -203,7 +197,7 @@ Async_Listen(char *relname, int pid)
203197
boolalreadyListener= false;
204198

205199
if (Trace_notify)
206-
elog(DEBUG1,"Async_Listen(%s,%d)",relname,pid);
200+
elog(DEBUG1,"Async_Listen(%s,%d)",relname,MyProcPid);
207201

208202
lRel=heap_open(ListenerRelationId,ExclusiveLock);
209203

@@ -213,7 +207,7 @@ Async_Listen(char *relname, int pid)
213207
{
214208
Form_pg_listenerlistener= (Form_pg_listener)GETSTRUCT(tuple);
215209

216-
if (listener->listenerpid==pid&&
210+
if (listener->listenerpid==MyProcPid&&
217211
strncmp(NameStr(listener->relname),relname,NAMEDATALEN)==0)
218212
{
219213
alreadyListener= true;
@@ -241,7 +235,7 @@ Async_Listen(char *relname, int pid)
241235

242236
i=0;
243237
values[i++]= (Datum)relname;
244-
values[i++]= (Datum)pid;
238+
values[i++]= (Datum)MyProcPid;
245239
values[i++]= (Datum)0;/* no notifies pending */
246240

247241
tuple=heap_formtuple(RelationGetDescr(lRel),values,nulls);
@@ -271,19 +265,16 @@ Async_Listen(char *relname, int pid)
271265
*
272266
*This is executed by the SQL unlisten command.
273267
*
274-
*Remove the backend from the list of listening backends
268+
*Remove thecurrentbackend from the list of listening backends
275269
*for the specified relation.
276270
*
277-
* Results:
278-
*XXX
279-
*
280271
* Side effects:
281272
*pg_listener is updated.
282273
*
283274
*--------------------------------------------------------------
284275
*/
285276
void
286-
Async_Unlisten(char*relname,intpid)
277+
Async_Unlisten(constchar*relname)
287278
{
288279
RelationlRel;
289280
HeapScanDescscan;
@@ -297,7 +288,7 @@ Async_Unlisten(char *relname, int pid)
297288
}
298289

299290
if (Trace_notify)
300-
elog(DEBUG1,"Async_Unlisten(%s,%d)",relname,pid);
291+
elog(DEBUG1,"Async_Unlisten(%s,%d)",relname,MyProcPid);
301292

302293
lRel=heap_open(ListenerRelationId,ExclusiveLock);
303294

@@ -306,7 +297,7 @@ Async_Unlisten(char *relname, int pid)
306297
{
307298
Form_pg_listenerlistener= (Form_pg_listener)GETSTRUCT(tuple);
308299

309-
if (listener->listenerpid==pid&&
300+
if (listener->listenerpid==MyProcPid&&
310301
strncmp(NameStr(listener->relname),relname,NAMEDATALEN)==0)
311302
{
312303
/* Found the matching tuple, delete it */

‎src/backend/tcop/utility.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.243 2005/08/01 04:03:57 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.244 2005/10/06 21:30:36 neilc Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -823,15 +823,15 @@ ProcessUtility(Node *parsetree,
823823
{
824824
ListenStmt*stmt= (ListenStmt*)parsetree;
825825

826-
Async_Listen(stmt->relation->relname,MyProcPid);
826+
Async_Listen(stmt->relation->relname);
827827
}
828828
break;
829829

830830
caseT_UnlistenStmt:
831831
{
832832
UnlistenStmt*stmt= (UnlistenStmt*)parsetree;
833833

834-
Async_Unlisten(stmt->relation->relname,MyProcPid);
834+
Async_Unlisten(stmt->relation->relname);
835835
}
836836
break;
837837

‎src/include/commands/async.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/commands/async.h,v 1.28 2005/06/17 22:32:49 tgl Exp $
9+
* $PostgreSQL: pgsql/src/include/commands/async.h,v 1.29 2005/10/06 21:30:39 neilc Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -16,9 +16,9 @@
1616
externboolTrace_notify;
1717

1818
/* notify-related SQL statements */
19-
externvoidAsync_Notify(char*relname);
20-
externvoidAsync_Listen(char*relname,intpid);
21-
externvoidAsync_Unlisten(char*relname,intpid);
19+
externvoidAsync_Notify(constchar*relname);
20+
externvoidAsync_Listen(constchar*relname);
21+
externvoidAsync_Unlisten(constchar*relname);
2222

2323
/* perform (or cancel) outbound notify processing at transaction commit */
2424
externvoidAtCommit_Notify(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp