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

Commit58f481c

Browse files
committed
Tweak libpq so that if a backend ERROR message arrives while libpq
thinks the connection is idle, the error message is displayed as ifit were a NOTICE. This seems better than dropping the message onthe floor ... particularly if the message is the backend telling uswhy it's about to close the connection. The previous behavior wasBackend message type 0x45 arrived while idlepqReadData() -- backend closed the channel unexpectedly.which is not real helpful.
1 parentf017d7e commit58f481c

File tree

1 file changed

+37
-18
lines changed

1 file changed

+37
-18
lines changed

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

Lines changed: 37 additions & 18 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.90 2000/02/07 23:10:10 petere Exp $
11+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.91 2000/02/24 04:50:51 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -669,6 +669,13 @@ parseInput(PGconn *conn)
669669
/*
670670
* NOTIFY and NOTICE messages can happen in any state besides COPY
671671
* OUT; always process them right away.
672+
*
673+
* Most other messages should only be processed while in BUSY state.
674+
* (In particular, in READY state we hold off further parsing until
675+
* the application collects the current PGresult.)
676+
*
677+
* However, if the state is IDLE then we got trouble; we need to
678+
* deal with the unexpected message somehow.
672679
*/
673680
if (id=='A')
674681
{
@@ -680,28 +687,40 @@ parseInput(PGconn *conn)
680687
if (getNotice(conn))
681688
return;
682689
}
683-
else
690+
elseif (conn->asyncStatus!=PGASYNC_BUSY)
684691
{
685-
692+
/* If not IDLE state, just wait ... */
693+
if (conn->asyncStatus!=PGASYNC_IDLE)
694+
return;
686695
/*
687-
* Other messages should only be processed while in BUSY
688-
* state. (In particular, in READY state we hold off further
689-
* parsing until the application collects the current
690-
* PGresult.) If the state is IDLE then we got trouble.
696+
* Unexpected message in IDLE state; need to recover somehow.
697+
* ERROR messages are displayed using the notice processor;
698+
* anything else is just dropped on the floor after displaying
699+
* a suitable warning notice. (An ERROR is very possibly the
700+
* backend telling us why it is about to close the connection,
701+
* so we don't want to just discard it...)
691702
*/
692-
if (conn->asyncStatus!=PGASYNC_BUSY)
703+
if (id=='E')
693704
{
694-
if (conn->asyncStatus==PGASYNC_IDLE)
695-
{
696-
sprintf(noticeWorkspace,
697-
"Backend message type 0x%02x arrived while idle\n",
698-
id);
699-
DONOTICE(conn,noticeWorkspace);
700-
/* Discard the unexpected message; good idea?? */
701-
conn->inStart=conn->inEnd;
702-
}
703-
return;
705+
if (getNotice(conn))
706+
return;
707+
}
708+
else
709+
{
710+
sprintf(noticeWorkspace,
711+
"Backend message type 0x%02x arrived while idle\n",
712+
id);
713+
DONOTICE(conn,noticeWorkspace);
714+
/* Discard the unexpected message; good idea?? */
715+
conn->inStart=conn->inEnd;
716+
break;
704717
}
718+
}
719+
else
720+
{
721+
/*
722+
* In BUSY state, we can process everything.
723+
*/
705724
switch (id)
706725
{
707726
case'C':/* command complete */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp