Testing SQLite Fossil [0abdc2903d], sqlite_open_v2() returns SQLITE_PERM when 
trying to open a named memory database if the flag SQLITE_OPEN_CREATE is not 
passed. This is in contrast to unnamed memory databases. Is this intentional?

Basic C code below demonstrates the issue.

Ralf

------------------------------

sqlite3 *db = 0;


void check (int i) {
  switch (i) {
        case SQLITE_DONE:
        case  SQLITE_OK:
        case SQLITE_ROW:
          break;
  default:
         printf ("Error %d: %s\n", i, sqlite3_errmsg(db)) ;
  }
};


int main(int argc, char* argv[])
{
  char * fn;

  /* Test opening a named memory database using a URI file name. */
  fn = "file:test.db?cache=shared&mode=memory";
  check(sqlite3_open_v2(fn, &db,
    SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_URI, NULL));
  check(sqlite3_close(db));

  /* Test opening a named memory database using a URI file name.
     This fails because SQLITE_OPEN_CREATE is missing. */
  fn = "file:test.db?cache=shared&mode=memory";
  check(sqlite3_open_v2(fn, &db,
    SQLITE_OPEN_READWRITE | SQLITE_OPEN_URI, NULL));
  check(sqlite3_close(db));

  /* Test opening an unnamed memory database using a URI file name. */
  fn = "file::memory:?cache=shared";
  check(sqlite3_open_v2(fn, &db,
    SQLITE_OPEN_READWRITE | SQLITE_OPEN_URI, NULL));
  check(sqlite3_close(db));

  /* Test opening an unnamed memory database. */
  fn = ":memory:";
  check(sqlite3_open_v2(fn, &db,
    SQLITE_OPEN_READWRITE, NULL));
  check(sqlite3_close(db));
}
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to