mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
Back out tcl patch, per Tom Lane:
Everytime if I do PQconsumeInput (when the backend channel gets readable) I check for the return value. (0 == error) and generate a notification manually, e.g. fixed string connection_closed) and pass it to the
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.63 2002/08/17 12:19:31 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.64 2002/08/18 01:39:43 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -419,11 +419,8 @@ Pg_disconnect(ClientData cData, Tcl_Interp *interp, int argc, char *argv[])
|
|||||||
|
|
||||||
#if TCL_MAJOR_VERSION >= 8
|
#if TCL_MAJOR_VERSION >= 8
|
||||||
conn = PgGetConnectionId(interp, argv[1], &connid);
|
conn = PgGetConnectionId(interp, argv[1], &connid);
|
||||||
if (connid->notifier_channel != NULL) {
|
if (connid->notifier_channel != NULL)
|
||||||
/* stop listening for NOTIFY events on that channel */
|
|
||||||
PgStopNotifyEventSource(connid,1);
|
|
||||||
Tcl_UnregisterChannel(interp, connid->notifier_channel);
|
Tcl_UnregisterChannel(interp, connid->notifier_channel);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return Tcl_UnregisterChannel(interp, conn_chan);
|
return Tcl_UnregisterChannel(interp, conn_chan);
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.31 2002/08/17 12:19:31 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.32 2002/08/18 01:39:43 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -277,7 +277,7 @@ PgDelConnectionId(DRIVER_DEL_PROTO)
|
|||||||
* Turn off the Tcl event source for this connection, and delete any
|
* Turn off the Tcl event source for this connection, and delete any
|
||||||
* pending notify events.
|
* pending notify events.
|
||||||
*/
|
*/
|
||||||
PgStopNotifyEventSource(connid,1);
|
PgStopNotifyEventSource(connid);
|
||||||
|
|
||||||
/* Close the libpq connection too */
|
/* Close the libpq connection too */
|
||||||
PQfinish(connid->conn);
|
PQfinish(connid->conn);
|
||||||
@ -441,7 +441,7 @@ PgGetConnByResultId(Tcl_Interp *interp, char *resid_c)
|
|||||||
*mark = '.';
|
*mark = '.';
|
||||||
if (conn_chan && Tcl_GetChannelType(conn_chan) == &Pg_ConnType)
|
if (conn_chan && Tcl_GetChannelType(conn_chan) == &Pg_ConnType)
|
||||||
{
|
{
|
||||||
Tcl_SetResult(interp, (char *)Tcl_GetChannelName(conn_chan), TCL_VOLATILE);
|
Tcl_SetResult(interp, Tcl_GetChannelName(conn_chan), TCL_VOLATILE);
|
||||||
return TCL_OK;
|
return TCL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -611,9 +611,7 @@ PgNotifyTransferEvents(Pg_ConnectionId * connid)
|
|||||||
* closed socket descriptor.
|
* closed socket descriptor.
|
||||||
*/
|
*/
|
||||||
if (PQsocket(connid->conn) < 0)
|
if (PQsocket(connid->conn) < 0)
|
||||||
/* do not remove any pending events, so that the virtual notification
|
PgStopNotifyEventSource(connid);
|
||||||
connection_closed will be processed */
|
|
||||||
PgStopNotifyEventSource(connid,0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -677,17 +675,7 @@ Pg_Notify_FileHandler(ClientData clientData, int mask)
|
|||||||
* it internally to libpq; but it will clear the read-ready
|
* it internally to libpq; but it will clear the read-ready
|
||||||
* condition).
|
* condition).
|
||||||
*/
|
*/
|
||||||
if (!PQconsumeInput(connid->conn)) {
|
PQconsumeInput(connid->conn);
|
||||||
NotifyEvent *event = (NotifyEvent *) ckalloc(sizeof(NotifyEvent));
|
|
||||||
|
|
||||||
PGnotify *closed = (PGnotify *) ckalloc(sizeof(PGnotify));
|
|
||||||
strcpy(closed->relname,"connection_closed");
|
|
||||||
event->header.proc = Pg_Notify_EventProc;
|
|
||||||
event->info= *closed;
|
|
||||||
event->connid = connid;
|
|
||||||
Tcl_QueueEvent((Tcl_Event *) event, TCL_QUEUE_TAIL);
|
|
||||||
ckfree((void *)closed);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Transfer notify events from libpq to Tcl event queue. */
|
/* Transfer notify events from libpq to Tcl event queue. */
|
||||||
PgNotifyTransferEvents(connid);
|
PgNotifyTransferEvents(connid);
|
||||||
@ -736,7 +724,7 @@ PgStartNotifyEventSource(Pg_ConnectionId * connid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PgStopNotifyEventSource(Pg_ConnectionId * connid, int remove_pending)
|
PgStopNotifyEventSource(Pg_ConnectionId * connid)
|
||||||
{
|
{
|
||||||
/* Remove the event source */
|
/* Remove the event source */
|
||||||
if (connid->notifier_running)
|
if (connid->notifier_running)
|
||||||
@ -755,5 +743,5 @@ PgStopNotifyEventSource(Pg_ConnectionId * connid, int remove_pending)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Kill any queued Tcl events that reference this channel */
|
/* Kill any queued Tcl events that reference this channel */
|
||||||
if (remove_pending) Tcl_DeleteEvents(NotifyEventDeleteProc, (ClientData) connid);
|
Tcl_DeleteEvents(NotifyEventDeleteProc, (ClientData) connid);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: pgtclId.h,v 1.19 2002/08/17 12:19:31 momjian Exp $
|
* $Id: pgtclId.h,v 1.20 2002/08/18 01:39:43 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -44,7 +44,7 @@ extern PGresult *PgGetResultId(Tcl_Interp *interp, char *id);
|
|||||||
extern void PgDelResultId(Tcl_Interp *interp, char *id);
|
extern void PgDelResultId(Tcl_Interp *interp, char *id);
|
||||||
extern int PgGetConnByResultId(Tcl_Interp *interp, char *resid);
|
extern int PgGetConnByResultId(Tcl_Interp *interp, char *resid);
|
||||||
extern void PgStartNotifyEventSource(Pg_ConnectionId * connid);
|
extern void PgStartNotifyEventSource(Pg_ConnectionId * connid);
|
||||||
extern void PgStopNotifyEventSource(Pg_ConnectionId * connid, int remove_pend);
|
extern void PgStopNotifyEventSource(Pg_ConnectionId * connid);
|
||||||
extern void PgNotifyTransferEvents(Pg_ConnectionId * connid);
|
extern void PgNotifyTransferEvents(Pg_ConnectionId * connid);
|
||||||
extern void PgNotifyInterpDelete(ClientData clientData, Tcl_Interp *interp);
|
extern void PgNotifyInterpDelete(ClientData clientData, Tcl_Interp *interp);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user