turso icon indicating copy to clipboard operation
turso copied to clipboard

SQLite C API improvements

Open penberg opened this issue 1 year ago • 3 comments

The SQLite C API in the limbo_sqlite3 crate is very basic. Let's improve it to cover enough to run some basic applications.

penberg avatar Jul 07 '24 09:07 penberg

I'd like to take on this task, but just to clarify, what would be considered not basic?

misterclayt0n avatar Dec 10 '24 16:12 misterclayt0n

@misterclayt0n, nice! I think things like backup API, user defined functions, and things like that are probably best tackled later. What we need is basics like sqlite3_prepare(), sqlite_bind_*(), sqlite_column_*(), and others like that to get most apps going.

penberg avatar Dec 10 '24 17:12 penberg

Add sqlite3_bind_int64 implementation

Hello, @penberg!

I've just implemented sqlite3_bind_int64. The approach I took was:

  • I introduced a HashMap inside Statement instead of storing Value<'a> directly.
  • The HashMap stores OwnedValue for each parameter (index → value) so we don't run into lifetime issues.

I'd like to confirm if this HashMap + OwnedValue approach for parameter binding aligns with your vision—this seemed logical to avoid 'a complexity and to store parameter values persistently. What do you think?

misterclayt0n avatar Dec 16 '24 18:12 misterclayt0n

I quickly looked into this, and, to have a fully functional Java JDBC driver based on the SQLite3 C compatibility layer there are a few missing APIs:

  • [x] sqlite3_changes64
  • [x] sqlite3_column_table_name
  • [x] sqlite3_table_column_metadata
  • [ ] sqlite3_result_int
  • [ ] sqlite3_value_int
  • [ ] sqlite3_busy_handler
  • [ ] sqlite3_update_hook
  • [ ] sqlite3_commit_hook
  • [ ] sqlite3_rollback_hook

Seems like the sqlite3 subfolder went a little outdated, and I couldn't find automatic tests in CI. The next step would be to figure out how to handle the callbacks, is there any example I can refer to?

andreaTP avatar Sep 09 '25 14:09 andreaTP