1
0
Fork 0

Merge pull request #836 from rqlite/add-wal-status

Add current SQLite journal mode to status output
master
Philip O'Toole 3 years ago committed by GitHub
commit 1e4e1e06e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,7 +2,8 @@
### Implementation changes and bug fixes
- [PR #827](https://github.com/rqlite/rqlite/pull/827): Upgrade dependencies, including SQLite to 3.36.
- [PR #835](https://github.com/rqlite/rqlite/pull/835): Use Go standard libary sql/database abstraction. Fixes [issue #830](https://github.com/rqlite/rqlite/issues/830).
- [PR #835](https://github.com/rqlite/rqlite/pull/835): Use SQLite connection pool.
- [PR #835](https://github.com/rqlite/rqlite/pull/835): Use SQLite connection pool and add pool statistics to status output.
- [PR #836](https://github.com/rqlite/rqlite/pull/836): Add current SQLite journal mode to status output.
## 6.0.1 (June 28th 2021)
### Implementation changes and bug fixes

@ -27,6 +27,7 @@ const (
fkChecks = "PRAGMA foreign_keys"
fkChecksEnabled = "PRAGMA foreign_keys=ON"
fkChecksDisabled = "PRAGMA foreign_keys=OFF"
journalCheck = "PRAGMA journal_mode"
numExecutions = "executions"
numExecutionErrors = "execution_errors"
@ -232,6 +233,15 @@ func (db *DB) FKConstraints() (bool, error) {
return false, nil
}
// JournalMode returns the current journal mode.
func (db *DB) JournalMode() (string, error) {
r, err := db.QueryStringStmt(journalCheck)
if err != nil {
return "", err
}
return r[0].Values[0][0].(string), nil
}
// Size returns the size of the database in bytes. "Size" is defined as
// page_count * schema.page_size.
func (db *DB) Size() (int64, error) {

@ -762,6 +762,34 @@ func Test_ForeignKeyConstraints(t *testing.T) {
}
}
func Test_JournalMode(t *testing.T) {
db, path := mustCreateDatabase()
defer db.Close()
defer os.Remove(path)
m, err := db.JournalMode()
if err != nil {
t.Fatalf("failed to check journal mode: %s", err.Error())
}
if exp, got := "delete", m; exp != got {
t.Fatalf("got wrong mode for journal, expected %s, got %s", exp, got)
}
_, err = db.ExecuteStringStmt(`PRAGMA journal_mode=off`)
if err != nil {
t.Fatalf(`failed to execute 'PRAGMA journal_mode' statement: %s`, err.Error())
}
m, err = db.JournalMode()
if err != nil {
t.Fatalf("failed to check journal mode: %s", err.Error())
}
if exp, got := "off", m; exp != got {
t.Fatalf("got wrong mode for journal, expected %s, got %s", exp, got)
}
}
func Test_UniqueConstraints(t *testing.T) {
db, path := mustCreateDatabase()
defer db.Close()

@ -459,12 +459,17 @@ func (s *Store) Stats() (map[string]interface{}, error) {
if err != nil {
return nil, err
}
jm, err := s.db.JournalMode()
if err != nil {
return nil, err
}
dbStatus := map[string]interface{}{
"dsn": s.dbConf.DSN,
"fk_constraints": enabledFromBool(fkEnabled),
"version": sql.DBVersion,
"db_size": dbSz,
"conn_pool_stats": s.db.ConnectionPoolStats(),
"journal_mode": jm,
}
if s.dbConf.Memory {
dbStatus["path"] = ":memory:"

Loading…
Cancel
Save