-
Notifications
You must be signed in to change notification settings - Fork 74
(778) SQLITE_IOERR_WRITE when adding a table using UNIQUE or PRIMARY KEY on spiffs #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This library relies on the VFS layer of ESP32 for SPIFFS, SD_MMC and SD_SPI. I have not checked the code though to say that the problem is definitely not in this library. |
Wow, thanks for the super fast response! I'm unfortunately not very well read when it comes to VFS layers and how they operate. The literature suggests that you can choose which VFS you'd like to use with SQLite. https://sqlite.org/c3ref/vfs_find.html Are you aware of any others that I might be able to try in place of the default one? The thing that really doesn't make send to me is: If the SQLite is just manipulating a single .db file, why would it matter what is being written to the VFS layer. ie, wouldn't creating a database with or without constraints be the same as far as the file system is concerned? It's just writing bits to a file. |
Not sure if this is a clue or completely unrelated: I can't get the library to compile in Sloeber (basically Eclipse but uses the Arduino ESP32 core). Just including the library causes some errors: shox96_0_2.cpp - line 274:
|
You could overcome by changing the line to: It will take me some time to look into why it does not work with SPIFFS. |
@mr-wiggle I can confirm this happens for me as well. I'm not sure if the SPIFFS partition has anything to do with it or not, but I've located where the error occurs. I'm using the IDF version of this, which has a slightly different I traced it down to this: Arduino
|
@mr-wiggle @jason7sc |
@siara-cc thanks for responding. I'm using ESP-IDF, so I can't verify the changes for Arduino, but here are my results using the SPIFFS example from the esp-idf examples repo: I updated the sqlite library files and the config file, but I'm unable to create/open the database now. Using the old config, I can still open/create the database and perform the same operations as before, so the new sqlite library files don't appear to be the issue. I tried adding/modifying some config parameters I thought would be relevant, but still couldn't get it to work. Are there other config parameters that should be set for ESP-IDF? Here is the debug output for the disk I/O operations. It looks like fseek is failing at
|
I too am having issues with the updated library. I updated the Sqlite3Esp32 Library to 2.1.0 in Arduino IDE. I still get the i/o error (code 10) when creating a table using Version 2.1.0 is also creating memory issues in my project (which is in Sloeber IDE). It appears to be interfering with the WiFi ssl_client. I haven't had a chance to dig into it yet, but I'm getting error code 7 in sqlite (malloc failied) and this from the ssl client @siara-cc happy to do any testing you may need, just let me know! @jason7sc thanks for the sleuthing! |
@mr-wiggle Thanks. I am not sure why UNIQUE wouldn't work for you. Also I created a release 2.2 which does not seem to show up on the Library Manager. |
I tested using V2.3 and have the same issues (both with the Unique constraint causing the disk I/O error and with the memory issues ( malloc failed in Sqlite and memory allocation errors in the ssl_client ). Reverting back to V2.0 solved the memory issues. My test with V2.3 consisted of loading the example sketch "sqlite3_spiffs" and running it. It runs ok with all queries succeeding as loaded. Then added I'm using:
|
@mr-wiggle I will check what is going wrong. |
I've the same issue. I'm using an esp32 and the error come when i try to create a table with AUTOINCREMENT, no problem if i don't use this feature. |
This solution may solve your problems but I have not tried it: |
Same error with AUTOINCREMENT. I hadn't written it before but occasionally (always using spiffs) there is an I / O error |
Hi - I have the same error with AUTOINCREMENT using spiffs - it gives me an I / O error |
Updating the table don't work... |
@illosan Thanks for the info I tried it out using the spiffs example (modified) and it does work - I tried a restart before the end and you can see it continues to increment ␛[0;32mI (89501) sp: SQL : INSERT INTO test1(content) VALUES ('hello from ESP32 : 0 '); |
The problem is if you delete a line. With Autoincrement the id of the line is lost, without the next line you write will use the deleted id. |
I have a bit of info that I've found which might be helpful. I recently switched over to LittleFS from SPIFFS and I've found that I can successfully use things like UNIQUE now that I'm on the new file system. For those who aren't familiar LittleFS is a drop in replacement for SPIFFS and can be mounted on a spiffs partition on the ESP32. |
Please follow the solution here |
I am having an issue where I cannot add tables using UNIQUE or PRIMARY KEY. This produces an disk i/o error. my DB file is on SPIFFS. I do not have an SD card, so can't test if this happens on SD.
To reproduce the issue:
rc = db_exec(db1, "CREATE TABLE test1 (id INTEGER UNIQUE, content);");
From https://www.sqlite.org/rescode.html#ioerr_write:
And here's some info on the VFS layer: https://www.sqlite.org/vfs.html
I can't figure out why adding UNIQUE to the sql would cause a disk error. Even with debugging set to verbose, I'm not getting any more information. Using the console example, I was able to get the 778 error code when entering the same CREATE TABLE sql command, but I'm stuck there. I can't seem to get any more info.
Based on the nature of the 778 error being related to the VFS layer, it seems like the issue might be in the library.
Any thoughts?
The text was updated successfully, but these errors were encountered: