IO Short Read Error when inserting a TEXT column

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

IO Short Read Error when inserting a TEXT column

rgarnett
HiI am using sqLite3 on an embedded system (STM32H743VI) using, freeRTOS,
fatFS and an SD Card using the HAL Drivers and the SDMMC1 interface.The
database works fine with doubles, integers and chars, but as soon as I
attempt to insert a record with a bound text field the step function fails
with an IO Error Short Read.The VFS I am using I developed myself from the
demo on the sqLite website.  I suspect there may be problems with this code
as it was built with very little knowledge of the internals of sqLite.I
create the databases using sqLite Studio to avoid having to write code to
produce the data bases using the embedded system. I copy the databases with
no data onto the SD Card.The insert SQL string is const char
*insertIndexRecord  = "INSERT INTO tblMetaData VALUES (?1, ?2, ?3, ?4, ?5,
?6)"; The table has the automatic rowid field, and was created with the
following SQL statement:PRAGMA foreign_keys = 0;CREATE TABLE
sqlitestudio_temp_table AS SELECT *                                        
FROM tblMetaData;DROP TABLE tblMetaData;CREATE TABLE tblMetaData (  
dbFilename     TEXT    UNIQUE,    startJD_UTC    DOUBLE  NOT NULL                          
UNIQUE,    endJD_UTC      DOUBLE  UNIQUE                           NOT NULL,  
numRecords     INTEGER NOT NULL,    IndexRecJD_UTC DOUBLE,    recNum        
INTEGER PRIMARY KEY ASC AUTOINCREMENT                           NOT
NULL);INSERT INTO tblMetaData (                            dbFilename,                          
startJD_UTC,                            endJD_UTC,                          
numRecords,                            IndexRecJD_UTC,                          
recNum                        )                        SELECT dbFilename,                              
startJD_UTC,                               endJD_UTC,                              
numRecords,                               IndexRecJD_UTC,                              
recNum                          FROM sqlitestudio_temp_table;DROP TABLE
sqlitestudio_temp_table;CREATE UNIQUE INDEX endJD ON tblMetaData (  
startJD_UTC ASC);CREATE UNIQUE INDEX "" ON tblMetaData (    startJD_UTC
ASC);PRAGMA foreign_keys = 1;I thought that maybe the problem was my bind
statement not passing the text correctly, but I traced through the bind
function and it seemed to be OK.I suspect my VFS is the problem.  I am using
memsys5 with about 421k allocated for sqLite.  I am not running out of
memory.  I have two separate databases, one for the metaData and one for the
actual data. I only have one of them open at a time.Could anyone assist
please.I have attached the relevant files in a zip.Best regardsRob
sqLiteInsertTextProblem_001.zip
<http://sqlite.1065341.n5.nabble.com/file/t9217/sqLiteInsertTextProblem_001.zip>  



--
Sent from: http://sqlite.1065341.n5.nabble.com/
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: IO Short Read Error when inserting a TEXT column

Richard Hipp-3
On 1/28/20, rgarnett <[hidden email]> wrote:
> the step function fails
> with an IO Error Short Read.The VFS I am using I developed myself from the
> demo on the sqLite website.  I suspect there may be problems with this code

I suspect you are correct.

The SQLITE_IOERR_SHORT_READ is an error code that is only generated by
the VFS.  That means it is your code that is likely generating the
error.  I suggest you set a breakpoint on the place in your custom VFS
where the SQLITE_IOERR_SHORT_READ is being generated and try to figure
out what is going on.

--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users