pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Wei Weng <wweng@kencast.com>
To: Matthew Vanecek <mevanecek@yahoo.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: debug a mess
Date: Tue, 25 Feb 2003 15:58:20 -0500
Message-ID: <20030225155820.B24120@example.com> (raw)

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






view thread (9+ messages)  latest in thread

Message-ID: <20030225155820.B24120@example.com>
Permalink:  ../20030225155820.B24120@example.com/
Also on:    postgresql.org/message-id/20030225155820.B24120@example.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: wweng@kencast.com, mevanecek@yahoo.com
  Subject: Re: debug a mess
  In-Reply-To: <20030225155820.B24120@example.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox