Thread: prepared statement results don't clear?

prepared statement results don't clear?

From
David Rysdam
Date:
I have a Tcl function that does this:

1) create prepared statement for binary insertion via pg_exec (and
releases the result handle)
2) run statement with binary data via pg_exec_prepared (and releases the
result handle)
3) deallocate statement via pg_exec (and releases the result handle)

When I try to run this function a couple hundred times, I get "had limit
on result handles reached" after 128 successes.  It seems something is
not being released.  To make absolutely sure it's not me that's leaving
something out there, I output a line each time I either create or
destroy a result handle and they add up perfectly.  Furthermore, all the
pg_execs go through another function that has been well-exercised, so I
don't think the problem is there.

The only thing I can think of is that a prepared statement (or the Tcl
specific pg_exec_prepared) has, like, a "double" result handle (one for
the statement itself and one for the exec'ing thereof).  Kind of a
half-assed theory, but necessity is the mother of such invention.  Does
anyone else have any better ideas for locating the result handle leak?


Re: prepared statement results don't clear?

From
Michael Fuhr
Date:
On Tue, Jan 17, 2006 at 03:37:14PM -0500, David Rysdam wrote:
> I have a Tcl function that does this:
>
> 1) create prepared statement for binary insertion via pg_exec (and
> releases the result handle)
> 2) run statement with binary data via pg_exec_prepared (and releases the
> result handle)
> 3) deallocate statement via pg_exec (and releases the result handle)
>
> When I try to run this function a couple hundred times, I get "had limit
> on result handles reached" after 128 successes.  It seems something is
> not being released.

Can you post a simple test case?  I can provoke "hard limit on
result handles reached" by not clearing results, but so far I haven't
seen that error if I do clear all results.

What versions of PostgreSQL, Tcl, and pgtcl are you using, and on
what platform?  I tested with PostgreSQL 8.1.2, Tcl 8.4.11, and
pgtcl 1.5 on FreeBSD 6.0.

--
Michael Fuhr

Re: prepared statement results don't clear?

From
David Rysdam
Date:
Michael Fuhr wrote:

>On Tue, Jan 17, 2006 at 03:37:14PM -0500, David Rysdam wrote:
>
>
>>I have a Tcl function that does this:
>>
>>1) create prepared statement for binary insertion via pg_exec (and
>>releases the result handle)
>>2) run statement with binary data via pg_exec_prepared (and releases the
>>result handle)
>>3) deallocate statement via pg_exec (and releases the result handle)
>>
>>When I try to run this function a couple hundred times, I get "had limit
>>on result handles reached" after 128 successes.  It seems something is
>>not being released.
>>
>>
>
>Can you post a simple test case?  I can provoke "hard limit on
>result handles reached" by not clearing results, but so far I haven't
>seen that error if I do clear all results.
>
>
Sorry, I was wrong.  I had a connection leak that was hidden because my
accounting procedure and the actual code made different assumptions.