Reputation: 11
I'm new to Sqlite3. I'm using the C++ interface, specifically the amalgamation. The database is being created in a tmp folder with rw permissions, specifically 0x644. When I go to write the table, I get the error SQLITE_IOERR_LOCK (3850). I'm running on QNX os. What can I do to resolve this?
Thanks!
bool myApp::Start()
{
bool retVal = false;
int rc, ret;
char sql [] = "CREATE TABLE IF NOT EXISTS ZPL_CMDS(" \
"id INT PRIMARY KEY NOT NULL," \
"myCount INT NOT NULL );" ;
char *zErrMsg = 0;
// initialize engine
if (SQLITE_OK != (ret = sqlite3_initialize()))
{
printf("Failed to initialize library: %d\n", ret);
} else {
printf("SQLITE3 library Initialized!\n");
}
rc = sqlite3_open("/tmp/zplCmd.db", &db);
if(!sqlite3_extended_result_codes(db, 1))
{
printf("SQLITE3: extended result codes turned ONs\n");
}
else
{
printf("SQLITE3: extended result codes turned OFF\n");
}
if( rc ){
printf("Can't open database: %s\n", sqlite3_errmsg(db));
return(0);
}else{
printf("Opened database successfully: %s\n", sqlite3_errmsg(db));
}
/* write tables */
rc = sqlite3_exec(db, sql, NULL, 0, NULL); // <-- my code fails here
if( rc != SQLITE_OK ){
printf("SQL error: %s, %d\n", sqlite3_errmsg(db), rc);
sqlite3_free(zErrMsg);
} else {
printf("Table created successfully\n");
}
return retVal; }
Upvotes: 0
Views: 724
Reputation: 11
The issue is with the locking mechanism under QNX
rc = sqlite3_open_v2(path.c_str(), &database, SQLITE_OPEN_READWRITE,"unix-none") worked for me
The VFS option "unix-none" disables the locking mechanism.
More detail on why here: https://www.sqlite.org/vfs.html
Upvotes: 1