apache / nuttx-apps

Apache NuttX Apps is a collection of tools, shells, network utilities, libraries, interpreters and can be used with the NuttX RTOS
https://nuttx.apache.org/
Apache License 2.0
268 stars 504 forks source link

database: add sqlite support #2297

Closed Gary-Hobson closed 5 months ago

Gary-Hobson commented 6 months ago

Summary

enable UTILS_SQLITE configuration, use the sqlite3 command line tool

Impact

Testing

sim

xiaoxiang781216 commented 6 months ago

@Gary-Hobson let's fix the style warning.

jturnsek commented 6 months ago

I am getting: /home/jernej/work/nuttx/apps/database/sqlite/build/sqlite3.c:180495:16: error: conflicting types for 'sqlite3_autovacuum_pages' 180495 | SQLITE_API int sqlite3_autovacuum_pages( | ^~~~~~~~ /home/jernej/work/nuttx/apps/database/sqlite/build/sqlite3.c:7144:16: note: previous declaration of 'sqlite3_autovacuum_pages' was here 7144 | SQLITE_API int sqlite3_autovacuum_pages( | ^~~~~~~~ make[2]: *** [/home/jernej/work/nuttx/apps/Application.mk:200: /home/jernej/work/nuttx/apps/database/sqlite/build/sqlite3.c.home.jernej.work.nuttx.apps.database.sqlite.o] Error 1

Any ideas?

jturnsek commented 6 months ago

If I change u32 types to unsigned int, it compiles ok.

jturnsek commented 6 months ago

Have you tried to use Sqlite on FAT filesystem (i.e. SDCARD). I am getting disk IO errors, because Sqlite opens test.db empty file and then tries to read header from it. Because file is empty fat_read function returns with negative value instead of 0. This is not the case when littlefs is used instead of FAT.

jturnsek commented 6 months ago

I recommend also SQLITE_HOMEGROWN_RECURSIVE_MUTEX option to be enabled.

jturnsek commented 6 months ago

NuttX FAT filesystem is returning EINVAL when empty file is opened and seek is performed on it. Sqlite expects 0 to be returned. This why we get disk I/O error when opening database file. Also FAT should be configured with long names support, otherwise xxx.db-journal file is not opened and Sqlite fails.

acassis commented 5 months ago

@Gary-Hobson please fix the coding style issues