message: added -readonly support for cli THE NUMBER OF THE BEAST
diff: @@ -64,16 +64,31 @@ void sqlite3_randomness(int N, void *pBuf) {
  int sqlite3_open(const char *filename, /* Database filename (UTF-8) */
  sqlite3 **ppDb /* OUT: SQLite db handle */
  +) {
  + return sqlite3_open_v2(filename, ppDb, 0, NULL);
  +}
  +
  +int sqlite3_open_v2(const char *filename, /* Database filename (UTF-8) */
  + sqlite3 **ppDb, /* OUT: SQLite db handle */
  + int flags, /* Flags */
  + const char *zVfs /* Name of VFS module to use */
  ) {
  if (filename && strcmp(filename, ":memory:") == 0) {
  filename = NULL;
  }
  *ppDb = nullptr;
  -
  + if (zVfs) { /* unsupported so if set we complain */
  + return SQLITE_ERROR;
  + }
  sqlite3 *pDb = nullptr;
  try {
  pDb = new sqlite3();
  - pDb->db = make_unique<DuckDB>(filename);
  + DBConfig config;
  + config.access_mode = AccessMode::AUTOMATIC;
  + if (flags & SQLITE_OPEN_READONLY) {
  + config.access_mode = AccessMode::READ_ONLY;
  + }
  + pDb->db = make_unique<DuckDB>(filename, &config);
  pDb->con = make_unique<Connection>(*pDb->db);
  } catch (std::exception &ex) {
  if (pDb) {
  @@ -85,14 +100,6 @@ int sqlite3_open(const char *filename, /* Database filename (UTF-8) */
  return SQLITE_OK;
  }
  -int sqlite3_open_v2(const char *filename, /* Database filename (UTF-8) */
  - sqlite3 **ppDb, /* OUT: SQLite db handle */
  - int flags, /* Flags */
  - const char *zVfs /* Name of VFS module to use */
  -) {
  - return sqlite3_open(filename, ppDb);
  -}
  -
  int sqlite3_close(sqlite3 *db) {
  if (db) {
  delete db;
  