From 874b8bffdacad7b2ebea681a9d305e9414740c90 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Tue, 30 Jan 2024 20:53:44 -0500 Subject: [PATCH] CHANGELOG --- CHANGELOG.md | 1 + db/db.go | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b72567e5..b88713d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - [PR #1647](https://github.com/rqlite/rqlite/pull/1647): More CHECKPOINT test coverage. - [PR #1649](https://github.com/rqlite/rqlite/pull/1649): Check Leader when handling `/db/request` with _None_ read consistency. Fixes issue [#1648](https://github.com/rqlite/rqlite/issues/1648). - [PR #1653](https://github.com/rqlite/rqlite/pull/1653): Fix `busy_timeout` stat for read-only DB. Thanks @mauri870 +- [PR #1654](https://github.com/rqlite/rqlite/pull/1654): Memoize SQLite compilation options. ## 8.18.4 (January 30th 2024) ### Implementation changes and bug fixes diff --git a/db/db.go b/db/db.go index 36e0b885..9c1f4bcf 100644 --- a/db/db.go +++ b/db/db.go @@ -496,8 +496,13 @@ func (db *DB) WALPath() string { return db.walPath } +var compileOptions []string // Memoized compile options + // CompileOptions returns the SQLite compilation options. func (db *DB) CompileOptions() ([]string, error) { + if compileOptions != nil { + return compileOptions, nil + } res, err := db.QueryStringStmt("PRAGMA compile_options") if err != nil { return nil, err @@ -506,14 +511,14 @@ func (db *DB) CompileOptions() ([]string, error) { return nil, fmt.Errorf("compile options result wrong size (%d)", len(res)) } - copts := make([]string, len(res[0].Values)) - for i := range copts { + compileOptions = make([]string, len(res[0].Values)) + for i := range compileOptions { if len(res[0].Values[i].Parameters) != 1 { return nil, fmt.Errorf("compile options values wrong size (%d)", len(res)) } - copts[i] = res[0].Values[i].Parameters[0].GetS() + compileOptions[i] = res[0].Values[i].Parameters[0].GetS() } - return copts, nil + return compileOptions, nil } // ConnectionPoolStats returns database pool statistics