In SQLITE there is a possibility to relatively easily create User-Defined Functions and Aggregates in (extension) languages such as C, Perl, Python and others. Is there also such possibility using common-lisp as SQLITE language extension? I know there are libraries like cl-sqlite and plain-odbc but they don't seem to offer this possibility.
+5
A:
When I wrote cl-sqlite, I hadn't thought about user-defined functions.
But it's actually pretty easy. It just takes to define callbacks, foreign functions and wrap them in lispy interface. I guess I'll add this feature to cl-sqlite soon.
dmitry_vk
2010-07-17 18:05:52
Thanks. I am glad it wouldn't be difficult. Actually meanwhile I wrote a C code that uses sqlite3_exec and in the callback I embedded some ECL (lisp implementation) C functions like ecl_cons(ecl_cstring_to_base_string_or_nil(p_fields[i]),...and call that in ECL using ffi:c-inline and ffi:clines. Then of course I could use the sqlite3_create_function in the C file on the C coded user-defined function. But in the updated cl-sqlite I believe it will be easier because the user will define the user-defined function in CL without getting too involved with the C code (maybe only through the CFFI).
francogrex
2010-07-20 20:42:27