Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8299e75

Browse files
committed
following is a little fix for libpq.
PQexec handles the possibility of multiple results from one query by simply submitting an empty query after the first result and waiting for an 'I' message. Rules can generate errors with transaction abort after the first 'C' message was recieved (e.g. if a C-language function used in a rule calls elog(WARN, ...)). Thus we have to look for. Jan(wieck@sapserv.debis.de)
1 parent 6399c74 commit 8299e75

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/interfaces/libpq/fe-exec.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.18 1996/09/16 05:50:46 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.19 1996/11/20 22:35:19 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -363,7 +363,7 @@ PGresult*
363363
PQexec(PGconn* conn, const char* query)
364364
{
365365
PGresult *result;
366-
int id, clear;
366+
int id, clear, error;
367367
char buffer[MAX_MESSAGE_LEN];
368368
char cmdStatus[MAX_MESSAGE_LEN];
369369
char pname[MAX_MESSAGE_LEN]; /* portal name */
@@ -459,6 +459,7 @@ PQexec(PGconn* conn, const char* query)
459459
// until an 'I' is received.
460460
*/
461461
clear = 0;
462+
error = 0;
462463

463464
pqPuts("Q ",pfout,pfdebug); /* send an empty query */
464465
#ifdef PQ_NOTIFY_PATCH
@@ -472,8 +473,19 @@ PQexec(PGconn* conn, const char* query)
472473
{
473474
if (pqGets(buffer,ERROR_MSG_LENGTH,pfin,pfdebug) == 1)
474475
clear = 1;
476+
/*
477+
// Rules can create error messages while we are waiting
478+
// for the 'I'.
479+
*/
480+
if (buffer[0] == 'E') {
481+
strcpy(conn->errorMessage, &buffer[1]);
482+
error++;
483+
}
475484
clear = (buffer[0] == 'I');
476485
}
486+
if (error) {
487+
return (PGresult*)NULL;
488+
}
477489
result = makeEmptyPGresult(conn,PGRES_COMMAND_OK);
478490
strncpy(result->cmdStatus,cmdStatus, CMDSTATUS_LEN-1);
479491
return result;

0 commit comments

Comments
 (0)