Skip to content

Commit

Permalink
Enable dbstat table by default (#580)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
pawurb and flavorjones authored Nov 19, 2024
1 parent 31cbbd9 commit 1d4cc9e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion ext/sqlite3/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
6 changes: 6 additions & 0 deletions test/test_database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -727,5 +727,11 @@ def test_sqlite_dbpage_vtab

assert_nothing_raised { @db.execute("select count(*) from sqlite_dbpage") }
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
end

0 comments on commit 1d4cc9e

Please sign in to comment.