tursodatabase / libsql

libSQL is a fork of SQLite that is both Open Source, and Open Contributions.
https://turso.tech/libsql
MIT License
9.55k stars 252 forks source link

[C Bindings] Missing reset prepared statement #1416

Closed ospfranco closed 4 months ago

ospfranco commented 4 months ago

On the original sqlite source you can re-use a statement by calling [sqlite3_reset](https://www.sqlite.org/c3ref/reset.html#:~:text=The%20sqlite3_reset()%20function%20is,()%20to%20reset%20the%20bindings.). This is useful as a performance optimization to speed up already planned queries that only need to re-execute.

Currently there is no way to reset a libsql statement, only free it.

CleanShot 2024-05-25 at 07 46 34@2x

I need the reset function to be able to restart a prepared statement.

haaawk commented 4 months ago

I don't think prepared statements are any faster in libsql so this probably won't make any performance difference.

ospfranco commented 4 months ago

Interesting, still, I need to reset the statement otherwise I need to do a lot of memory copying every time to create new statements every time. Do you think it is easy to expose a reset function?

haaawk commented 4 months ago

I think so. Let me have a look and get back to you.

haaawk commented 4 months ago

Let me know @ospfranco if https://github.com/tursodatabase/libsql/pull/1419 would be enough?

ospfranco commented 4 months ago

I think so