Module: SQLite3
Constant Summary
-
SQLITE_LOADED_VERSION =
# File 'ext/sqlite3/sqlite3.c', line 247
(String) The version of the sqlite3 library loaded at runtime (e.g., "3.46.1")
rb_obj_freeze(rb_str_new2(sqlite3_libversion()))
-
SQLITE_PACKAGED_LIBRARIES =
# File 'ext/sqlite3/sqlite3.c', line 250Qtrue -
SQLITE_PRECOMPILED_LIBRARIES =
# File 'ext/sqlite3/sqlite3.c', line 256Qtrue -
SQLITE_VERSION =
# File 'ext/sqlite3/sqlite3.c', line 241
(String) The version of the sqlite3 library compiled with (e.g., "3.46.1")
rb_obj_freeze(rb_str_new2(SQLITE_VERSION))
-
SQLITE_VERSION_NUMBER =
# File 'ext/sqlite3/sqlite3.c', line 244
(Integer) The version of the sqlite3 library compiled with (e.g., 346001)
INT2FIX(SQLITE_VERSION_NUMBER)
-
VERSION =
# File 'lib/sqlite3/version.rb', line 3
(String) the version of the sqlite3 gem, e.g. "2.1.1"
"2.10.2" -
VERSION_INFO =
# File 'lib/sqlite3/version_info.rb', line 4
a hash of descriptive metadata about the current version of the sqlite3 gem, deeply frozen so that it can be read from any Ractor
{ ruby: RUBY_DESCRIPTION, gem: { version: SQLite3::VERSION.freeze }.freeze, sqlite: { compiled: SQLite3::SQLITE_VERSION, loaded: SQLite3::SQLITE_LOADED_VERSION, packaged: SQLite3::SQLITE_PACKAGED_LIBRARIES, precompiled: SQLite3::SQLITE_PRECOMPILED_LIBRARIES, sqlcipher: SQLite3.sqlcipher?, threadsafe: SQLite3.threadsafe? }.freeze }.freeze
Class Attribute Summary
-
.ractor_safe? ⇒ Boolean
readonly
Returns true if the extension declared itself Ractor-safe.
- .sqlcipher? ⇒ Boolean readonly
-
.threadsafe
readonly
Returns the compile time setting of the SQLITE_THREADSAFE flag.
-
.threadsafe? ⇒ Boolean
readonly
Was sqlite3 compiled with thread safety on?
Class Method Summary
- .libversion
-
.status(parameter) → Hash)
Queries the
SQLite3library for run-time status information.
Class Attribute Details
.ractor_safe? ⇒ Boolean (readonly)
Returns true if the extension declared itself Ractor-safe. That needs SQLite compiled thread-safe and Ruby 3.4 or later, which has rb_thread_lock_native_thread (see lock_native_thread in exception.c).
# File 'ext/sqlite3/sqlite3.c', line 105
static VALUE
ractor_safe_p(VALUE UNUSED(klass))
{
#if defined(HAVE_RB_EXT_RACTOR_SAFE) && defined(HAVE_RB_THREAD_LOCK_NATIVE_THREAD)
return sqlite3_threadsafe() ? Qtrue : Qfalse;
#else
return Qfalse;
#endif
}
.sqlcipher? ⇒ Boolean (readonly)
[ GitHub ]
# File 'ext/sqlite3/sqlite3.c', line 82
static VALUE
using_sqlcipher(VALUE UNUSED(klass))
{
#ifdef USING_SQLCIPHER
return Qtrue;
#else
return Qfalse;
#endif
}
.threadsafe (readonly)
Returns the compile time setting of the SQLITE_THREADSAFE flag. See: https://www.sqlite.org/c3ref/threadsafe.html
# File 'ext/sqlite3/sqlite3.c', line 95
static VALUE
threadsafe_p(VALUE UNUSED(klass))
{
return INT2NUM(sqlite3_threadsafe());
}
.threadsafe? ⇒ Boolean (readonly)
Was sqlite3 compiled with thread safety on?
# File 'lib/sqlite3.rb', line 14
def self.threadsafe? threadsafe > 0 end
Class Method Details
.libversion
[ GitHub ]# File 'ext/sqlite3/sqlite3.c', line 76
static VALUE
libversion(VALUE UNUSED(klass))
{
return INT2NUM(sqlite3_libversion_number());
}
.status(parameter) → Hash)
.status(parameter, reset_flag = false) → Hash)
Queries the SQLite3 library for run-time status information. Passing a truthy reset_flag will
reset the highwater mark to the current value.
[Parameters]
parameter(Integer,::SQLite3::Constants::Status): The status parameter to query.reset_flag(Boolean): Whether to reset the highwater mark. (default isfalse)
[Returns]
A Hash containing :current and :highwater keys for integer values.
# File 'ext/sqlite3/sqlite3.c', line 130
static VALUE
rb_sqlite3_status(int argc, VALUE *argv, VALUE klass)
{
VALUE opArg, resetFlagArg;
rb_scan_args(argc, argv, "11", &opArg, &resetFlagArg);
int op = NUM2INT(opArg);
bool resetFlag = RTEST(resetFlagArg);
int pCurrent = 0;
int pHighwater = 0;
sqlite3_status(op, &pCurrent, &pHighwater, resetFlag);
VALUE hash = rb_hash_new();
rb_hash_aset(hash, ID2SYM(rb_intern("current")), INT2FIX(pCurrent));
rb_hash_aset(hash, ID2SYM(rb_intern("highwater")), INT2FIX(pHighwater));
return hash;
}