Re: BUG #5697: Infinite loop inside PQexecStart function - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #5697: Infinite loop inside PQexecStart function
Date
Msg-id 29983.1286466266@sss.pgh.pa.us
Whole thread Raw
In response to BUG #5697: Infinite loop inside PQexecStart function  ("Boris" <admin@nyc.yamaha.com>)
Responses Re: BUG #5697: Infinite loop inside PQexecStart function
List pgsql-bugs
"Boris" <admin@nyc.yamaha.com> writes:
> while ((result = PQgetResult(conn)) != NULL){
>     ExecStatusType resultStatus = result->resultStatus;
>     PQclear(result); /* only need its status */
>     /* check for loss of connection, too */
>     if (result->resultStatus == PGRES_COPY_IN ||
>                          result->resultStatus == PGRES_COPY_OUT ||
>                          conn->status == CONNECTION_BAD)
>                          break;
>     }

This code is broken: once you've done PQclear() it's unsafe to access
the PGresult.  I think you meant just "resultStatus" not
"result->resultStatus" in the if().

            regards, tom lane

pgsql-bugs by date:

Previous
From: "Boris"
Date:
Subject: BUG #5697: Infinite loop inside PQexecStart function
Next
From: Tom Lane
Date:
Subject: Re: BUG #5697: Infinite loop inside PQexecStart function