Skip to content

Commit

Permalink
Keeping the read-only check when database object created
Browse files Browse the repository at this point in the history
  • Loading branch information
qiaoyuang committed Oct 18, 2023
1 parent 11dffb7 commit 9ac2db2
Showing 1 changed file with 3 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,7 @@ import cnames.structs.sqlite3
import cnames.structs.sqlite3_stmt
import com.ctrip.sqllin.driver.DatabaseConfiguration
import com.ctrip.sqllin.driver.sqliteException
import com.ctrip.sqllin.sqlite3.SQLITE_DBCONFIG_LOOKASIDE
import com.ctrip.sqllin.sqlite3.SQLITE_OK
import com.ctrip.sqllin.sqlite3.SQLITE_OPEN_CREATE
import com.ctrip.sqllin.sqlite3.SQLITE_OPEN_READWRITE
import com.ctrip.sqllin.sqlite3.SQLITE_OPEN_URI
import com.ctrip.sqllin.sqlite3.sqlite3_busy_timeout
import com.ctrip.sqllin.sqlite3.sqlite3_close_v2
import com.ctrip.sqllin.sqlite3.sqlite3_db_config
import com.ctrip.sqllin.sqlite3.sqlite3_errmsg
import com.ctrip.sqllin.sqlite3.sqlite3_exec
import com.ctrip.sqllin.sqlite3.sqlite3_open_v2
import com.ctrip.sqllin.sqlite3.sqlite3_prepare16_v2
import com.ctrip.sqllin.sqlite3.*
import kotlinx.cinterop.*

/**
Expand Down Expand Up @@ -70,10 +59,10 @@ internal class NativeDatabase private constructor(val dbPointer: CPointer<sqlite
}

// Check that the database is really read/write when that is what we asked for.
/*if ((sqliteFlags and SQLITE_OPEN_READWRITE > 0) && sqlite3_db_readonly(db, null) != 0) {
if (!configuration.isReadOnly && sqlite3_db_readonly(db, null) != 0) {
sqlite3_close_v2(db)
throw sqliteException("Could not open the database in read/write mode")
}*/
}

// Set the default busy handler to retry automatically before returning SQLITE_BUSY.
val err = sqlite3_busy_timeout(db, configuration.busyTimeout)
Expand Down

0 comments on commit 9ac2db2

Please sign in to comment.