Re: BUG #5697: Infinite loop inside PQexecStart function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Boris" <admin(at)nyc(dot)yamaha(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5697: Infinite loop inside PQexecStart function
Date: 2010-10-07 15:44:26
Message-ID: 29983.1286466266@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Boris" <admin(at)nyc(dot)yamaha(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Boris Bondarenko 2010-10-07 15:51:36 Re: BUG #5697: Infinite loop inside PQexecStart function
Previous Message Dave Page 2010-10-07 14:10:52 Re: BUG #5696: cannot upgrade to 9.0.1