小编owl*_*wl7的帖子

在finalize/close期间,sqlite3_column_text返回的数据被破坏

我不确定这里发生了什么,但我发现在finalize/close sqlite阶段,sqlite3_column_text返回的数据正在被更改.

  // rc not handled in this abbreviated code

  sqlite3 *db;
  sqlite3_stmt *stmt;
  char * sql;

  const char * tail;
  int rc;

  char * dbName = "C:\\db\\myblobs.db";
  int myIndex = 0;

  char * myLocation1;
  string myLocation2;   

  rc = sqlite3_open(dbName, &db);

  sql = "SELECT location FROM blobs WHERE key = ?";
  rc = sqlite3_prepare(db, sql, strlen(sql), &stmt, &tail);
  sqlite3_bind_int(stmt, 1, myIndex);
  rc = sqlite3_step(stmt);

  myLocation1 = (char*)sqlite3_column_text(stmt, 0);
  myLocation2 = (char*)sqlite3_column_text(stmt, 0);

  // can process myLocation1 & myLocation2 fine here …
Run Code Online (Sandbox Code Playgroud)

c sqlite

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

c ×1

sqlite ×1