tursodatabase / libsql

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

[C bindings] Prepared libsql_reset_stmt does not seem to work as expected #1481

Closed pdenapo closed 1 week ago

pdenapo commented 3 months ago

I have created a simple test program in C that creates an in memory database and inserts two records using prepared statetement

Please find it here

https://github.com/pdenapo/libsql-C-testing/blob/main/test_prepared_statements_minimal/test_psm.c

Compile using the compile.sh script after setting the environment variables like in my script at

https://github.com/pdenapo/libsql-C-testing/blob/main/set_env.sh

(adapted to the location of libsql in your system)

CREATE TABLE Persons(Name TEXT); insert_person (Paul) insert_person (Laura) Paul Laura

(You can find a similar program without using prepared statements at

https://github.com/pdenapo/libsql-C-testing/tree/main/test2 )

CREATE TABLE Persons(Name TEXT); insert_person (Paul) insert_person (Laura) Paul Paul

As you can see, the same record seems to have been inserted twice, so that libsql_reset_stmt seems not to be working as expected.

Of course there might be some stupid bug in my code. I'm just guessing the behavoir of the interfaces, since there is no actual documentation!

Also it would be very important to have a test suite for the bindings in order to assure the quality of the code. Your are wellcome to use my programs as an starting point.