Module sqlite_loadable::api

source ·
Expand description

(Mostly) safe wrappers around low-level sqlite3 C API.

Uses the unsafe low-level API’s defined in crate::ext.

Useful when working with sqlite3_value or sqlite3_context.

Structs

Ergonomic wrapper around a raw sqlite3_value. It is the caller’s reponsibility to ensure that a given pointer points to a valid sqlite3_value object. There seems to be a 5-10% perf cost when using Value vs calling functions on raw pointers

Enums

A columns “extended affinity”. The traditional affinity does not include supplementary “types” that SQLite doesn’t support out of the box, like JSON, boolean, or datetime. This is an experimental extension to tradition affinities, and may change anytime.
Possible error cases when calling mprintf, aka the sqlite3_mprintf function.
Possible values that sqlite3_value_type will return for a value.

Functions

Calls sqlite3_mprintf on the given string, with memory allocated by sqlite3. Meant to be passed into sqlite APIs that require sqlite-allocated strings, like virtual table’s zErrMsg or xBestIndex’s idxStr
Calls sqlite3_result_blob to represent that a function returns a blob with the given value.
Calls result_int with value=1 for true, or value=0 for false.
Calls sqlite3_result_double to represent that a function returns a double/float with the given value.
Calls sqlite3_result_error to represent that a function returns an error with the given value. Note: You can typically rely on crate::Result to do this for you.
Calls sqlite3_result_error_code to represent that a function returns xx with the given value.
Calls sqlite3_result_int to represent that a function returns an int32 with the given value.
sqlite3_result_int64 to represent that a function returns an int64 with the given value.
Result the given JSON as a value that other SQLite JSON functions expect: a stringified text result with subtype of ‘J’.
Calls sqlite3_result_null to represent that a function returns null with the given value.
Calls sqlite3_result_text to represent that a function returns a string with the given value. Fails if the string length is larger than i32 maximum value.
Returns the sqlite3_value_blob result from the given sqlite3_value, as a u8 slice.
Returns the sqlite3_value_bytes result from the given sqlite3_value, as i32.
Returns the sqlite3_value_double result from the given sqlite3_value, as f64.
Returns the sqlite3_value_int result from the given sqlite3_value, as i32.
Returns the sqlite3_value_int64 result from the given sqlite3_value, as i64.
Returns the sqlite3_value_text result from the given sqlite3_value, as a str. If the number of bytes of the underlying value is 0, then an empty string is returned. A UTF8 Error is returned if there are problems encoding the string.
Returns the sqlite3_value_type result of the given value, one of TEXT/INT/FLOAT/BLOB/NULL.