Re: debug a mess - Mailing list pgsql-interfaces

From Wei Weng
Subject Re: debug a mess
Date
Msg-id 20030225155820.B24120@example.com
Whole thread Raw
In response to debug a mess  (Wei Weng <wweng@kencast.com>)
Responses Re: debug a mess
Re: debug a mess
List pgsql-interfaces
On 25/02/03 14:29 -0600, Matthew Vanecek wrote:
> It sounds like you've executed a query or command, and have not called
> PQclear(result) on the results.  Whenever I've gottten that error, not
> clearing the results has always been the root cause.  Make sure result
> is not NULL first, of course...
> 
>
The entire code from PQconnect until PQfinish goes like this:
   pgconn = PQconnect(init_string);
   res = PQexec(pgconn, my_query);
   if (res == NULL)       quit;
   switch( PQresultStatus(res) )   {       case ... goto _end;       case ... goto _end;       ...       default ...
goto_end;   }
 
   PQclear(res);   res = NULL;

_end:   if (res)       PQclear(res);
   PQfinish(pgconn);


This is pretty much the skeleton of the code, as you can see, I treat res
pretty carefully, PQclear it whenever necessary.

Thanks


Wei





pgsql-interfaces by date:

Previous
From: Matthew Vanecek
Date:
Subject: Re: ECPG and C++ compilation
Next
From: "Jeroen T. Vermeulen"
Date:
Subject: Re: debug a mess