> if you pass an SQL string to sqlite3:for-each-row as the statement, the
> code compiles this string creating a temporary statement handle which is
> then finalized upon exit from the dynamic scope of sqlite3:for-each-row
> using a dynamic-wind construct.
That makes perfect sense, I understand the problem now.
I've settled down on the following style:
(define (db-exec db sql)
(iterator->stream
(lambda (collect _)
(receive (stmt rest)
(sqlite3:prepare db sql)
(sqlite3:for-each-row (compose c vector) stmt)
(sqlite3:finalize! stmt)))))
This is because my code just calls db-exec with the SQL string and the
DB handle and expectes db-exec to return the stream with the results.
If I where to use sqlite3:call-with-temporary-statements, I would have
to make changes to all my code, not just to the db-exec function.
I have one question, though. In the unlikely chance that a stream
returned by db-exec doesn't get traversed until the end, the call to
sqlite3:finalize! won't be made. Will the garbage collector take care
of finalizing the sqlite3:statement (by means of a finalizer on the
statement object) anyway?
Thanks for your help, Thomas!
Alejo.
http://azul.freaks-unidos.net/
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users