tursodatabase / libsql

libSQL is a fork of SQLite that is both Open Source, and Open Contributions.

Home Page:https://turso.tech/libsql

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

pdenapo opened this issue · comments

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

  • Steps to reproduce it:

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)

  • Expected results

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 )

  • Actual results

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.