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

Commit8299e75

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 parent6399c74 commit8299e75

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,constchar*query)
364364
{
365365
PGresult*result;
366-
intid,clear;
366+
intid,clear,error;
367367
charbuffer[MAX_MESSAGE_LEN];
368368
charcmdStatus[MAX_MESSAGE_LEN];
369369
charpname[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
#ifdefPQ_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
returnresult;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp