Is it hard to support Julia UDFs in DuckDB?

Hmm, strange…
Using the example from @asbisen is the duckdata.db.wal file getting created after the function is called but the moment the garbage collector starts it disappears (and the error opening the database is gone.)
I was hoping the Stmt() handle created by execute() is the only thing that keeps the connection open but maybe there are more…

After a bit research I found some discussions that using finalizers for resource cleanup has some isseus (1, 2, 3 ) mostly because of garbage collection intervals.
And yeah, the current DuckDB julia package uses finalizers for cleanup.

Julia seems to lack a good way to have destructors that are based on the scope of variable (or at least that I’m aware of)

i think this just came up in the slack and Dave M. found the solution.

I guess you cant detach from the default database, so to release locks, one must attach to a different database eg to ":memory:" and use it?

it appears you dont need to use close!

julia> DBI.execute(db, "attach ':memory:' as memdb")
(Success = Bool[],)

julia> DBI.execute(db, "use memdb")
(Success = Bool[],)

julia> DBI.execute(db, "detach foo")
(Success = Bool[],)

shell> lsof foo.duckdb
lsof: WARNING: can't stat() tracefs file system /sys/kernel/debug/tracing
      Output information may be incomplete.
1 Like