Skip site navigation (1) Skip section navigation (2)

Re: debug a mess

From: Wei Weng <wweng(at)kencast(dot)com>
To: Matthew Vanecek <mevanecek(at)yahoo(dot)com>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: debug a mess
Date: 2003-02-25 20:58:20
Message-ID: 20030225155820.B24120@example.com (view raw or flat)
Thread:
Lists: 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




Responses

pgsql-interfaces by date

Next:From: Jeroen T. VermeulenDate: 2003-02-25 21:24:26
Subject: Re: debug a mess
Previous:From: Matthew VanecekDate: 2003-02-25 20:44:45
Subject: Re: ECPG and C++ compilation

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group