I find that `PRAGMA table_info(tableName)` will not check the expired schema 
which is modified by other sqlite connections.


1. Open conn 1 and conn 2.
2. Run a SQL to load the schema for conn 2
3. Change the schema using conn 1 by create-table-statement.
4. Get the schema using conn 2 by table_info-pragma-statement.


As a result, step 4 could not get any things since the schema is expired but 
table_info-pragma-statement do not update it.
How to solve this problem ? Am I using SQLite in a wrong way ?


Here is the sample code:
```
sqlite3_config(SQLITE_CONFIG_MULTITHREAD);  
sqlite3* conn1;
rc = sqlite3_open(path.UTF8String, conn1);  
sqlite3* conn2;
rc = sqlite3_open(path.UTF8String, conn2);
assert(rc==0);
{
  //load schema
  rc = sqlite3_exec(conn2, "SELECT * FROM sqlite_master", nullptr, nullptr, 
nullptr);
  printf("rc %d\n", rc);
}
rc = sqlite3_exec(conn1, "CREATE TABLE test1 (i INTEGER)", NULL, NULL, NULL);
rc = sqlite3_exec(conn1, "INSERT INTO test1 VALUES(1)", NULL, NULL, NULL);
assert(rc==0);
sqlite3_stmt* stmt;
rc = sqlite3_prepare_v2(conn2, "PRAGMA table_info(test1)", -1, stmt, nullptr);
assert(rc==0);
while (YES) {
  int rc = sqlite3_step(stmt);
  if (rc!=SQLITE_ROW) {
    break;
  }
  for (int i = 0; i  sqlite3_column_count(stmt); i++) {
    switch (sqlite3_column_type(stmt, i)) {
      case SQLITE_TEXT:
        printf("%d %s\n", i, sqlite3_column_text(stmt, i));
        break;
      case SQLITE_INTEGER:
        printf("%d %d\n", i, sqlite3_column_int(stmt, i));
        break;
      default:
       printf("other\n");
        break;
    }
  }
}
sqlite3_finalize(stmt);
```
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to