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?