Re: [database-devel] PGclear

You don't need to; PGclear is called automatically some time after the
Result is garbage collected. This is done by using PQclear as a finalizer
on the foreign pointer that represents a Result:
http://hackage.haskell.org/packages/archive/postgresql-libpq/0.8.2/doc/html/...
There is "unsafeFreeResult", which triggers the finalizer at a
deterministic point in time. But I don't recommend it's use unless you
really understand the basics of GHC's implementation : you can easily have
a reference to the Result sitting around in a thunk even "after" you have
computed some value from the Result and thrown away all other references.
(Because, in fact, you haven't computed the value completely; some part
of that value is actually a thunk that needs the Result to compute the rest
of the value.) And even then, I'm skeptical that very many
applications would truly benefit from it's use.
Best,
Leon
On Fri, Jun 8, 2012 at 3:03 PM, Kirk Peterson
Hi Leon,
I'm working with your haskell postgresql-libpq package and noticed that the examples form: http://www.postgresql.org/docs/9.1/static/libpq-example.html release a Result using the PGclear() function, however there is no clear function in postgresql-libpq.
I'm new to libpq in general, so perhaps this is an easy question: what is the idiomatic way to clear a result using postgresql-libpq?
cheers, -kirk
-- ⑆gmail.com⑆necrobious⑈
participants (1)
-
Leon Smith