X-Original-To: pgsql-interfaces@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 75742475A97 for ; Tue, 25 Feb 2003 16:12:42 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 88859-10 for ; Tue, 25 Feb 2003 16:12:31 -0500 (EST) Received: from localhost.localdomain (167.95.252.64.snet.net [64.252.95.167]) by postgresql.org (Postfix) with ESMTP id B3024475C2B for ; Tue, 25 Feb 2003 15:57:39 -0500 (EST) Received: (from wweng@localhost) by localhost.localdomain (8.11.6/8.11.6) id h1PKwKG24138; Tue, 25 Feb 2003 15:58:20 -0500 X-Authentication-Warning: localhost.localdomain: wweng set sender to wweng@kencast.com using -f Date: Tue, 25 Feb 2003 15:58:20 -0500 From: Wei Weng To: Matthew Vanecek Cc: pgsql-interfaces@postgresql.org Subject: Re: debug a mess Message-ID: <20030225155820.B24120@example.com> Reply-To: Wei Weng Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/107 X-Sequence-Number: 3728 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