如何解决 Sqlite3 扩展错误SQLITE_IOERR_LOCK (3850)



我是Sqlite3的新手。我正在使用C++界面,特别是合并。数据库是在具有 rw 权限(特别是 0x644(的 tmp 文件夹中创建的。当我去写表时,我得到错误SQLITE_IOERR_LOCK (3850(。我运行的是 QNX 操作系统。我该怎么做才能解决这个问题?

谢谢!

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: %dn", 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 ONsn");
  }
  else
  {
     printf("SQLITE3: extended result codes turned OFFn");
  }
  if( rc ){
      printf("Can't open database: %sn", sqlite3_errmsg(db));
      return(0);
  }else{
  printf("Opened database successfully: %sn", 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, %dn", sqlite3_errmsg(db), rc);
   sqlite3_free(zErrMsg);
   } else {
     printf("Table created successfullyn");
   }

返回 retVal;}

问题出在 QNX 下的锁定机制上

rc = sqlite3_open_v2(path.c_str(), &database, SQLITE_OPEN_READWRITE,"unix-none") worked for me

VFS 选项"unix-none"禁用锁定机制。

有关原因的更多详细信息:https://www.sqlite.org/vfs.html

相关内容

  • 没有找到相关文章

最新更新