Commit 389e336c authored by Marc G. Fournier's avatar Marc G. Fournier

From: wieck@sapserv.debis.de

Hi,

    counting the empty dummy queries in libpq isn't everything.
    If the backend sends an error, the I returns from the dummies
    still come. So we must eat them up in any case, not just
    returning on the occurence of an E reply.

Until later, Jan
parent 16293d05
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.26 1996/12/31 07:29:15 bryanh Exp $ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.27 1997/01/08 23:25:32 scrappy Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -380,6 +380,10 @@ process_response_from_backend(FILE *pfin, FILE *pfout, FILE *pfdebug, ...@@ -380,6 +380,10 @@ process_response_from_backend(FILE *pfin, FILE *pfout, FILE *pfdebug,
responses, less the number of corresponding responses we have responses, less the number of corresponding responses we have
received. received.
*/ */
int errors;
/* If an error is received, we must still drain out the empty
queries sent. So we need another flag.
*/
char cmdStatus[MAX_MESSAGE_LEN]; char cmdStatus[MAX_MESSAGE_LEN];
char pname[MAX_MESSAGE_LEN]; /* portal name */ char pname[MAX_MESSAGE_LEN]; /* portal name */
...@@ -388,6 +392,7 @@ process_response_from_backend(FILE *pfin, FILE *pfout, FILE *pfdebug, ...@@ -388,6 +392,7 @@ process_response_from_backend(FILE *pfin, FILE *pfout, FILE *pfdebug,
*/ */
emptiesSent = 0; /* No empty queries sent yet */ emptiesSent = 0; /* No empty queries sent yet */
errors = 0; /* No errors received yet */
pname[0] = '\0'; pname[0] = '\0';
done = false; /* initial value */ done = false; /* initial value */
...@@ -444,7 +449,10 @@ process_response_from_backend(FILE *pfin, FILE *pfout, FILE *pfdebug, ...@@ -444,7 +449,10 @@ process_response_from_backend(FILE *pfin, FILE *pfout, FILE *pfdebug,
"but attempt to read the error message failed."); "but attempt to read the error message failed.");
} }
*result_p = (PGresult*)NULL; *result_p = (PGresult*)NULL;
done = true; errors++;
if (emptiesSent == 0) {
done = true;
}
break; break;
case 'I': { /* empty query */ case 'I': { /* empty query */
/* read and throw away the closing '\0' */ /* read and throw away the closing '\0' */
...@@ -458,13 +466,21 @@ process_response_from_backend(FILE *pfin, FILE *pfout, FILE *pfdebug, ...@@ -458,13 +466,21 @@ process_response_from_backend(FILE *pfin, FILE *pfout, FILE *pfdebug,
* If this is the result of a portal query command set the * If this is the result of a portal query command set the
* command status and message accordingly. DZ - 31-8-1996 * command status and message accordingly. DZ - 31-8-1996
*/ */
*result_p = makeEmptyPGresult(conn,PGRES_COMMAND_OK); if (!errors) {
strncpy((*result_p)->cmdStatus, cmdStatus, CMDSTATUS_LEN-1); *result_p = makeEmptyPGresult(conn,PGRES_COMMAND_OK);
strncpy((*result_p)->cmdStatus, cmdStatus, CMDSTATUS_LEN-1);
} else {
*result_p = (PGresult*)NULL;
}
done = true; done = true;
} }
} }
else { else {
*result_p = makeEmptyPGresult(conn, PGRES_EMPTY_QUERY); if (!errors) {
*result_p = makeEmptyPGresult(conn, PGRES_EMPTY_QUERY);
} else {
*result_p = (PGresult*)NULL;
}
done = true; done = true;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment