From e315dfdab42861768907226129bbaed5edc8ddec Mon Sep 17 00:00:00 2001 From: pawurb Date: Mon, 18 Nov 2024 21:34:53 +0100 Subject: [PATCH 1/4] [#573] Enable dbstat table by default --- ext/sqlite3/extconf.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/sqlite3/extconf.rb b/ext/sqlite3/extconf.rb index 88f86d14..c3eb3716 100644 --- a/ext/sqlite3/extconf.rb +++ b/ext/sqlite3/extconf.rb @@ -63,7 +63,8 @@ def configure_packaged_libraries "-fvisibility=hidden", # see https://github.com/rake-compiler/rake-compiler-dock/issues/87 "-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1", "-DSQLITE_USE_URI=1", - "-DSQLITE_ENABLE_DBPAGE_VTAB=1" + "-DSQLITE_ENABLE_DBPAGE_VTAB=1", + "-DSQLITE_ENABLE_DBSTAT_VTAB=1" ] env["CFLAGS"] = [user_cflags, env["CFLAGS"], more_cflags].flatten.join(" ") recipe.configure_options += env.select { |k, v| ENV_ALLOWLIST.include?(k) } From 07d3e9b7355e1f79d6e5536d0696a312c0a1d9c6 Mon Sep 17 00:00:00 2001 From: pawurb Date: Tue, 19 Nov 2024 10:37:55 +0100 Subject: [PATCH 2/4] Add dbstat test --- test/test_database.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/test_database.rb b/test/test_database.rb index 583f0cce..b7d676c5 100644 --- a/test/test_database.rb +++ b/test/test_database.rb @@ -727,5 +727,9 @@ def test_sqlite_dbpage_vtab assert_nothing_raised { @db.execute("select count(*) from sqlite_dbpage") } end + + def test_dbstat_table_exists + assert_nothing_raised { @db.execute("select * from dbstat") } + end end end From b8230f3532f2afa938a6f6b9b23024c158080fa1 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Tue, 19 Nov 2024 17:06:41 -0500 Subject: [PATCH 3/4] test: skip dbstat test unless we're using our packaged libraries because system libraries may not have this enabled --- test/test_database.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_database.rb b/test/test_database.rb index b7d676c5..27f0479a 100644 --- a/test/test_database.rb +++ b/test/test_database.rb @@ -729,6 +729,8 @@ def test_sqlite_dbpage_vtab end def test_dbstat_table_exists + skip("dbstat not supported") unless SQLite3::SQLITE_PACKAGED_LIBRARIES + assert_nothing_raised { @db.execute("select * from dbstat") } end end From 29eb24847ad0de652166ee7f28ef2b9d188e92f3 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Tue, 19 Nov 2024 17:11:56 -0500 Subject: [PATCH 4/4] doc: update changelog for #580 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23fe9f0c..c289d6cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Added - The SQLITE_DBPAGE extension is now enabled by default, which implements an eponymous-only virtual table that provides direct access to the underlying database file by interacting with the pager. See https://www.sqlite.org/dbpage.html for more information. [#578] @flavorjones +- The DBSTAT extension is now enabled by default, which implements a read-only eponymous virtual table that returns information about the amount of disk space used to store the content of an SQLite database. See https://sqlite.org/dbstat.html for more information. [#580] @pawurb @flavorjones - `Database#optimize` which wraps the `pragma optimize;` statement. Also added `Constants::Optimize` to allow advanced users to pass a bitmask of options. See https://www.sqlite.org/pragma.html#pragma_optimize. [#572] @alexcwatt @flavorjones - `SQLite3::VERSION_INFO` is a new constant that tracks a bag of metadata about the gem and the sqlite library used. `SQLite3::SQLITE_PACKAGED_LIBRARIES` and `SQLite3::SQLITE_PRECOMPILED_LIBRARIES` are new constants indicating how the gem was built. [#581] @flavorjones