Skip to content

Commit 1d4cc9e

Browse files
pawurbflavorjones
andauthored
Enable dbstat table by default (#580)
* Enable dbstat table by default * Add dbstat test * test: skip dbstat test unless we're using our packaged libraries because system libraries may not have this enabled * doc: update changelog for #580 --------- Co-authored-by: Mike Dalessio <[email protected]>
1 parent 31cbbd9 commit 1d4cc9e

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Added
66

77
- 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
8+
- 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
89
- `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
910
- `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
1011

ext/sqlite3/extconf.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ def configure_packaged_libraries
6363
"-fvisibility=hidden", # see https://github.com/rake-compiler/rake-compiler-dock/issues/87
6464
"-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1",
6565
"-DSQLITE_USE_URI=1",
66-
"-DSQLITE_ENABLE_DBPAGE_VTAB=1"
66+
"-DSQLITE_ENABLE_DBPAGE_VTAB=1",
67+
"-DSQLITE_ENABLE_DBSTAT_VTAB=1"
6768
]
6869
env["CFLAGS"] = [user_cflags, env["CFLAGS"], more_cflags].flatten.join(" ")
6970
recipe.configure_options += env.select { |k, v| ENV_ALLOWLIST.include?(k) }

test/test_database.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,5 +727,11 @@ def test_sqlite_dbpage_vtab
727727

728728
assert_nothing_raised { @db.execute("select count(*) from sqlite_dbpage") }
729729
end
730+
731+
def test_dbstat_table_exists
732+
skip("dbstat not supported") unless SQLite3::SQLITE_PACKAGED_LIBRARIES
733+
734+
assert_nothing_raised { @db.execute("select * from dbstat") }
735+
end
730736
end
731737
end

0 commit comments

Comments
 (0)