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 “affinity”. https://www.sqlite.org/datatype3.html#type_affinity
- 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_mprintfon the given string, with memory allocated by sqlite3. Meant to be passed into sqlite APIs that require sqlite-allocated strings, like virtual table’szErrMsgor xBestIndex’sidxStr - Calls
sqlite3_result_blobto represent that a function returns a blob with the given value. - Calls
sqlite3_result_doubleto represent that a function returns a double/float with the given value. - Calls
sqlite3_result_errorto represent that a function returns an error with the given value. Note: You can typically rely oncrate::Resultto do this for you. - Calls
sqlite3_result_error_codeto represent that a function returns xx with the given value. - Calls
sqlite3_result_intto represent that a function returns an int32 with the given value. sqlite3_result_int64to 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_nullto represent that a function returns null with the given value. - Calls
sqlite3_result_subtype - Calls
sqlite3_result_textto 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_blobresult from the given sqlite3_value, as a u8 slice. - Returns the
sqlite3_value_bytesresult from the given sqlite3_value, as i32. - Returns the
sqlite3_value_doubleresult from the given sqlite3_value, as f64. - Returns the
sqlite3_value_intresult from the given sqlite3_value, as i32. - Returns the
sqlite3_value_int64result from the given sqlite3_value, as i64. - Returns the
sqlite3_value_textresult 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_typeresult of the given value, one of TEXT/INT/FLOAT/BLOB/NULL.