mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-03 15:36:59 +02:00
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)
This commit is contained in:
parent
6399c74f17
commit
8299e75577
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.18 1996/09/16 05:50:46 scrappy Exp $
|
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.19 1996/11/20 22:35:19 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -363,7 +363,7 @@ PGresult*
|
|||||||
PQexec(PGconn* conn, const char* query)
|
PQexec(PGconn* conn, const char* query)
|
||||||
{
|
{
|
||||||
PGresult *result;
|
PGresult *result;
|
||||||
int id, clear;
|
int id, clear, error;
|
||||||
char buffer[MAX_MESSAGE_LEN];
|
char buffer[MAX_MESSAGE_LEN];
|
||||||
char cmdStatus[MAX_MESSAGE_LEN];
|
char cmdStatus[MAX_MESSAGE_LEN];
|
||||||
char pname[MAX_MESSAGE_LEN]; /* portal name */
|
char pname[MAX_MESSAGE_LEN]; /* portal name */
|
||||||
@ -459,6 +459,7 @@ PQexec(PGconn* conn, const char* query)
|
|||||||
// until an 'I' is received.
|
// until an 'I' is received.
|
||||||
*/
|
*/
|
||||||
clear = 0;
|
clear = 0;
|
||||||
|
error = 0;
|
||||||
|
|
||||||
pqPuts("Q ",pfout,pfdebug); /* send an empty query */
|
pqPuts("Q ",pfout,pfdebug); /* send an empty query */
|
||||||
#ifdef PQ_NOTIFY_PATCH
|
#ifdef PQ_NOTIFY_PATCH
|
||||||
@ -472,8 +473,19 @@ PQexec(PGconn* conn, const char* query)
|
|||||||
{
|
{
|
||||||
if (pqGets(buffer,ERROR_MSG_LENGTH,pfin,pfdebug) == 1)
|
if (pqGets(buffer,ERROR_MSG_LENGTH,pfin,pfdebug) == 1)
|
||||||
clear = 1;
|
clear = 1;
|
||||||
|
/*
|
||||||
|
// Rules can create error messages while we are waiting
|
||||||
|
// for the 'I'.
|
||||||
|
*/
|
||||||
|
if (buffer[0] == 'E') {
|
||||||
|
strcpy(conn->errorMessage, &buffer[1]);
|
||||||
|
error++;
|
||||||
|
}
|
||||||
clear = (buffer[0] == 'I');
|
clear = (buffer[0] == 'I');
|
||||||
}
|
}
|
||||||
|
if (error) {
|
||||||
|
return (PGresult*)NULL;
|
||||||
|
}
|
||||||
result = makeEmptyPGresult(conn,PGRES_COMMAND_OK);
|
result = makeEmptyPGresult(conn,PGRES_COMMAND_OK);
|
||||||
strncpy(result->cmdStatus,cmdStatus, CMDSTATUS_LEN-1);
|
strncpy(result->cmdStatus,cmdStatus, CMDSTATUS_LEN-1);
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user