mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 00:39:20 +08:00
parent
ee7f7b89d5
commit
0312937d6a
@ -150,6 +150,7 @@ features = [ "array", "backup", "blob", "chrono", "collation", "functions", "lim
|
|||||||
all-features = false
|
all-features = false
|
||||||
no-default-features = true
|
no-default-features = true
|
||||||
default-target = "x86_64-unknown-linux-gnu"
|
default-target = "x86_64-unknown-linux-gnu"
|
||||||
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
[package.metadata.playground]
|
[package.metadata.playground]
|
||||||
features = ["bundled-full"]
|
features = ["bundled-full"]
|
||||||
|
@ -181,7 +181,10 @@ mod build_bundled {
|
|||||||
|
|
||||||
if cfg!(feature = "bundled-sqlcipher-vendored-openssl") {
|
if cfg!(feature = "bundled-sqlcipher-vendored-openssl") {
|
||||||
cfg.include(std::env::var("DEP_OPENSSL_INCLUDE").unwrap());
|
cfg.include(std::env::var("DEP_OPENSSL_INCLUDE").unwrap());
|
||||||
println!("cargo:rustc-link-lib=static=crypto"); // cargo will resolve downstream to the static lib in openssl-sys
|
println!("cargo:rustc-link-lib=static=crypto"); // cargo will
|
||||||
|
// resolve downstream
|
||||||
|
// to the static
|
||||||
|
// lib in openssl-sys
|
||||||
} else if is_windows {
|
} else if is_windows {
|
||||||
// FIXME README says that bundled-sqlcipher is Unix only, and the sources are
|
// FIXME README says that bundled-sqlcipher is Unix only, and the sources are
|
||||||
// configured on a Unix machine. So maybe this should be made unreachable.
|
// configured on a Unix machine. So maybe this should be made unreachable.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//! `feature = "backup"` Online SQLite backup API.
|
//! Online SQLite backup API.
|
||||||
//!
|
//!
|
||||||
//! To create a [`Backup`], you must have two distinct [`Connection`]s - one
|
//! To create a [`Backup`], you must have two distinct [`Connection`]s - one
|
||||||
//! for the source (which can be used while the backup is running) and one for
|
//! for the source (which can be used while the backup is running) and one for
|
||||||
@ -44,7 +44,7 @@ use crate::error::{error_from_handle, error_from_sqlite_code};
|
|||||||
use crate::{Connection, DatabaseName, Result};
|
use crate::{Connection, DatabaseName, Result};
|
||||||
|
|
||||||
impl Connection {
|
impl Connection {
|
||||||
/// `feature = "backup"` Back up the `name` database to the given
|
/// Back up the `name` database to the given
|
||||||
/// destination path.
|
/// destination path.
|
||||||
///
|
///
|
||||||
/// If `progress` is not `None`, it will be called periodically
|
/// If `progress` is not `None`, it will be called periodically
|
||||||
@ -84,7 +84,7 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "backup"` Restore the given source path into the
|
/// Restore the given source path into the
|
||||||
/// `name` database. If `progress` is not `None`, it will be
|
/// `name` database. If `progress` is not `None`, it will be
|
||||||
/// called periodically until the restore completes.
|
/// called periodically until the restore completes.
|
||||||
///
|
///
|
||||||
@ -131,7 +131,7 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "backup"` Possible successful results of calling
|
/// Possible successful results of calling
|
||||||
/// [`Backup::step`].
|
/// [`Backup::step`].
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
@ -152,7 +152,7 @@ pub enum StepResult {
|
|||||||
Locked,
|
Locked,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "backup"` Struct specifying the progress of a backup. The
|
/// Struct specifying the progress of a backup. The
|
||||||
/// percentage completion can be calculated as `(pagecount - remaining) /
|
/// percentage completion can be calculated as `(pagecount - remaining) /
|
||||||
/// pagecount`. The progress of a backup is as of the last call to
|
/// pagecount`. The progress of a backup is as of the last call to
|
||||||
/// [`step`](Backup::step) - if the source database is modified after a call to
|
/// [`step`](Backup::step) - if the source database is modified after a call to
|
||||||
@ -166,7 +166,7 @@ pub struct Progress {
|
|||||||
pub pagecount: c_int,
|
pub pagecount: c_int,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "backup"` A handle to an online backup.
|
/// A handle to an online backup.
|
||||||
pub struct Backup<'a, 'b> {
|
pub struct Backup<'a, 'b> {
|
||||||
phantom_from: PhantomData<&'a Connection>,
|
phantom_from: PhantomData<&'a Connection>,
|
||||||
phantom_to: PhantomData<&'b Connection>,
|
phantom_to: PhantomData<&'b Connection>,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//! `feature = "blob"` Incremental BLOB I/O.
|
//! Incremental BLOB I/O.
|
||||||
//!
|
//!
|
||||||
//! Note that SQLite does not provide API-level access to change the size of a
|
//! Note that SQLite does not provide API-level access to change the size of a
|
||||||
//! BLOB; that must be performed through SQL statements.
|
//! BLOB; that must be performed through SQL statements.
|
||||||
@ -196,7 +196,7 @@ use crate::{Connection, DatabaseName, Result};
|
|||||||
|
|
||||||
mod pos_io;
|
mod pos_io;
|
||||||
|
|
||||||
/// `feature = "blob"` Handle to an open BLOB. See
|
/// Handle to an open BLOB. See
|
||||||
/// [`rusqlite::blob`](crate::blob) documentation for in-depth discussion.
|
/// [`rusqlite::blob`](crate::blob) documentation for in-depth discussion.
|
||||||
pub struct Blob<'conn> {
|
pub struct Blob<'conn> {
|
||||||
conn: &'conn Connection,
|
conn: &'conn Connection,
|
||||||
@ -206,7 +206,7 @@ pub struct Blob<'conn> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Connection {
|
impl Connection {
|
||||||
/// `feature = "blob"` Open a handle to the BLOB located in `row_id`,
|
/// Open a handle to the BLOB located in `row_id`,
|
||||||
/// `column`, `table` in database `db`.
|
/// `column`, `table` in database `db`.
|
||||||
///
|
///
|
||||||
/// # Failure
|
/// # Failure
|
||||||
@ -400,7 +400,7 @@ impl Drop for Blob<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "blob"` BLOB of length N that is filled with zeroes.
|
/// BLOB of length N that is filled with zeroes.
|
||||||
///
|
///
|
||||||
/// Zeroblobs are intended to serve as placeholders for BLOBs whose content is
|
/// Zeroblobs are intended to serve as placeholders for BLOBs whose content is
|
||||||
/// later written using incremental BLOB I/O routines.
|
/// later written using incremental BLOB I/O routines.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//! `feature = "collation"` Add, remove, or modify a collation
|
//! Add, remove, or modify a collation
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::os::raw::{c_char, c_int, c_void};
|
use std::os::raw::{c_char, c_int, c_void};
|
||||||
use std::panic::{catch_unwind, UnwindSafe};
|
use std::panic::{catch_unwind, UnwindSafe};
|
||||||
@ -14,7 +14,7 @@ unsafe extern "C" fn free_boxed_value<T>(p: *mut c_void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Connection {
|
impl Connection {
|
||||||
/// `feature = "collation"` Add or modify a collation.
|
/// Add or modify a collation.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn create_collation<'c, C>(&'c self, collation_name: &str, x_compare: C) -> Result<()>
|
pub fn create_collation<'c, C>(&'c self, collation_name: &str, x_compare: C) -> Result<()>
|
||||||
where
|
where
|
||||||
@ -25,7 +25,7 @@ impl Connection {
|
|||||||
.create_collation(collation_name, x_compare)
|
.create_collation(collation_name, x_compare)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "collation"` Collation needed callback
|
/// Collation needed callback
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn collation_needed(
|
pub fn collation_needed(
|
||||||
&self,
|
&self,
|
||||||
@ -34,7 +34,7 @@ impl Connection {
|
|||||||
self.db.borrow_mut().collation_needed(x_coll_needed)
|
self.db.borrow_mut().collation_needed(x_coll_needed)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "collation"` Remove collation.
|
/// Remove collation.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn remove_collation(&self, collation_name: &str) -> Result<()> {
|
pub fn remove_collation(&self, collation_name: &str) -> Result<()> {
|
||||||
self.db.borrow_mut().remove_collation(collation_name)
|
self.db.borrow_mut().remove_collation(collation_name)
|
||||||
|
@ -132,6 +132,7 @@ impl Statement<'_> {
|
|||||||
/// sure that current statement has already been stepped once before
|
/// sure that current statement has already been stepped once before
|
||||||
/// calling this method.
|
/// calling this method.
|
||||||
#[cfg(feature = "column_decltype")]
|
#[cfg(feature = "column_decltype")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "column_decltype")))]
|
||||||
pub fn columns(&self) -> Vec<Column> {
|
pub fn columns(&self) -> Vec<Column> {
|
||||||
let n = self.column_count();
|
let n = self.column_count();
|
||||||
let mut cols = Vec::with_capacity(n as usize);
|
let mut cols = Vec::with_capacity(n as usize);
|
||||||
|
@ -72,15 +72,18 @@ pub enum Error {
|
|||||||
/// [`functions::Context::get`](crate::functions::Context::get) when the
|
/// [`functions::Context::get`](crate::functions::Context::get) when the
|
||||||
/// function argument cannot be converted to the requested type.
|
/// function argument cannot be converted to the requested type.
|
||||||
#[cfg(feature = "functions")]
|
#[cfg(feature = "functions")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "functions")))]
|
||||||
InvalidFunctionParameterType(usize, Type),
|
InvalidFunctionParameterType(usize, Type),
|
||||||
/// Error returned by [`vtab::Values::get`](crate::vtab::Values::get) when
|
/// Error returned by [`vtab::Values::get`](crate::vtab::Values::get) when
|
||||||
/// the filter argument cannot be converted to the requested type.
|
/// the filter argument cannot be converted to the requested type.
|
||||||
#[cfg(feature = "vtab")]
|
#[cfg(feature = "vtab")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "vtab")))]
|
||||||
InvalidFilterParameterType(usize, Type),
|
InvalidFilterParameterType(usize, Type),
|
||||||
|
|
||||||
/// An error case available for implementors of custom user functions (e.g.,
|
/// An error case available for implementors of custom user functions (e.g.,
|
||||||
/// [`create_scalar_function`](crate::Connection::create_scalar_function)).
|
/// [`create_scalar_function`](crate::Connection::create_scalar_function)).
|
||||||
#[cfg(feature = "functions")]
|
#[cfg(feature = "functions")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "functions")))]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
UserFunctionError(Box<dyn error::Error + Send + Sync + 'static>),
|
UserFunctionError(Box<dyn error::Error + Send + Sync + 'static>),
|
||||||
|
|
||||||
@ -94,11 +97,13 @@ pub enum Error {
|
|||||||
/// An error case available for implementors of custom modules (e.g.,
|
/// An error case available for implementors of custom modules (e.g.,
|
||||||
/// [`create_module`](crate::Connection::create_module)).
|
/// [`create_module`](crate::Connection::create_module)).
|
||||||
#[cfg(feature = "vtab")]
|
#[cfg(feature = "vtab")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "vtab")))]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
ModuleError(String),
|
ModuleError(String),
|
||||||
|
|
||||||
/// An unwinding panic occurs in an UDF (user-defined function).
|
/// An unwinding panic occurs in an UDF (user-defined function).
|
||||||
#[cfg(feature = "functions")]
|
#[cfg(feature = "functions")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "functions")))]
|
||||||
UnwindingPanic,
|
UnwindingPanic,
|
||||||
|
|
||||||
/// An error returned when
|
/// An error returned when
|
||||||
@ -106,6 +111,7 @@ pub enum Error {
|
|||||||
/// retrieve data of a different type than what had been stored using
|
/// retrieve data of a different type than what had been stored using
|
||||||
/// [`Context::set_aux`](crate::functions::Context::set_aux).
|
/// [`Context::set_aux`](crate::functions::Context::set_aux).
|
||||||
#[cfg(feature = "functions")]
|
#[cfg(feature = "functions")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "functions")))]
|
||||||
GetAuxWrongType,
|
GetAuxWrongType,
|
||||||
|
|
||||||
/// Error when the SQL contains multiple statements.
|
/// Error when the SQL contains multiple statements.
|
||||||
@ -120,6 +126,7 @@ pub enum Error {
|
|||||||
/// [`Blob::raw_read_at_exact`](crate::blob::Blob::raw_read_at_exact) will
|
/// [`Blob::raw_read_at_exact`](crate::blob::Blob::raw_read_at_exact) will
|
||||||
/// return it if the blob has insufficient data.
|
/// return it if the blob has insufficient data.
|
||||||
#[cfg(feature = "blob")]
|
#[cfg(feature = "blob")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "blob")))]
|
||||||
BlobSizeError,
|
BlobSizeError,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//! `feature = "functions"` Create or redefine SQL functions.
|
//! Create or redefine SQL functions.
|
||||||
//!
|
//!
|
||||||
//! # Example
|
//! # Example
|
||||||
//!
|
//!
|
||||||
@ -104,7 +104,7 @@ unsafe extern "C" fn free_boxed_value<T>(p: *mut c_void) {
|
|||||||
drop(Box::from_raw(p as *mut T));
|
drop(Box::from_raw(p as *mut T));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "functions"` Context is a wrapper for the SQLite function
|
/// Context is a wrapper for the SQLite function
|
||||||
/// evaluation context.
|
/// evaluation context.
|
||||||
pub struct Context<'a> {
|
pub struct Context<'a> {
|
||||||
ctx: *mut sqlite3_context,
|
ctx: *mut sqlite3_context,
|
||||||
@ -260,7 +260,7 @@ impl Deref for ConnectionRef<'_> {
|
|||||||
|
|
||||||
type AuxInner = Arc<dyn Any + Send + Sync + 'static>;
|
type AuxInner = Arc<dyn Any + Send + Sync + 'static>;
|
||||||
|
|
||||||
/// `feature = "functions"` Aggregate is the callback interface for user-defined
|
/// Aggregate is the callback interface for user-defined
|
||||||
/// aggregate function.
|
/// aggregate function.
|
||||||
///
|
///
|
||||||
/// `A` is the type of the aggregation context and `T` is the type of the final
|
/// `A` is the type of the aggregation context and `T` is the type of the final
|
||||||
@ -292,9 +292,10 @@ where
|
|||||||
fn finalize(&self, _: &mut Context<'_>, _: Option<A>) -> Result<T>;
|
fn finalize(&self, _: &mut Context<'_>, _: Option<A>) -> Result<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "window"` WindowAggregate is the callback interface for
|
/// WindowAggregate is the callback interface for
|
||||||
/// user-defined aggregate window function.
|
/// user-defined aggregate window function.
|
||||||
#[cfg(feature = "window")]
|
#[cfg(feature = "window")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "window")))]
|
||||||
pub trait WindowAggregate<A, T>: Aggregate<A, T>
|
pub trait WindowAggregate<A, T>: Aggregate<A, T>
|
||||||
where
|
where
|
||||||
A: RefUnwindSafe + UnwindSafe,
|
A: RefUnwindSafe + UnwindSafe,
|
||||||
@ -341,7 +342,7 @@ impl Default for FunctionFlags {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Connection {
|
impl Connection {
|
||||||
/// `feature = "functions"` Attach a user-defined scalar function to
|
/// Attach a user-defined scalar function to
|
||||||
/// this database connection.
|
/// this database connection.
|
||||||
///
|
///
|
||||||
/// `fn_name` is the name the function will be accessible from SQL.
|
/// `fn_name` is the name the function will be accessible from SQL.
|
||||||
@ -395,7 +396,7 @@ impl Connection {
|
|||||||
.create_scalar_function(fn_name, n_arg, flags, x_func)
|
.create_scalar_function(fn_name, n_arg, flags, x_func)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "functions"` Attach a user-defined aggregate function to this
|
/// Attach a user-defined aggregate function to this
|
||||||
/// database connection.
|
/// database connection.
|
||||||
///
|
///
|
||||||
/// # Failure
|
/// # Failure
|
||||||
@ -419,12 +420,13 @@ impl Connection {
|
|||||||
.create_aggregate_function(fn_name, n_arg, flags, aggr)
|
.create_aggregate_function(fn_name, n_arg, flags, aggr)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "window"` Attach a user-defined aggregate window function to
|
/// Attach a user-defined aggregate window function to
|
||||||
/// this database connection.
|
/// this database connection.
|
||||||
///
|
///
|
||||||
/// See `https://sqlite.org/windowfunctions.html#udfwinfunc` for more
|
/// See `https://sqlite.org/windowfunctions.html#udfwinfunc` for more
|
||||||
/// information.
|
/// information.
|
||||||
#[cfg(feature = "window")]
|
#[cfg(feature = "window")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "window")))]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn create_window_function<A, W, T>(
|
pub fn create_window_function<A, W, T>(
|
||||||
&self,
|
&self,
|
||||||
@ -443,7 +445,7 @@ impl Connection {
|
|||||||
.create_window_function(fn_name, n_arg, flags, aggr)
|
.create_window_function(fn_name, n_arg, flags, aggr)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "functions"` Removes a user-defined function from this
|
/// Removes a user-defined function from this
|
||||||
/// database connection.
|
/// database connection.
|
||||||
///
|
///
|
||||||
/// `fn_name` and `n_arg` should match the name and number of arguments
|
/// `fn_name` and `n_arg` should match the name and number of arguments
|
||||||
|
25
src/hooks.rs
25
src/hooks.rs
@ -1,4 +1,4 @@
|
|||||||
//! `feature = "hooks"` Commit, Data Change and Rollback Notification Callbacks
|
//! Commit, Data Change and Rollback Notification Callbacks
|
||||||
#![allow(non_camel_case_types)]
|
#![allow(non_camel_case_types)]
|
||||||
|
|
||||||
use std::os::raw::{c_char, c_int, c_void};
|
use std::os::raw::{c_char, c_int, c_void};
|
||||||
@ -9,11 +9,12 @@ use crate::ffi;
|
|||||||
|
|
||||||
use crate::{Connection, InnerConnection};
|
use crate::{Connection, InnerConnection};
|
||||||
|
|
||||||
/// `feature = "hooks"` Action Codes
|
/// Action Codes
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
#[repr(i32)]
|
#[repr(i32)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[allow(clippy::upper_case_acronyms)]
|
#[allow(clippy::upper_case_acronyms)]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "hooks")))]
|
||||||
pub enum Action {
|
pub enum Action {
|
||||||
/// Unsupported / unexpected action
|
/// Unsupported / unexpected action
|
||||||
UNKNOWN = -1,
|
UNKNOWN = -1,
|
||||||
@ -37,7 +38,7 @@ impl From<i32> for Action {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "hooks"` The context recieved by an authorizer hook.
|
/// The context recieved by an authorizer hook.
|
||||||
///
|
///
|
||||||
/// See <https://sqlite.org/c3ref/set_authorizer.html> for more info.
|
/// See <https://sqlite.org/c3ref/set_authorizer.html> for more info.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
@ -53,7 +54,7 @@ pub struct AuthContext<'c> {
|
|||||||
pub accessor: Option<&'c str>,
|
pub accessor: Option<&'c str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "hooks"` Actions and arguments found within a statement during
|
/// Actions and arguments found within a statement during
|
||||||
/// preparation.
|
/// preparation.
|
||||||
///
|
///
|
||||||
/// See <https://sqlite.org/c3ref/c_alter_table.html> for more info.
|
/// See <https://sqlite.org/c3ref/c_alter_table.html> for more info.
|
||||||
@ -254,7 +255,7 @@ impl<'c> AuthAction<'c> {
|
|||||||
table_name,
|
table_name,
|
||||||
column_name,
|
column_name,
|
||||||
},
|
},
|
||||||
(ffi::SQLITE_SELECT, _, _) => Self::Select,
|
(ffi::SQLITE_SELECT, ..) => Self::Select,
|
||||||
(ffi::SQLITE_TRANSACTION, Some(operation_str), _) => Self::Transaction {
|
(ffi::SQLITE_TRANSACTION, Some(operation_str), _) => Self::Transaction {
|
||||||
operation: TransactionOperation::from_str(operation_str),
|
operation: TransactionOperation::from_str(operation_str),
|
||||||
},
|
},
|
||||||
@ -286,7 +287,7 @@ impl<'c> AuthAction<'c> {
|
|||||||
savepoint_name,
|
savepoint_name,
|
||||||
},
|
},
|
||||||
#[cfg(feature = "modern_sqlite")]
|
#[cfg(feature = "modern_sqlite")]
|
||||||
(ffi::SQLITE_RECURSIVE, _, _) => Self::Recursive,
|
(ffi::SQLITE_RECURSIVE, ..) => Self::Recursive,
|
||||||
(code, arg1, arg2) => Self::Unknown { code, arg1, arg2 },
|
(code, arg1, arg2) => Self::Unknown { code, arg1, arg2 },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -295,7 +296,7 @@ impl<'c> AuthAction<'c> {
|
|||||||
pub(crate) type BoxedAuthorizer =
|
pub(crate) type BoxedAuthorizer =
|
||||||
Box<dyn for<'c> FnMut(AuthContext<'c>) -> Authorization + Send + 'static>;
|
Box<dyn for<'c> FnMut(AuthContext<'c>) -> Authorization + Send + 'static>;
|
||||||
|
|
||||||
/// `feature = "hooks"` A transaction operation.
|
/// A transaction operation.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum TransactionOperation {
|
pub enum TransactionOperation {
|
||||||
@ -338,7 +339,7 @@ impl Authorization {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Connection {
|
impl Connection {
|
||||||
/// `feature = "hooks"` Register a callback function to be invoked whenever
|
/// Register a callback function to be invoked whenever
|
||||||
/// a transaction is committed.
|
/// a transaction is committed.
|
||||||
///
|
///
|
||||||
/// The callback returns `true` to rollback.
|
/// The callback returns `true` to rollback.
|
||||||
@ -350,7 +351,7 @@ impl Connection {
|
|||||||
self.db.borrow_mut().commit_hook(hook);
|
self.db.borrow_mut().commit_hook(hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "hooks"` Register a callback function to be invoked whenever
|
/// Register a callback function to be invoked whenever
|
||||||
/// a transaction is committed.
|
/// a transaction is committed.
|
||||||
///
|
///
|
||||||
/// The callback returns `true` to rollback.
|
/// The callback returns `true` to rollback.
|
||||||
@ -362,7 +363,7 @@ impl Connection {
|
|||||||
self.db.borrow_mut().rollback_hook(hook);
|
self.db.borrow_mut().rollback_hook(hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "hooks"` Register a callback function to be invoked whenever
|
/// Register a callback function to be invoked whenever
|
||||||
/// a row is updated, inserted or deleted in a rowid table.
|
/// a row is updated, inserted or deleted in a rowid table.
|
||||||
///
|
///
|
||||||
/// The callback parameters are:
|
/// The callback parameters are:
|
||||||
@ -380,7 +381,7 @@ impl Connection {
|
|||||||
self.db.borrow_mut().update_hook(hook);
|
self.db.borrow_mut().update_hook(hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "hooks"` Register a query progress callback.
|
/// Register a query progress callback.
|
||||||
///
|
///
|
||||||
/// The parameter `num_ops` is the approximate number of virtual machine
|
/// The parameter `num_ops` is the approximate number of virtual machine
|
||||||
/// instructions that are evaluated between successive invocations of the
|
/// instructions that are evaluated between successive invocations of the
|
||||||
@ -395,7 +396,7 @@ impl Connection {
|
|||||||
self.db.borrow_mut().progress_handler(num_ops, handler);
|
self.db.borrow_mut().progress_handler(num_ops, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "hooks"` Register an authorizer callback that's invoked
|
/// Register an authorizer callback that's invoked
|
||||||
/// as a statement is being prepared.
|
/// as a statement is being prepared.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn authorizer<'c, F>(&self, hook: Option<F>)
|
pub fn authorizer<'c, F>(&self, hook: Option<F>)
|
||||||
|
20
src/lib.rs
20
src/lib.rs
@ -48,6 +48,7 @@
|
|||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
|
|
||||||
pub use libsqlite3_sys as ffi;
|
pub use libsqlite3_sys as ffi;
|
||||||
|
|
||||||
@ -88,23 +89,29 @@ pub use crate::version::*;
|
|||||||
mod error;
|
mod error;
|
||||||
|
|
||||||
#[cfg(feature = "backup")]
|
#[cfg(feature = "backup")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "backup")))]
|
||||||
pub mod backup;
|
pub mod backup;
|
||||||
#[cfg(feature = "blob")]
|
#[cfg(feature = "blob")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "blob")))]
|
||||||
pub mod blob;
|
pub mod blob;
|
||||||
mod busy;
|
mod busy;
|
||||||
mod cache;
|
mod cache;
|
||||||
#[cfg(feature = "collation")]
|
#[cfg(feature = "collation")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "collation")))]
|
||||||
mod collation;
|
mod collation;
|
||||||
mod column;
|
mod column;
|
||||||
pub mod config;
|
pub mod config;
|
||||||
#[cfg(any(feature = "functions", feature = "vtab"))]
|
#[cfg(any(feature = "functions", feature = "vtab"))]
|
||||||
mod context;
|
mod context;
|
||||||
#[cfg(feature = "functions")]
|
#[cfg(feature = "functions")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "functions")))]
|
||||||
pub mod functions;
|
pub mod functions;
|
||||||
#[cfg(feature = "hooks")]
|
#[cfg(feature = "hooks")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "hooks")))]
|
||||||
mod hooks;
|
mod hooks;
|
||||||
mod inner_connection;
|
mod inner_connection;
|
||||||
#[cfg(feature = "limits")]
|
#[cfg(feature = "limits")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "limits")))]
|
||||||
pub mod limits;
|
pub mod limits;
|
||||||
#[cfg(feature = "load_extension")]
|
#[cfg(feature = "load_extension")]
|
||||||
mod load_extension_guard;
|
mod load_extension_guard;
|
||||||
@ -113,15 +120,18 @@ mod pragma;
|
|||||||
mod raw_statement;
|
mod raw_statement;
|
||||||
mod row;
|
mod row;
|
||||||
#[cfg(feature = "session")]
|
#[cfg(feature = "session")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "session")))]
|
||||||
pub mod session;
|
pub mod session;
|
||||||
mod statement;
|
mod statement;
|
||||||
#[cfg(feature = "trace")]
|
#[cfg(feature = "trace")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "trace")))]
|
||||||
pub mod trace;
|
pub mod trace;
|
||||||
mod transaction;
|
mod transaction;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
mod unlock_notify;
|
mod unlock_notify;
|
||||||
mod version;
|
mod version;
|
||||||
#[cfg(feature = "vtab")]
|
#[cfg(feature = "vtab")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "vtab")))]
|
||||||
pub mod vtab;
|
pub mod vtab;
|
||||||
|
|
||||||
pub(crate) mod util;
|
pub(crate) mod util;
|
||||||
@ -714,7 +724,7 @@ impl Connection {
|
|||||||
r.map_err(move |err| (self, err))
|
r.map_err(move |err| (self, err))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "load_extension"` Enable loading of SQLite extensions.
|
/// Enable loading of SQLite extensions.
|
||||||
/// Strongly consider using `LoadExtensionGuard` instead of this function.
|
/// Strongly consider using `LoadExtensionGuard` instead of this function.
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
@ -733,12 +743,13 @@ impl Connection {
|
|||||||
///
|
///
|
||||||
/// Will return `Err` if the underlying SQLite call fails.
|
/// Will return `Err` if the underlying SQLite call fails.
|
||||||
#[cfg(feature = "load_extension")]
|
#[cfg(feature = "load_extension")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "load_extension")))]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn load_extension_enable(&self) -> Result<()> {
|
pub fn load_extension_enable(&self) -> Result<()> {
|
||||||
self.db.borrow_mut().enable_load_extension(1)
|
self.db.borrow_mut().enable_load_extension(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "load_extension"` Disable loading of SQLite extensions.
|
/// Disable loading of SQLite extensions.
|
||||||
///
|
///
|
||||||
/// See `load_extension_enable` for an example.
|
/// See `load_extension_enable` for an example.
|
||||||
///
|
///
|
||||||
@ -746,12 +757,13 @@ impl Connection {
|
|||||||
///
|
///
|
||||||
/// Will return `Err` if the underlying SQLite call fails.
|
/// Will return `Err` if the underlying SQLite call fails.
|
||||||
#[cfg(feature = "load_extension")]
|
#[cfg(feature = "load_extension")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "load_extension")))]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn load_extension_disable(&self) -> Result<()> {
|
pub fn load_extension_disable(&self) -> Result<()> {
|
||||||
self.db.borrow_mut().enable_load_extension(0)
|
self.db.borrow_mut().enable_load_extension(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "load_extension"` Load the SQLite extension at `dylib_path`.
|
/// Load the SQLite extension at `dylib_path`.
|
||||||
/// `dylib_path` is passed through to `sqlite3_load_extension`, which may
|
/// `dylib_path` is passed through to `sqlite3_load_extension`, which may
|
||||||
/// attempt OS-specific modifications if the file cannot be loaded directly.
|
/// attempt OS-specific modifications if the file cannot be loaded directly.
|
||||||
///
|
///
|
||||||
@ -775,6 +787,7 @@ impl Connection {
|
|||||||
///
|
///
|
||||||
/// Will return `Err` if the underlying SQLite call fails.
|
/// Will return `Err` if the underlying SQLite call fails.
|
||||||
#[cfg(feature = "load_extension")]
|
#[cfg(feature = "load_extension")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "load_extension")))]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn load_extension<P: AsRef<Path>>(
|
pub fn load_extension<P: AsRef<Path>>(
|
||||||
&self,
|
&self,
|
||||||
@ -853,6 +866,7 @@ impl Connection {
|
|||||||
/// Determine if all associated prepared statements have been reset.
|
/// Determine if all associated prepared statements have been reset.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg(feature = "modern_sqlite")] // 3.8.6
|
#[cfg(feature = "modern_sqlite")] // 3.8.6
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "modern_sqlite")))]
|
||||||
pub fn is_busy(&self) -> bool {
|
pub fn is_busy(&self) -> bool {
|
||||||
self.db.borrow().is_busy()
|
self.db.borrow().is_busy()
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//! `feature = "limits"` Run-Time Limits
|
//! Run-Time Limits
|
||||||
|
|
||||||
use std::os::raw::c_int;
|
use std::os::raw::c_int;
|
||||||
|
|
||||||
@ -8,14 +8,14 @@ pub use crate::ffi::Limit;
|
|||||||
use crate::Connection;
|
use crate::Connection;
|
||||||
|
|
||||||
impl Connection {
|
impl Connection {
|
||||||
/// `feature = "limits"` Returns the current value of a limit.
|
/// Returns the current value of a limit.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn limit(&self, limit: Limit) -> i32 {
|
pub fn limit(&self, limit: Limit) -> i32 {
|
||||||
let c = self.db.borrow();
|
let c = self.db.borrow();
|
||||||
unsafe { ffi::sqlite3_limit(c.db(), limit as c_int, -1) }
|
unsafe { ffi::sqlite3_limit(c.db(), limit as c_int, -1) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "limits"` Changes the limit to `new_val`, returning the prior
|
/// Changes the limit to `new_val`, returning the prior
|
||||||
/// value of the limit.
|
/// value of the limit.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_limit(&self, limit: Limit, new_val: i32) -> i32 {
|
pub fn set_limit(&self, limit: Limit, new_val: i32) -> i32 {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{Connection, Result};
|
use crate::{Connection, Result};
|
||||||
|
|
||||||
/// `feature = "load_extension"` RAII guard temporarily enabling SQLite
|
/// RAII guard temporarily enabling SQLite
|
||||||
/// extensions to be loaded.
|
/// extensions to be loaded.
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
@ -14,6 +14,7 @@ use crate::{Connection, Result};
|
|||||||
/// conn.load_extension(Path::new("my_sqlite_extension"), None)
|
/// conn.load_extension(Path::new("my_sqlite_extension"), None)
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "load_extension")))]
|
||||||
pub struct LoadExtensionGuard<'conn> {
|
pub struct LoadExtensionGuard<'conn> {
|
||||||
conn: &'conn Connection,
|
conn: &'conn Connection,
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//! `feature = "session"` [Session Extension](https://sqlite.org/sessionintro.html)
|
//! [Session Extension](https://sqlite.org/sessionintro.html)
|
||||||
#![allow(non_camel_case_types)]
|
#![allow(non_camel_case_types)]
|
||||||
|
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
@ -19,7 +19,7 @@ use crate::{errmsg_to_string, str_to_cstring, Connection, DatabaseName, Result};
|
|||||||
|
|
||||||
// https://sqlite.org/session.html
|
// https://sqlite.org/session.html
|
||||||
|
|
||||||
/// `feature = "session"` An instance of this object is a session that can be
|
/// An instance of this object is a session that can be
|
||||||
/// used to record changes to a database.
|
/// used to record changes to a database.
|
||||||
pub struct Session<'conn> {
|
pub struct Session<'conn> {
|
||||||
phantom: PhantomData<&'conn Connection>,
|
phantom: PhantomData<&'conn Connection>,
|
||||||
@ -223,7 +223,7 @@ impl Drop for Session<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "session"` Invert a changeset
|
/// Invert a changeset
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn invert_strm(input: &mut dyn Read, output: &mut dyn Write) -> Result<()> {
|
pub fn invert_strm(input: &mut dyn Read, output: &mut dyn Write) -> Result<()> {
|
||||||
let input_ref = &input;
|
let input_ref = &input;
|
||||||
@ -239,7 +239,7 @@ pub fn invert_strm(input: &mut dyn Read, output: &mut dyn Write) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "session"` Combine two changesets
|
/// Combine two changesets
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn concat_strm(
|
pub fn concat_strm(
|
||||||
input_a: &mut dyn Read,
|
input_a: &mut dyn Read,
|
||||||
@ -262,7 +262,7 @@ pub fn concat_strm(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "session"` Changeset or Patchset
|
/// Changeset or Patchset
|
||||||
pub struct Changeset {
|
pub struct Changeset {
|
||||||
cs: *mut c_void,
|
cs: *mut c_void,
|
||||||
n: c_int,
|
n: c_int,
|
||||||
@ -313,7 +313,7 @@ impl Drop for Changeset {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "session"` Cursor for iterating over the elements of a changeset
|
/// Cursor for iterating over the elements of a changeset
|
||||||
/// or patchset.
|
/// or patchset.
|
||||||
pub struct ChangesetIter<'changeset> {
|
pub struct ChangesetIter<'changeset> {
|
||||||
phantom: PhantomData<&'changeset Changeset>,
|
phantom: PhantomData<&'changeset Changeset>,
|
||||||
@ -367,7 +367,7 @@ impl FallibleStreamingIterator for ChangesetIter<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "session"`
|
/// Operation
|
||||||
pub struct Operation<'item> {
|
pub struct Operation<'item> {
|
||||||
table_name: &'item str,
|
table_name: &'item str,
|
||||||
number_of_columns: i32,
|
number_of_columns: i32,
|
||||||
@ -410,7 +410,7 @@ impl Drop for ChangesetIter<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "session"` An item passed to a conflict-handler by
|
/// An item passed to a conflict-handler by
|
||||||
/// [`Connection::apply`](crate::Connection::apply), or an item generated by
|
/// [`Connection::apply`](crate::Connection::apply), or an item generated by
|
||||||
/// [`ChangesetIter::next`](ChangesetIter::next).
|
/// [`ChangesetIter::next`](ChangesetIter::next).
|
||||||
// TODO enum ? Delete, Insert, Update, ...
|
// TODO enum ? Delete, Insert, Update, ...
|
||||||
@ -517,7 +517,7 @@ impl ChangesetItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "session"` Used to combine two or more changesets or
|
/// Used to combine two or more changesets or
|
||||||
/// patchsets
|
/// patchsets
|
||||||
pub struct Changegroup {
|
pub struct Changegroup {
|
||||||
cg: *mut ffi::sqlite3_changegroup,
|
cg: *mut ffi::sqlite3_changegroup,
|
||||||
@ -587,7 +587,7 @@ impl Drop for Changegroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Connection {
|
impl Connection {
|
||||||
/// `feature = "session"` Apply a changeset to a database
|
/// Apply a changeset to a database
|
||||||
pub fn apply<F, C>(&self, cs: &Changeset, filter: Option<F>, conflict: C) -> Result<()>
|
pub fn apply<F, C>(&self, cs: &Changeset, filter: Option<F>, conflict: C) -> Result<()>
|
||||||
where
|
where
|
||||||
F: Fn(&str) -> bool + Send + RefUnwindSafe + 'static,
|
F: Fn(&str) -> bool + Send + RefUnwindSafe + 'static,
|
||||||
@ -621,7 +621,7 @@ impl Connection {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "session"` Apply a changeset to a database
|
/// Apply a changeset to a database
|
||||||
pub fn apply_strm<F, C>(
|
pub fn apply_strm<F, C>(
|
||||||
&self,
|
&self,
|
||||||
input: &mut dyn Read,
|
input: &mut dyn Read,
|
||||||
@ -662,7 +662,7 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "session"` Constants passed to the conflict handler
|
/// Constants passed to the conflict handler
|
||||||
/// See [here](https://sqlite.org/session.html#SQLITE_CHANGESET_CONFLICT) for details.
|
/// See [here](https://sqlite.org/session.html#SQLITE_CHANGESET_CONFLICT) for details.
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
#[repr(i32)]
|
#[repr(i32)]
|
||||||
@ -690,7 +690,7 @@ impl From<i32> for ConflictType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "session"` Constants returned by the conflict handler
|
/// Constants returned by the conflict handler
|
||||||
/// See [here](https://sqlite.org/session.html#SQLITE_CHANGESET_ABORT) for details.
|
/// See [here](https://sqlite.org/session.html#SQLITE_CHANGESET_ABORT) for details.
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
#[repr(i32)]
|
#[repr(i32)]
|
||||||
|
@ -776,6 +776,7 @@ impl Statement<'_> {
|
|||||||
/// Returns a string containing the SQL text of prepared statement with
|
/// Returns a string containing the SQL text of prepared statement with
|
||||||
/// bound parameters expanded.
|
/// bound parameters expanded.
|
||||||
#[cfg(feature = "modern_sqlite")]
|
#[cfg(feature = "modern_sqlite")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "modern_sqlite")))]
|
||||||
pub fn expanded_sql(&self) -> Option<String> {
|
pub fn expanded_sql(&self) -> Option<String> {
|
||||||
self.stmt
|
self.stmt
|
||||||
.expanded_sql()
|
.expanded_sql()
|
||||||
|
10
src/trace.rs
10
src/trace.rs
@ -1,4 +1,4 @@
|
|||||||
//! `feature = "trace"` Tracing and profiling functions. Error and warning log.
|
//! Tracing and profiling functions. Error and warning log.
|
||||||
|
|
||||||
use std::ffi::{CStr, CString};
|
use std::ffi::{CStr, CString};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
@ -11,7 +11,7 @@ use super::ffi;
|
|||||||
use crate::error::error_from_sqlite_code;
|
use crate::error::error_from_sqlite_code;
|
||||||
use crate::{Connection, Result};
|
use crate::{Connection, Result};
|
||||||
|
|
||||||
/// `feature = "trace"` Set up the process-wide SQLite error logging callback.
|
/// Set up the process-wide SQLite error logging callback.
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
@ -53,7 +53,7 @@ pub unsafe fn config_log(callback: Option<fn(c_int, &str)>) -> Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "trace"` Write a message into the error log established by
|
/// Write a message into the error log established by
|
||||||
/// `config_log`.
|
/// `config_log`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn log(err_code: c_int, msg: &str) {
|
pub fn log(err_code: c_int, msg: &str) {
|
||||||
@ -64,7 +64,7 @@ pub fn log(err_code: c_int, msg: &str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Connection {
|
impl Connection {
|
||||||
/// `feature = "trace"` Register or clear a callback function that can be
|
/// Register or clear a callback function that can be
|
||||||
/// used for tracing the execution of SQL statements.
|
/// used for tracing the execution of SQL statements.
|
||||||
///
|
///
|
||||||
/// Prepared statement placeholders are replaced/logged with their assigned
|
/// Prepared statement placeholders are replaced/logged with their assigned
|
||||||
@ -89,7 +89,7 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "trace"` Register or clear a callback function that can be
|
/// Register or clear a callback function that can be
|
||||||
/// used for profiling the execution of SQL statements.
|
/// used for profiling the execution of SQL statements.
|
||||||
///
|
///
|
||||||
/// There can only be a single profiler defined for each database
|
/// There can only be a single profiler defined for each database
|
||||||
|
@ -15,15 +15,17 @@ pub enum FromSqlError {
|
|||||||
/// requested type.
|
/// requested type.
|
||||||
OutOfRange(i64),
|
OutOfRange(i64),
|
||||||
|
|
||||||
/// `feature = "i128_blob"` Error returned when reading an `i128` from a
|
/// Error returned when reading an `i128` from a
|
||||||
/// blob with a size other than 16. Only available when the `i128_blob`
|
/// blob with a size other than 16. Only available when the `i128_blob`
|
||||||
/// feature is enabled.
|
/// feature is enabled.
|
||||||
#[cfg(feature = "i128_blob")]
|
#[cfg(feature = "i128_blob")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "i128_blob")))]
|
||||||
InvalidI128Size(usize),
|
InvalidI128Size(usize),
|
||||||
|
|
||||||
/// `feature = "uuid"` Error returned when reading a `uuid` from a blob with
|
/// Error returned when reading a `uuid` from a blob with
|
||||||
/// a size other than 16. Only available when the `uuid` feature is enabled.
|
/// a size other than 16. Only available when the `uuid` feature is enabled.
|
||||||
#[cfg(feature = "uuid")]
|
#[cfg(feature = "uuid")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "uuid")))]
|
||||||
InvalidUuidSize(usize),
|
InvalidUuidSize(usize),
|
||||||
|
|
||||||
/// An error case available for implementors of the [`FromSql`] trait.
|
/// An error case available for implementors of the [`FromSql`] trait.
|
||||||
@ -176,6 +178,7 @@ impl FromSql for Vec<u8> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "i128_blob")]
|
#[cfg(feature = "i128_blob")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "i128_blob")))]
|
||||||
impl FromSql for i128 {
|
impl FromSql for i128 {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self> {
|
fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self> {
|
||||||
@ -192,6 +195,7 @@ impl FromSql for i128 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "uuid")]
|
#[cfg(feature = "uuid")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "uuid")))]
|
||||||
impl FromSql for uuid::Uuid {
|
impl FromSql for uuid::Uuid {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self> {
|
fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self> {
|
||||||
|
@ -75,14 +75,18 @@ pub use self::value_ref::ValueRef;
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[cfg(feature = "chrono")]
|
#[cfg(feature = "chrono")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "chrono")))]
|
||||||
mod chrono;
|
mod chrono;
|
||||||
mod from_sql;
|
mod from_sql;
|
||||||
#[cfg(feature = "serde_json")]
|
#[cfg(feature = "serde_json")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "serde_json")))]
|
||||||
mod serde_json;
|
mod serde_json;
|
||||||
#[cfg(feature = "time")]
|
#[cfg(feature = "time")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "time")))]
|
||||||
mod time;
|
mod time;
|
||||||
mod to_sql;
|
mod to_sql;
|
||||||
#[cfg(feature = "url")]
|
#[cfg(feature = "url")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "url")))]
|
||||||
mod url;
|
mod url;
|
||||||
mod value;
|
mod value;
|
||||||
mod value_ref;
|
mod value_ref;
|
||||||
|
@ -16,13 +16,15 @@ pub enum ToSqlOutput<'a> {
|
|||||||
/// An owned SQLite-representable value.
|
/// An owned SQLite-representable value.
|
||||||
Owned(Value),
|
Owned(Value),
|
||||||
|
|
||||||
/// `feature = "blob"` A BLOB of the given length that is filled with
|
/// A BLOB of the given length that is filled with
|
||||||
/// zeroes.
|
/// zeroes.
|
||||||
#[cfg(feature = "blob")]
|
#[cfg(feature = "blob")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "blob")))]
|
||||||
ZeroBlob(i32),
|
ZeroBlob(i32),
|
||||||
|
|
||||||
/// `feature = "array"`
|
/// `feature = "array"`
|
||||||
#[cfg(feature = "array")]
|
#[cfg(feature = "array")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "array")))]
|
||||||
Array(Array),
|
Array(Array),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,9 +72,11 @@ from_value!(Vec<u8>);
|
|||||||
// `i128` needs in `Into<Value>`, but it's probably fine for the moment, and not
|
// `i128` needs in `Into<Value>`, but it's probably fine for the moment, and not
|
||||||
// worth adding another case to Value.
|
// worth adding another case to Value.
|
||||||
#[cfg(feature = "i128_blob")]
|
#[cfg(feature = "i128_blob")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "i128_blob")))]
|
||||||
from_value!(i128);
|
from_value!(i128);
|
||||||
|
|
||||||
#[cfg(feature = "uuid")]
|
#[cfg(feature = "uuid")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "uuid")))]
|
||||||
from_value!(uuid::Uuid);
|
from_value!(uuid::Uuid);
|
||||||
|
|
||||||
impl ToSql for ToSqlOutput<'_> {
|
impl ToSql for ToSqlOutput<'_> {
|
||||||
@ -162,9 +166,11 @@ to_sql_self!(f32);
|
|||||||
to_sql_self!(f64);
|
to_sql_self!(f64);
|
||||||
|
|
||||||
#[cfg(feature = "i128_blob")]
|
#[cfg(feature = "i128_blob")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "i128_blob")))]
|
||||||
to_sql_self!(i128);
|
to_sql_self!(i128);
|
||||||
|
|
||||||
#[cfg(feature = "uuid")]
|
#[cfg(feature = "uuid")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "uuid")))]
|
||||||
to_sql_self!(uuid::Uuid);
|
to_sql_self!(uuid::Uuid);
|
||||||
|
|
||||||
macro_rules! to_sql_self_fallible(
|
macro_rules! to_sql_self_fallible(
|
||||||
|
@ -41,6 +41,7 @@ impl From<isize> for Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "i128_blob")]
|
#[cfg(feature = "i128_blob")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "i128_blob")))]
|
||||||
impl From<i128> for Value {
|
impl From<i128> for Value {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(i: i128) -> Value {
|
fn from(i: i128) -> Value {
|
||||||
@ -54,6 +55,7 @@ impl From<i128> for Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "uuid")]
|
#[cfg(feature = "uuid")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "uuid")))]
|
||||||
impl From<uuid::Uuid> for Value {
|
impl From<uuid::Uuid> for Value {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(id: uuid::Uuid) -> Value {
|
fn from(id: uuid::Uuid) -> Value {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//! `feature = "array"` Array Virtual Table.
|
//! Array Virtual Table.
|
||||||
//!
|
//!
|
||||||
//! Note: `rarray`, not `carray` is the name of the table valued function we
|
//! Note: `rarray`, not `carray` is the name of the table valued function we
|
||||||
//! define.
|
//! define.
|
||||||
@ -57,7 +57,7 @@ impl ToSql for Array {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "array"` Register the "rarray" module.
|
/// Register the "rarray" module.
|
||||||
pub fn load_module(conn: &Connection) -> Result<()> {
|
pub fn load_module(conn: &Connection) -> Result<()> {
|
||||||
let aux: Option<()> = None;
|
let aux: Option<()> = None;
|
||||||
conn.create_module("rarray", eponymous_only_module::<ArrayTab>(), aux)
|
conn.create_module("rarray", eponymous_only_module::<ArrayTab>(), aux)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//! `feature = "csvtab"` CSV Virtual Table.
|
//! CSV Virtual Table.
|
||||||
//!
|
//!
|
||||||
//! Port of [csv](http://www.sqlite.org/cgi/src/finfo?name=ext/misc/csv.c) C
|
//! Port of [csv](http://www.sqlite.org/cgi/src/finfo?name=ext/misc/csv.c) C
|
||||||
//! extension: `https://www.sqlite.org/csv.html`
|
//! extension: `https://www.sqlite.org/csv.html`
|
||||||
@ -35,7 +35,7 @@ use crate::vtab::{
|
|||||||
};
|
};
|
||||||
use crate::{Connection, Error, Result};
|
use crate::{Connection, Error, Result};
|
||||||
|
|
||||||
/// `feature = "csvtab"` Register the "csv" module.
|
/// Register the "csv" module.
|
||||||
/// ```sql
|
/// ```sql
|
||||||
/// CREATE VIRTUAL TABLE vtab USING csv(
|
/// CREATE VIRTUAL TABLE vtab USING csv(
|
||||||
/// filename=FILENAME -- Name of file containing CSV content
|
/// filename=FILENAME -- Name of file containing CSV content
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//! `feature = "vtab"` Create virtual tables.
|
//! Create virtual tables.
|
||||||
//!
|
//!
|
||||||
//! Follow these steps to create your own virtual table:
|
//! Follow these steps to create your own virtual table:
|
||||||
//! 1. Write implementation of [`VTab`] and [`VTabCursor`] traits.
|
//! 1. Write implementation of [`VTab`] and [`VTabCursor`] traits.
|
||||||
@ -57,7 +57,7 @@ use crate::{str_to_cstring, Connection, Error, InnerConnection, Result};
|
|||||||
// ffi::sqlite3_vtab => VTab
|
// ffi::sqlite3_vtab => VTab
|
||||||
// ffi::sqlite3_vtab_cursor => VTabCursor
|
// ffi::sqlite3_vtab_cursor => VTabCursor
|
||||||
|
|
||||||
/// `feature = "vtab"` Virtual table module
|
/// Virtual table module
|
||||||
///
|
///
|
||||||
/// (See [SQLite doc](https://sqlite.org/c3ref/module.html))
|
/// (See [SQLite doc](https://sqlite.org/c3ref/module.html))
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
@ -84,7 +84,7 @@ const ZERO_MODULE: ffi::sqlite3_module = unsafe {
|
|||||||
.module
|
.module
|
||||||
};
|
};
|
||||||
|
|
||||||
/// `feature = "vtab"` Create a read-only virtual table implementation.
|
/// Create a read-only virtual table implementation.
|
||||||
///
|
///
|
||||||
/// Step 2 of [Creating New Virtual Table Implementations](https://sqlite.org/vtab.html#creating_new_virtual_table_implementations).
|
/// Step 2 of [Creating New Virtual Table Implementations](https://sqlite.org/vtab.html#creating_new_virtual_table_implementations).
|
||||||
pub fn read_only_module<'vtab, T: CreateVTab<'vtab>>() -> &'static Module<'vtab, T> {
|
pub fn read_only_module<'vtab, T: CreateVTab<'vtab>>() -> &'static Module<'vtab, T> {
|
||||||
@ -122,7 +122,7 @@ pub fn read_only_module<'vtab, T: CreateVTab<'vtab>>() -> &'static Module<'vtab,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "vtab"` Create an eponymous only virtual table implementation.
|
/// Create an eponymous only virtual table implementation.
|
||||||
///
|
///
|
||||||
/// Step 2 of [Creating New Virtual Table Implementations](https://sqlite.org/vtab.html#creating_new_virtual_table_implementations).
|
/// Step 2 of [Creating New Virtual Table Implementations](https://sqlite.org/vtab.html#creating_new_virtual_table_implementations).
|
||||||
pub fn eponymous_only_module<'vtab, T: VTab<'vtab>>() -> &'static Module<'vtab, T> {
|
pub fn eponymous_only_module<'vtab, T: VTab<'vtab>>() -> &'static Module<'vtab, T> {
|
||||||
@ -187,7 +187,7 @@ impl VTabConnection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "vtab"` Virtual table instance trait.
|
/// Virtual table instance trait.
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
@ -228,7 +228,7 @@ pub unsafe trait VTab<'vtab>: Sized {
|
|||||||
fn open(&'vtab self) -> Result<Self::Cursor>;
|
fn open(&'vtab self) -> Result<Self::Cursor>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "vtab"` Non-eponymous virtual table instance trait.
|
/// Non-eponymous virtual table instance trait.
|
||||||
///
|
///
|
||||||
/// (See [SQLite doc](https://sqlite.org/c3ref/vtab.html))
|
/// (See [SQLite doc](https://sqlite.org/c3ref/vtab.html))
|
||||||
pub trait CreateVTab<'vtab>: VTab<'vtab> {
|
pub trait CreateVTab<'vtab>: VTab<'vtab> {
|
||||||
@ -257,7 +257,7 @@ pub trait CreateVTab<'vtab>: VTab<'vtab> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "vtab"` Index constraint operator.
|
/// Index constraint operator.
|
||||||
/// See [Virtual Table Constraint Operator Codes](https://sqlite.org/c3ref/c_index_constraint_eq.html) for details.
|
/// See [Virtual Table Constraint Operator Codes](https://sqlite.org/c3ref/c_index_constraint_eq.html) for details.
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
#[allow(non_snake_case, non_camel_case_types, missing_docs)]
|
#[allow(non_snake_case, non_camel_case_types, missing_docs)]
|
||||||
@ -302,7 +302,7 @@ impl From<u8> for IndexConstraintOp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "vtab"` Pass information into and receive the reply from the
|
/// Pass information into and receive the reply from the
|
||||||
/// [`VTab::best_index`] method.
|
/// [`VTab::best_index`] method.
|
||||||
///
|
///
|
||||||
/// (See [SQLite doc](http://sqlite.org/c3ref/index_info.html))
|
/// (See [SQLite doc](http://sqlite.org/c3ref/index_info.html))
|
||||||
@ -370,6 +370,7 @@ impl IndexInfo {
|
|||||||
|
|
||||||
/// Estimated number of rows returned.
|
/// Estimated number of rows returned.
|
||||||
#[cfg(feature = "modern_sqlite")] // SQLite >= 3.8.2
|
#[cfg(feature = "modern_sqlite")] // SQLite >= 3.8.2
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "modern_sqlite")))]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_estimated_rows(&mut self, estimated_rows: i64) {
|
pub fn set_estimated_rows(&mut self, estimated_rows: i64) {
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -402,7 +403,7 @@ impl<'a> Iterator for IndexConstraintIter<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "vtab"` WHERE clause constraint.
|
/// WHERE clause constraint.
|
||||||
pub struct IndexConstraint<'a>(&'a ffi::sqlite3_index_constraint);
|
pub struct IndexConstraint<'a>(&'a ffi::sqlite3_index_constraint);
|
||||||
|
|
||||||
impl IndexConstraint<'_> {
|
impl IndexConstraint<'_> {
|
||||||
@ -425,7 +426,7 @@ impl IndexConstraint<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "vtab"` Information about what parameters to pass to
|
/// Information about what parameters to pass to
|
||||||
/// [`VTabCursor::filter`].
|
/// [`VTabCursor::filter`].
|
||||||
pub struct IndexConstraintUsage<'a>(&'a mut ffi::sqlite3_index_constraint_usage);
|
pub struct IndexConstraintUsage<'a>(&'a mut ffi::sqlite3_index_constraint_usage);
|
||||||
|
|
||||||
@ -463,7 +464,7 @@ impl<'a> Iterator for OrderByIter<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "vtab"` A column of the ORDER BY clause.
|
/// A column of the ORDER BY clause.
|
||||||
pub struct OrderBy<'a>(&'a ffi::sqlite3_index_info_sqlite3_index_orderby);
|
pub struct OrderBy<'a>(&'a ffi::sqlite3_index_info_sqlite3_index_orderby);
|
||||||
|
|
||||||
impl OrderBy<'_> {
|
impl OrderBy<'_> {
|
||||||
@ -480,7 +481,7 @@ impl OrderBy<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "vtab"` Virtual table cursor trait.
|
/// Virtual table cursor trait.
|
||||||
///
|
///
|
||||||
/// Implementations must be like:
|
/// Implementations must be like:
|
||||||
/// ```rust,ignore
|
/// ```rust,ignore
|
||||||
@ -514,7 +515,7 @@ pub unsafe trait VTabCursor: Sized {
|
|||||||
fn rowid(&self) -> Result<i64>;
|
fn rowid(&self) -> Result<i64>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "vtab"` Context is used by [`VTabCursor::column`] to specify the
|
/// Context is used by [`VTabCursor::column`] to specify the
|
||||||
/// cell value.
|
/// cell value.
|
||||||
pub struct Context(*mut ffi::sqlite3_context);
|
pub struct Context(*mut ffi::sqlite3_context);
|
||||||
|
|
||||||
@ -530,7 +531,7 @@ impl Context {
|
|||||||
// TODO sqlite3_vtab_nochange (http://sqlite.org/c3ref/vtab_nochange.html)
|
// TODO sqlite3_vtab_nochange (http://sqlite.org/c3ref/vtab_nochange.html)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "vtab"` Wrapper to [`VTabCursor::filter`] arguments, the values
|
/// Wrapper to [`VTabCursor::filter`] arguments, the values
|
||||||
/// requested by [`VTab::best_index`].
|
/// requested by [`VTab::best_index`].
|
||||||
pub struct Values<'a> {
|
pub struct Values<'a> {
|
||||||
args: &'a [*mut ffi::sqlite3_value],
|
args: &'a [*mut ffi::sqlite3_value],
|
||||||
@ -560,10 +561,12 @@ impl Values<'_> {
|
|||||||
}
|
}
|
||||||
FromSqlError::OutOfRange(i) => Error::IntegralValueOutOfRange(idx, i),
|
FromSqlError::OutOfRange(i) => Error::IntegralValueOutOfRange(idx, i),
|
||||||
#[cfg(feature = "i128_blob")]
|
#[cfg(feature = "i128_blob")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "i128_blob")))]
|
||||||
FromSqlError::InvalidI128Size(_) => {
|
FromSqlError::InvalidI128Size(_) => {
|
||||||
Error::InvalidColumnType(idx, idx.to_string(), value.data_type())
|
Error::InvalidColumnType(idx, idx.to_string(), value.data_type())
|
||||||
}
|
}
|
||||||
#[cfg(feature = "uuid")]
|
#[cfg(feature = "uuid")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "uuid")))]
|
||||||
FromSqlError::InvalidUuidSize(_) => {
|
FromSqlError::InvalidUuidSize(_) => {
|
||||||
Error::FromSqlConversionFailure(idx, value.data_type(), Box::new(err))
|
Error::FromSqlConversionFailure(idx, value.data_type(), Box::new(err))
|
||||||
}
|
}
|
||||||
@ -573,6 +576,7 @@ impl Values<'_> {
|
|||||||
// `sqlite3_value_type` returns `SQLITE_NULL` for pointer.
|
// `sqlite3_value_type` returns `SQLITE_NULL` for pointer.
|
||||||
// So it seems not possible to enhance `ValueRef::from_value`.
|
// So it seems not possible to enhance `ValueRef::from_value`.
|
||||||
#[cfg(feature = "array")]
|
#[cfg(feature = "array")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "array")))]
|
||||||
fn get_array(&self, idx: usize) -> Option<array::Array> {
|
fn get_array(&self, idx: usize) -> Option<array::Array> {
|
||||||
use crate::types::Value;
|
use crate::types::Value;
|
||||||
let arg = self.args[idx];
|
let arg = self.args[idx];
|
||||||
@ -630,7 +634,7 @@ impl<'a> Iterator for ValueIter<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Connection {
|
impl Connection {
|
||||||
/// `feature = "vtab"` Register a virtual table implementation.
|
/// Register a virtual table implementation.
|
||||||
///
|
///
|
||||||
/// Step 3 of [Creating New Virtual Table
|
/// Step 3 of [Creating New Virtual Table
|
||||||
/// Implementations](https://sqlite.org/vtab.html#creating_new_virtual_table_implementations).
|
/// Implementations](https://sqlite.org/vtab.html#creating_new_virtual_table_implementations).
|
||||||
@ -680,7 +684,7 @@ impl InnerConnection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `feature = "vtab"` Escape double-quote (`"`) character occurrences by
|
/// Escape double-quote (`"`) character occurrences by
|
||||||
/// doubling them (`""`).
|
/// doubling them (`""`).
|
||||||
pub fn escape_double_quote(identifier: &str) -> Cow<'_, str> {
|
pub fn escape_double_quote(identifier: &str) -> Cow<'_, str> {
|
||||||
if identifier.contains('"') {
|
if identifier.contains('"') {
|
||||||
@ -690,7 +694,7 @@ pub fn escape_double_quote(identifier: &str) -> Cow<'_, str> {
|
|||||||
Borrowed(identifier)
|
Borrowed(identifier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// `feature = "vtab"` Dequote string
|
/// Dequote string
|
||||||
pub fn dequote(s: &str) -> &str {
|
pub fn dequote(s: &str) -> &str {
|
||||||
if s.len() < 2 {
|
if s.len() < 2 {
|
||||||
return s;
|
return s;
|
||||||
@ -703,7 +707,7 @@ pub fn dequote(s: &str) -> &str {
|
|||||||
_ => s,
|
_ => s,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// `feature = "vtab"` The boolean can be one of:
|
/// The boolean can be one of:
|
||||||
/// ```text
|
/// ```text
|
||||||
/// 1 yes true on
|
/// 1 yes true on
|
||||||
/// 0 no false off
|
/// 0 no false off
|
||||||
@ -1072,10 +1076,13 @@ fn alloc(s: &str) -> *mut c_char {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "array")]
|
#[cfg(feature = "array")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "array")))]
|
||||||
pub mod array;
|
pub mod array;
|
||||||
#[cfg(feature = "csvtab")]
|
#[cfg(feature = "csvtab")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "csvtab")))]
|
||||||
pub mod csvtab;
|
pub mod csvtab;
|
||||||
#[cfg(feature = "series")]
|
#[cfg(feature = "series")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "series")))]
|
||||||
pub mod series; // SQLite >= 3.9.0
|
pub mod series; // SQLite >= 3.9.0
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//! `feature = "series"` Generate series virtual table.
|
//! Generate series virtual table.
|
||||||
//!
|
//!
|
||||||
//! Port of C [generate series
|
//! Port of C [generate series
|
||||||
//! "function"](http://www.sqlite.org/cgi/src/finfo?name=ext/misc/series.c):
|
//! "function"](http://www.sqlite.org/cgi/src/finfo?name=ext/misc/series.c):
|
||||||
@ -15,7 +15,7 @@ use crate::vtab::{
|
|||||||
};
|
};
|
||||||
use crate::{Connection, Error, Result};
|
use crate::{Connection, Error, Result};
|
||||||
|
|
||||||
/// `feature = "series"` Register the "generate_series" module.
|
/// Register the "generate_series" module.
|
||||||
pub fn load_module(conn: &Connection) -> Result<()> {
|
pub fn load_module(conn: &Connection) -> Result<()> {
|
||||||
let aux: Option<()> = None;
|
let aux: Option<()> = None;
|
||||||
conn.create_module("generate_series", eponymous_only_module::<SeriesTab>(), aux)
|
conn.create_module("generate_series", eponymous_only_module::<SeriesTab>(), aux)
|
||||||
|
Loading…
Reference in New Issue
Block a user